Skip to main content

InfoLang memory integration for LlamaIndex

Project description

LlamaIndex Memory Integration: InfoLang

InfoLang 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:

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:

pip install git+https://github.com/InfoLang-Inc/llama-index-memory-infolang.git

Usage

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:

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

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

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.

References

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

llama_index_memory_infolang-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_memory_infolang-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_memory_infolang-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_memory_infolang-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for llama_index_memory_infolang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 031ebde60ab5c288099217e405f92a5cbb42250d7d9529a4b2f2ce23c47394d9
MD5 848df97a57279dbf0790ba442d7bedf8
BLAKE2b-256 81b0b7aa192193440b2df99c119507e1f0617caa73c1e6dadc1d502589da2181

See more details on using hashes here.

File details

Details for the file llama_index_memory_infolang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_memory_infolang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for llama_index_memory_infolang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95df8d5c1e87a51c1c37f430bfba293a7e1da8f0af38e2299886b31ef75ff3f4
MD5 9297718a06023c7b3648ae20befc9c88
BLAKE2b-256 a511919b0d7ec49ea9c5e4ebb7cd45d92c104e4727e8f9c396340d26ebb8ff91

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