Skip to main content

LangChain BaseMemory adapter backed by MuBit memory engine

Project description

mubit-langchain

LangChain BaseMemory backed by MuBit.

This adapter provides BaseMemory and chat-oriented subclasses that route all memory operations through MuBit's control plane.

Install

pip install mubit-langchain[langchain]

Basic usage

ConversationChain

from mubit_langchain import MubitMemory
from langchain.chains import ConversationChain

memory = MubitMemory(api_key="mbt_...", session_id="chain-1")
chain = ConversationChain(llm=llm, memory=memory)
chain.run("Hello")  # auto-loads context, auto-saves interaction

Chat-oriented (returns Message objects)

from mubit_langchain import MubitChatMemory

memory = MubitChatMemory(api_key="mbt_...", session_id="chat-1")
# Returns SystemMessage objects instead of raw strings

BaseMemory interface

Method MuBit mapping
memory_variables Returns [memory_key]
load_memory_variables(inputs) control.context — semantic context retrieval
save_context(inputs, outputs) control.ingest — stores input/output pair
clear() control.delete_run

MubitMemory vs MubitChatMemory

Feature MubitMemory MubitChatMemory
Return type Raw string SystemMessage list
Save behavior Single combined trace Individual messages
Default return_messages False True

Config

Parameter Default Purpose
endpoint http://127.0.0.1:3000 MuBit HTTP endpoint
api_key "" MuBit API key
session_id "default" Session/run scope
memory_key "history" Key in memory variables dict
input_key None Explicit input key (auto-detect if None)
output_key None Explicit output key (auto-detect if None)
return_messages False Return SystemMessage objects
max_token_budget 2048 Token budget for context retrieval

Development

PYTHONPATH=sdk/python/mubit-sdk/src:integrations/python \
python3 -m unittest integrations.python.mubit_langchain.tests.test_memory -v

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mubit_langchain-0.5.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mubit_langchain-0.5.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file mubit_langchain-0.5.3.tar.gz.

File metadata

  • Download URL: mubit_langchain-0.5.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for mubit_langchain-0.5.3.tar.gz
Algorithm Hash digest
SHA256 43d57a324461d9b6dd5c17965a8dc80405653d4e0ef5fb0cd3724f4efcd4e6c2
MD5 e0d1ad238e394c6bbd31cf25439f8977
BLAKE2b-256 e45572e6179a9cfecc2800af252368c7f50c1d5f26d32b90bdea88d3620f8ff1

See more details on using hashes here.

File details

Details for the file mubit_langchain-0.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mubit_langchain-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c95443235db7f997be39cb5f84fcc7f2e2332c8caad55a0df5dc37ce5a65bbd
MD5 ffaf1f6af177496c1984352acd624ece
BLAKE2b-256 2101fd5e803460b60e95da5d9c73f398b5c71f21b71e51f17fd7e4310e845dde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page