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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mubit_langchain-0.5.2.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.2.tar.gz
Algorithm Hash digest
SHA256 61238add1cbc17395ffee1fc1d9ca6002b18697c832460870794df2d7b7799cf
MD5 773e57871dc88b3ca5e78369cbb6e103
BLAKE2b-256 96741fb6f81f9478af53a470420bdb474bc207c4f6e54a371e67df5c61fb67a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mubit_langchain-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0d4f6676a2fd8c80caba2bbe2c0c6f7e501725c30ea514882a2a1dbdb3302ba2
MD5 c72c8f4133ec3217ed0b6fe8327ed8dc
BLAKE2b-256 3d00276e3e60a85e391ff54de7dfd00d918a6be7f87ea7f97f2c216e630603bd

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