Skip to main content

Persistent memory integration for LangChain powered by Alchemyst AI

Project description

Alchemyst LangChain

Persistent memory for LangChain powered by Alchemyst AI.


Installation

pip install alchemyst-langchain

Quick Start

from alchemyst_langchain import AlchemystMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI

# Create persistent memory
memory = AlchemystMemory(
    api_key="your-alchemyst-api-key",
    session_id="user-123"
)

# Use with LangChain
llm = ChatOpenAI(model="gpt-4o-mini")
chain = ConversationChain(llm=llm, memory=memory)

# Chat
response = chain.invoke({"input": "My name is Alice"})
print(response['response'])

# Later... memory persists!
response = chain.invoke({"input": "What's my name?"})
print(response['response'])  # "Alice"

Features

  • 💾 Persistent Memory - Survives restarts
  • 🔗 LangChain Compatible - Drop-in replacement
  • 🚀 Easy Setup - 3 lines of code
  • 🔒 Session Isolation - Multi-user support
  • Production Ready - Tested and reliable

API

AlchemystMemory

memory = AlchemystMemory(
    api_key="your-key",      # Alchemyst AI API key
    session_id="user-123"    # Unique session identifier
)

Methods:

  • save_context(inputs, outputs) - Save conversation
  • load_memory_variables(inputs) - Load history
  • clear() - Clear session memory

Examples

Basic Usage

memory = AlchemystMemory(
    api_key="your-key",
    session_id="session-1"
)

chain = ConversationChain(llm=llm, memory=memory)
chain.invoke({"input": "Hello!"})

Multi-User Support

# Different users, different sessions
alice_memory = AlchemystMemory(api_key=key, session_id="alice")
bob_memory = AlchemystMemory(api_key=key, session_id="bob")

Clear Memory

# Delete session data
memory.clear()

Environment Setup

Create .env file:

ALCHEMYST_AI_API_KEY=your_api_key_here
OPENAI_API_KEY=your_openai_key_here

Development

# Install
pip install -e ".[dev]"

# Run tests
pytest

# Build
python -m build

Get API Key

Sign up at getalchemystai.com


Links


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

alchemyst_langchain-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

alchemyst_langchain-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for alchemyst_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dba32e2707036e46a68948afaf29cd19ba0755bdf913f32d05311c77ebbad023
MD5 71563fbcd71637bfffadfd6662093253
BLAKE2b-256 2585d54a1e09b1b2022d0ebd3fa995312a8ad19448011db3b5d174789702297b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alchemyst_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7beda78fe73be8c3b0941c4fa06327efdc0b72682faeb9bd49fde6be5c728ae0
MD5 78582c8804e471126e635d6f2a12e91c
BLAKE2b-256 68e15791d50ed46f36d1d1ecdcff7f9199d41018b4109ff3a9b5fe670696580e

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