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 conversationload_memory_variables(inputs)- Load historyclear()- 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
- Documentation: https://getalchemystai.com/docs
- GitHub: https://github.com/Alchemyst-ai/alchemyst-langchain
- PyPI: https://pypi.org/project/alchemyst-langchain
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dba32e2707036e46a68948afaf29cd19ba0755bdf913f32d05311c77ebbad023
|
|
| MD5 |
71563fbcd71637bfffadfd6662093253
|
|
| BLAKE2b-256 |
2585d54a1e09b1b2022d0ebd3fa995312a8ad19448011db3b5d174789702297b
|
File details
Details for the file alchemyst_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alchemyst_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7beda78fe73be8c3b0941c4fa06327efdc0b72682faeb9bd49fde6be5c728ae0
|
|
| MD5 |
78582c8804e471126e635d6f2a12e91c
|
|
| BLAKE2b-256 |
68e15791d50ed46f36d1d1ecdcff7f9199d41018b4109ff3a9b5fe670696580e
|