Metadata-Version: 2.4
Name: langchain-chordian-knowledge-memory
Version: 0.1.0
Summary: LangChain tools for Chordian Knowledge Memory
License-Expression: MIT
Project-URL: Repository, https://github.com/SitaChopra/langchain-chordian-knowledge-memory
Project-URL: Documentation, https://github.com/SitaChopra/langchain-chordian-knowledge-memory#readme
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: langchain-core<2.0,>=1.0
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: uvicorn>=0.30; extra == "test"
Dynamic: license-file

# Chordian Knowledge Memory for LangChain

`langchain-chordian-knowledge-memory` provides LangChain tools for Chordian's Memory REST API. It is separate from the Memory MCP client and from Chordian's platform Search API for people and companies.

## What it provides

- `chordian_memory_search` searches the configured knowledge memory.
- `chordian_memory_save` writes text and metadata to memory.
- `chordian_memory_get_entity` explores an entity in the memory graph.

Search and save use the documented Memory API endpoints. Platform Search API functions are intentionally out of scope for this package.

## Requirements

- Python 3.11 or newer.
- A Chordian Memory API endpoint, such as `https://acme-1045.api.chordian.ai`.
- A Memory key (`mk_...`) or an authorized OAuth access token. Platform keys (`ck_...`) are not supported here.
- HTTPS for remote endpoints. Plain HTTP is permitted only for loopback testing.

The Memory key is sent in the `Authorization: Bearer` header. It is never placed in a URL, tool argument, or returned result.

## Install and configure

Install the package from PyPI:

```sh
python -m pip install langchain-chordian-knowledge-memory
```

Set the endpoint and key in the environment, or pass them directly to `create_memory_tools`:

```sh
export CHORDIAN_MEMORY_ENDPOINT="https://acme-1045.api.chordian.ai"
read -r -s -p 'Chordian Memory key: ' CHORDIAN_MEMORY_API_KEY
export CHORDIAN_MEMORY_API_KEY
```

PowerShell:

```powershell
$env:CHORDIAN_MEMORY_ENDPOINT = "https://acme-1045.api.chordian.ai"
$secret = Read-Host 'Chordian Memory key' -AsSecureString
$env:CHORDIAN_MEMORY_API_KEY = [System.Net.NetworkCredential]::new('', $secret).Password
Remove-Variable secret
```

Do not commit real keys or paste them into prompts. Use a least-privilege Memory key and an approved expiration.

## Use the tools

```python
from langchain_chordian_knowledge_memory import create_memory_tools

tools = create_memory_tools()
```

Use the returned tools with a LangChain agent, or call one directly:

```python
search = next(tool for tool in tools if tool.name == "chordian_memory_search")
answer = await search.ainvoke({"query": "What is our refund window?", "top_k": 5})
```

`chordian_memory_save` changes stored data. Agents may call it if it is included in their tool list; review tool permissions and calls. Memory search results are returned to the calling application and may be sent to its model provider.

Optional default scopes can be fixed when constructing tools:

```python
tools = create_memory_tools(vault="Sales", space="spc_123")
```

Individual search/save calls may also provide `vault` or `space` to select a scope.

## API behavior

The tools follow the Chordian Python SDK contract:

- Search: `POST /api/v1/memory/search`, with `query`, `limit`, and `top_k`.
- Save: `POST /api/v1/memory/ingest`, with content, metadata, and routing.
- Entity lookup: `GET /api/v1/memory/graph/explore/{entity_id}`, with `depth`.

The platform Search API for company and people search is a separate API with a different host and key. It will be handled separately.

## Test and build

```sh
python -m pip install -e ".[test]" ruff build
python -m pytest -q
ruff check .
python -m build
```

Tests use a local fake HTTP server. They do not call a live Chordian tenant or require a real key.

## Source and license

The Memory API contract is documented in the [Chordian Python SDK](https://github.com/engineering-chordian/chordian-library/tree/master/sdks/python). This candidate uses MIT licensing, matching that repository's license.
