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.1.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.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mubit_langchain-0.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2bbb8886f22a126b07f82ca37f212ca393b65e6e15205cb95a6d6e794726077e
MD5 725dc70382f89715acdf1edeec2d6c97
BLAKE2b-256 b2701ca50653c8476ffafd97b9d40ccdd8d7d64136f04a5cf00299b4252cc101

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mubit_langchain-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc2b6adfaf60f96147c3c664e9894b39839d7a9173345d3f5e44eed5b404c45f
MD5 6cf0061359a83b9a1e22cce38f45642b
BLAKE2b-256 61cdce6593757d22556184b65fa72f676f9bb73d956fd8aa10eb6672c3a85ed5

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