memhq-langchain
MemHQ adapter for LangChain (Python). Drop-in chat message history and retriever backed by the MemHQ hosted API. Sync and async both supported via httpx.
Install
pip install memhq-langchain
Quickstart — Chat history
import os
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables.history import RunnableWithMessageHistory
from memhq_langchain import MemHQChatMessageHistory
model = ChatOpenAI(model="gpt-4o-mini")
prompt = ChatPromptTemplate.from_messages([
("system", "You have access to the user's memory."),
MessagesPlaceholder("history"),
("human", "{input}"),
])
chain = RunnableWithMessageHistory(
prompt | model,
lambda session_id: MemHQChatMessageHistory(
api_key=os.environ["MEMHQ_API_KEY"],
session_id=session_id,
user_id="user_42",
),
input_messages_key="input",
history_messages_key="history",
)
reply = chain.invoke(
{"input": "What's my favorite coffee order?"},
config={"configurable": {"session_id": "conv_42"}},
)
Quickstart — Retriever
from memhq_langchain import MemHQRetriever
retriever = MemHQRetriever(
api_key=os.environ["MEMHQ_API_KEY"],
user_id="user_42",
limit=8,
)
docs = retriever.invoke("pricing discussions")
Configuration
| Argument | Description |
|---|---|
api_key |
MemHQ project API key. Falls back to MEMHQ_API_KEY. |
user_id |
External user id. Required. |
session_id |
Thread anchor for the history adapter. |
recall_limit |
Memories surfaced per history read. Default 10. |
limit |
Memories returned per retriever query. Default 10. |
mode |
"hybrid" (default), "vector", or "lexical". |
base_url |
Override the API base. |
Reference
Full reference: https://docs.memhq.ai/sdks/langchain-py
Metadata
Release files for memhq-langchain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memhq_langchain-0.1.0.tar.gz | 9.3 kB | Without provenance | Details for memhq_langchain-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memhq_langchain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for memhq_langchain-0.1.0-py3-none-any.whl |
Total release size: 20.1 kB
Release files / memhq_langchain-0.1.0.tar.gz
| Download URL | memhq_langchain-0.1.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1dabae72c5e318e497d0172ef06c18915aba7b7a4762e7acb66504bdcfb7e64
|
|
BLAKE2b-256 checksum How to use checksums |
cd978930a90139bf96d65fd4e9d44cd80c3dd0ed94dec1099c1840ebe497a24a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Release files / memhq_langchain-0.1.0-py3-none-any.whl
| Download URL | memhq_langchain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2067175ab00b67d275f73cc2c4c192985c2ffb3535e37f192fba465d8392fb5a
|
|
BLAKE2b-256 checksum How to use checksums |
d7aa37be87e173c4b9e111f831329ac69710aaa4536548d03e17db40798c705a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Security for memhq-langchain 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.