Skip to main content

LangChain and LlamaIndex memory adapters for EidolonDB

Project description

eidolondb-adapters

LangChain and LlamaIndex memory adapters for EidolonDB.

Installation

pip install "eidolondb-adapters[langchain]"
# or
pip install "eidolondb-adapters[llamaindex]"
# or
pip install "eidolondb-adapters[all]"

Works with both self-hosted EidolonDB and the EidolonDB Cloud API (eidolondb.com).

LangChain Example

from langchain_core.language_models import FakeListLLM
from langchain.chains import ConversationChain

from eidolondb_adapters import EidolonMemory

memory = EidolonMemory(
    url="http://localhost:3000",
    tenant="my-tenant",
    k=5,
    memory_key="history",
    input_key="input",
    output_key="response",
)

llm = FakeListLLM(responses=["I can help with that."])
chain = ConversationChain(llm=llm, memory=memory)

result = chain.predict(input="We chose PostgreSQL for analytics.")
print(result)

LlamaIndex Example

from llama_index.core.chat_engine import SimpleChatEngine
from llama_index.core.llms import ChatMessage, MessageRole

from eidolondb_adapters import EidolonMemoryBuffer

memory = EidolonMemoryBuffer.from_defaults(
    url="http://localhost:3000",
    tenant="my-tenant",
    k=5,
)

# You can still push messages directly if needed.
memory.put(ChatMessage(role=MessageRole.USER, content="My preferred editor is Neovim."))

chat_engine = SimpleChatEngine.from_defaults(memory=memory)
response = chat_engine.chat("What tools do I prefer?")
print(response)

Configuration

Parameter Applies To Default Description
url LangChain, LlamaIndex http://localhost:3000 EidolonDB base URL (local or cloud endpoint).
tenant LangChain, LlamaIndex default Tenant ID used by the EidolonDB SDK.
k LangChain, LlamaIndex 5 Number of recalled memories to fetch per query.
input_key LangChain input Input key used to read the current user prompt.
output_key LangChain output Output key used to ingest the model response.
memory_key LangChain history Variable name injected into LangChain memory context.
return_messages LangChain False Return HumanMessage objects instead of a joined string.

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

eidolondb_adapters-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

eidolondb_adapters-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eidolondb_adapters-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for eidolondb_adapters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9720cdd06fac44467f84e864cec86ee884454636865ddaf4e058ca60742210d
MD5 01ca5cfa3261a3ae6596f9dcda03e7d9
BLAKE2b-256 5f103898d4884355be4f0315db92b8f2f343a9bbed8248671b5a119c2cc26fc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eidolondb_adapters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa1b1c387578f2774a77f9c8574dc5ba0bb96d603b30cffa6954aa98e2f63069
MD5 2c72859774f3efbb2f55f31a1009d7b7
BLAKE2b-256 38a74250f676e6c9dda01a6fbe5b9ad50ad62cda3d4a52f05de3f2e9ff97658a

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