diff --git a/packages.yml b/packages.yml index 0ca1804a51..f284934d42 100644 --- a/packages.yml +++ b/packages.yml @@ -100,6 +100,10 @@ packages: js: "@langchain/deepseek" downloads: 697000 downloads_updated_at: "2026-05-18T00:23:32.797657+00:00" +- name: langchain-engram + repo: Harshitk-cp/langchain-engram + downloads: 0 + downloads_updated_at: "2026-05-29T00:00:00.000000+00:00" - name: langchain-exa repo: langchain-ai/langchain path: libs/partners/exa diff --git a/src/oss/python/integrations/providers/all_providers.mdx b/src/oss/python/integrations/providers/all_providers.mdx index e18a0c5f6a..151f8b58e0 100644 --- a/src/oss/python/integrations/providers/all_providers.mdx +++ b/src/oss/python/integrations/providers/all_providers.mdx @@ -417,6 +417,14 @@ Browse the complete collection of integrations available for Python. LangChain P Cloud content collaboration and AI-powered search platform. + + Cognitive memory infrastructure for AI agents — confidence scoring, contradiction detection, and memory lifecycle. + + +```bash pip +pip install langchain-engram +``` + +```bash uv +uv add langchain-engram +``` + + +Set environment variables: + +```bash +export ENGRAM_BASE_URL=http://localhost:8080 +export ENGRAM_API_KEY=mk_... +``` + +See the [Engram quickstart](https://engram.ai#quickstart) for server setup. + +## Retrievers + +See the [EngramRetriever documentation](/oss/integrations/retrievers/engram) for +memory-backed retrieval with confidence filtering and hybrid recall. diff --git a/src/oss/python/integrations/retrievers/engram.mdx b/src/oss/python/integrations/retrievers/engram.mdx new file mode 100644 index 0000000000..12bd8fef54 --- /dev/null +++ b/src/oss/python/integrations/retrievers/engram.mdx @@ -0,0 +1,118 @@ +--- +title: "Engram retriever" +description: "Integrate with the Engram retriever using LangChain Python." +--- + +# EngramRetriever + +This will help you get started with the Engram [retriever](/oss/langchain/retrieval). + +Engram is cognitive memory infrastructure for AI agents—tracking not just what +agents know, but how confident they should be, and when to doubt it. Each retrieved +memory is a `Document` carrying confidence score, memory tier, and relevance scores +from Engram's hybrid vector + knowledge-graph recall. + +### Integration details + +| Retriever | Self-host | Cloud offering | Package | +| :--- | :---: | :---: | :---: | +| `EngramRetriever` | ✅ | ✅ | `langchain-engram` | + +## Setup + +### Installation + +```bash +pip install langchain-engram +``` + +### Start the server + +```bash +git clone https://github.com/Harshitk-cp/engram.git +cd engram +ENGRAM_SETUP_TOKEN=changeme docker compose up -d + +# Get your API key (run once) +curl -X POST http://localhost:8080/v1/setup \ + -H "X-Setup-Token: changeme" \ + -H "Content-Type: application/json" \ + -d '{"org_name": "My Org"}' +# → {"api_key": "mk_..."} +``` + +### Environment variables + +```bash +export ENGRAM_BASE_URL=http://localhost:8080 +export ENGRAM_API_KEY=mk_... +``` + +## Instantiation + +```python +from langchain_engram import EngramRetriever + +retriever = EngramRetriever( + agent_id="your-agent-uuid", + # api_key and base_url read from env if not passed + top_k=5, + min_confidence=0.6, # only surface confident memories +) +``` + +## Usage + +```python +docs = retriever.invoke("display preferences") +for doc in docs: + print(doc.page_content) + print(f" confidence: {doc.metadata['confidence']:.0%}") + print(f" tier: {doc.metadata['tier']}") # hot / warm / cold + print(f" type: {doc.metadata['memory_type']}") # fact / preference / decision + print(f" score: {doc.metadata.get('score', 'n/a')}") +``` + +### In a RetrievalQA chain + +```python +from langchain.chains import RetrievalQA +from langchain_openai import ChatOpenAI + +qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(), retriever=retriever) +answer = qa.invoke({"query": "What are the user's display preferences?"}) +``` + +### Document metadata fields + +| Field | Type | Description | +| :--- | :--- | :--- | +| `memory_id` | `str` | UUID of the memory | +| `agent_id` | `str` | Owning agent UUID | +| `memory_type` | `str` | `fact` / `preference` / `decision` / `constraint` | +| `confidence` | `float` | Calibrated confidence score (0–1) | +| `tier` | `str` | `hot` / `warm` / `cold` | +| `source` | `str` | Origin of the memory | +| `score` | `float` | Combined recall score | +| `vector_score` | `float` | Vector similarity component | +| `graph_score` | `float` | Graph traversal component | +| `created_at` | `str` | ISO 8601 timestamp | + +## Configuration + +| Parameter | Default | Description | +| :--- | :--- | :--- | +| `agent_id` | required | Engram agent UUID | +| `api_key` | `ENGRAM_API_KEY` env | `mk_` or `rk_` prefixed API key | +| `base_url` | `ENGRAM_BASE_URL` env | Engram server URL | +| `top_k` | `10` | Max memories to return | +| `min_confidence` | `None` | Confidence floor (0–1) | +| `memory_type` | `None` | Filter by type: `fact`, `preference`, `decision`, `constraint` | +| `graph_weight` | `None` | Graph/vector blend (0–1); server default 0.4/0.6 | + +## Related links + +- [Engram documentation](https://engram.ai) +- [Python SDK (engram.to)](https://pypi.org/project/engram.to/) +- [GitHub](https://github.com/Harshitk-cp/langchain-engram) +- [Provider page](/oss/integrations/providers/engram) diff --git a/src/oss/python/integrations/retrievers/index.mdx b/src/oss/python/integrations/retrievers/index.mdx index 11cbf2740c..81eb050e56 100644 --- a/src/oss/python/integrations/retrievers/index.mdx +++ b/src/oss/python/integrations/retrievers/index.mdx @@ -50,6 +50,7 @@ The below retrievers will search over an external index (e.g., constructed from +