Metadata-Version: 2.4
Name: llama-index-memory-infolang
Version: 0.1.0
Summary: InfoLang memory integration for LlamaIndex
Project-URL: Homepage, https://infolang.ai
Project-URL: Repository, https://github.com/InfoLang-Inc/llama-index-memory-infolang
Project-URL: Issues, https://github.com/InfoLang-Inc/llama-index-memory-infolang/issues
Author-email: InfoLang <engineering@infolang.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,infolang,llama-index,memory,semantic-memory
Requires-Python: <4.0,>=3.11
Requires-Dist: infolang<1.0,>=0.2.0
Requires-Dist: llama-index-core<0.15,>=0.13.0
Description-Content-Type: text/markdown

# LlamaIndex Memory Integration: InfoLang

[InfoLang](https://infolang.ai) is a hosted semantic memory API: `remember` stores text
into a namespace, `recall`/`recall_hybrid` retrieves the most relevant chunks for a
query. This package adapts it to LlamaIndex's `BaseMemory` interface.

## Installation

Once published to PyPI, installation will be:

```bash
pip install llama-index-memory-infolang
```

> Note: PyPI publication of this package and of its `infolang>=0.2.0` dependency is
> pending. Until then, install both from source:
>
> ```bash
> pip install git+https://github.com/InfoLang-Inc/llama-index-memory-infolang.git
> ```

## Usage

```python
from llama_index.memory.infolang import InfoLangMemory

memory = InfoLangMemory.from_api_key(
    api_key="il_live_...",
    namespace="user-123",  # optional; falls back to the key's default namespace
    top_k=5,  # optional, default is 5
)
```

You can also pass an already-constructed `infolang.InfoLang` client, e.g. to point at
a self-hosted runtime or reuse an existing client:

```python
from infolang import InfoLang
from llama_index.memory.infolang import InfoLangMemory

client = InfoLang(dev_key="il_dev_...", base_url="http://127.0.0.1:8766")
memory = InfoLangMemory.from_client(client, namespace="user-123")
```

Each `put`/`set` call writes new user/assistant messages to InfoLang via `remember`.
Each `get` call folds the current turn (or an explicit `input` string) into an InfoLang
`recall`, and prepends the recalled chunks to the local chat history as a system
message — local chat history itself is kept in-process and is not read back from
InfoLang, so `reset()` only clears the local buffer; it does not delete anything
server-side.

### With a chat engine

```python
import os
from llama_index.llms.openai import OpenAI
from llama_index.core import SimpleChatEngine

os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
llm = OpenAI(model="gpt-4o")

chat_engine = SimpleChatEngine.from_defaults(llm=llm, memory=memory)
response = chat_engine.chat("Hi, my name is Mayank")
print(response)
```

### With an agent

```python
from llama_index.core.agent.workflow import FunctionAgent

agent = FunctionAgent(tools=[...], llm=llm)
response = await agent.run("Hi, my name is Mayank", memory=memory)
print(response)
```

> Note: For a full walkthrough see the [example notebook](https://github.com/InfoLang-Inc/llama-index-memory-infolang/blob/main/examples/InfoLangMemory.ipynb).

## References

- [InfoLang](https://infolang.ai)
- [InfoLang Python SDK](https://infolang.ai/docs/sdk/python)
