Skip to main content

Drop-in RecallIO Memory for LangChain

Project description

Recallio Memory for LangChain

This repository provides an implementation of RecallioMemory, a drop‑in replacement for BaseMemory from LangChain. It stores conversation history in the Recallio cloud service using the official recallio client (version 1.2.4).

Features

  • Scoped writes – memories can be associated with a specific session_id or user_id.
  • TTL support – pass a time‑to‑live in seconds and it will be converted to an expiration timestamp stored alongside each memory.
  • Vector recall – previous messages are retrieved from Recallio using semantic search. Memories can also be filtered by custom tags.

Installation

pip install recallio==1.2.4 langchain

Usage

from langchain_recallio.memory import RecallioMemory
from langchain.chains import ConversationChain
from langchain.llms import OpenAI

memory = RecallioMemory(
    api_key="YOUR_RECALLIO_API_KEY",
    project_id="my-project",
    user_id="alice",
    session_id="chat-session-1",
    ttl_seconds=3600,  # expire after one hour
)
llm = OpenAI()

chain = ConversationChain(llm=llm, memory=memory)

response = chain.run("Who won the World Cup in 2022?")
print(response)

# Store an interaction
memory.save_context({"input": "Hello"}, {"output": "Hi there!"})

# Load recent conversation history to inject into a prompt
history = memory.load_memory_variables({"input": "What's up?"})
print(history)

Running the tests

pytest

The tests use mocks and do not require a valid Recallio API key.

License

This project is distributed under the MIT license.

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

langchain_recallio-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

langchain_recallio-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_recallio-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for langchain_recallio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9a6fdc09fbb475d4e393d95759675648ce60bed5bc7fefcde30d0720f0275349
MD5 f7042942d22d9e84921d62f2b47a50d9
BLAKE2b-256 b65da5068826c4a60f0c7347791495e8e3fc72252ad4466f2a1f7b0554864506

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_recallio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b70cf81ebbe3f8d2f3700e4695bec57345d2557b73d49af219fe0b57657a2e4b
MD5 37a9956c69f1d91ac07f820f611a6426
BLAKE2b-256 f1f0acbd1826ed0590dd5851f5ce9a332583ccc2d30506091845404302688897

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