Autogen integration for Zep
Project description
Zep AutoGen Integration
A comprehensive integration package that enables Zep to work seamlessly with Microsoft AutoGen agents, providing persistent conversation memory, knowledge graphs, and intelligent tool usage.
Installation
pip install zep-autogen
Quick Start
Basic Memory Integration
import asyncio
from zep_cloud.client import AsyncZep
from zep_autogen import ZepUserMemory
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main():
# Initialize Zep client
zep_client = AsyncZep(api_key="your-zep-api-key")
# Create Zep memory for your agent
memory = ZepUserMemory(
client=zep_client,
user_id="user_123",
thread_id="conversation_456"
)
# Create AutoGen agent with Zep memory
agent = AssistantAgent(
name="MemoryAwareAssistant",
model_client=OpenAIChatCompletionClient(model="gpt-4.1-mini"),
memory=[memory] # Add Zep memory to the agent
)
# Your agent now has persistent memory across conversations!
response = await agent.run(task="What's my name again?")
print(response.messages[-1].content)
asyncio.run(main())
Tool-Equipped Agents
import asyncio
from zep_cloud.client import AsyncZep
from zep_autogen import create_search_graph_tool, create_add_graph_data_tool
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main():
# Initialize Zep client
zep_client = AsyncZep(api_key="your-zep-api-key")
# Create tools bound to your graph
search_tool = create_search_graph_tool(zep_client, graph_id="my_knowledge_base")
add_tool = create_add_graph_data_tool(zep_client, graph_id="my_knowledge_base")
# Create agent with tools and reflection
agent = AssistantAgent(
name="KnowledgeAssistant",
model_client=OpenAIChatCompletionClient(model="gpt-4o-mini"),
tools=[search_tool, add_tool],
system_message="You can search and add information to knowledge bases.",
reflect_on_tool_use=True, # Enables natural language responses
)
# Agent can autonomously use tools and provide natural responses
await Console(agent.run_stream(task="Add this fact: Python is great for AI development"))
await Console(agent.run_stream(task="What do you know about Python?"))
asyncio.run(main())
Features
- Persistent Memory: Conversations and knowledge persist across agent sessions
- Graph Memory: Store and retrieve structured knowledge using Zep's graph capabilities
- Tool Integration: Pre-built AutoGen tools for search and data operations
- Intelligent Retrieval: Zep's memory automatically provides relevant context
- AutoGen Compatible: Seamlessly integrates with AutoGen's memory and tool interfaces
- Natural Language Tool Use: Agents process tool results and provide conversational responses
- Async Support: Full async/await support for modern applications
- Type Safety: Fully typed with comprehensive type hints
Configuration
Environment Variables
# Required: Your Zep Cloud API key
export ZEP_API_KEY="your-zep-api-key"
Memory Classes
ZepUserMemory
For conversational memory that persists across threads:
client(AsyncZep): Your Zep client instanceuser_id(str): Unique identifier for the userthread_id(str, optional): Thread/conversation identifier
ZepGraphMemory
For knowledge graph storage and retrieval:
client(AsyncZep): Your Zep client instancegraph_id(str): Identifier for the knowledge graph
Tool Functions
create_search_graph_tool
Creates a search tool bound to a graph or user:
client(AsyncZep): Your Zep client instancegraph_id(str, optional): Graph to search (for general knowledge graphs)user_id(str, optional): User to search (for user knowledge graphs)
create_add_graph_data_tool
Creates a data addition tool bound to a graph or user:
client(AsyncZep): Your Zep client instancegraph_id(str, optional): Graph to add data touser_id(str, optional): User to add data for
Examples
Memory Integration
- Basic Memory: User memory with conversation persistence
- Graph Memory: Knowledge graphs with ontology definitions
Tool Integration
- Search Tools: Agents with search-only capabilities
- Full Tools: Agents that can both search and add data
Multi-Agent with Shared Memory
# Multiple agents can share the same memory context
shared_memory = ZepUserMemory(
client=zep_client,
user_id="team_project",
thread_id="brainstorm_session"
)
researcher = AssistantAgent(
name="Researcher",
model_client=model_client,
memory=[shared_memory]
)
writer = AssistantAgent(
name="Writer",
model_client=model_client,
memory=[shared_memory]
)
Advanced Usage
Graph Memory with Ontology
Define structured entities for better knowledge organization:
from zep_cloud.external_clients.ontology import EntityModel, EntityText
from pydantic import Field
class ProgrammingLanguage(EntityModel):
paradigm: EntityText = Field(description="programming paradigm")
use_case: EntityText = Field(description="primary use cases")
# Set graph ontology
await zep_client.graph.set_ontology(
entities={"ProgrammingLanguage": ProgrammingLanguage},
edges={}
)
# Use graph memory with ontology
memory = ZepGraphMemory(
client=zep_client,
graph_id="tech_knowledge",
search_filters=SearchFilters(
node_labels=["ProgrammingLanguage"],
),
)
Tool Usage
agent = AssistantAgent(
name="Assistant",
model_client=model_client,
tools=[search_tool],
reflect_on_tool_use=True,
)
# Use streaming console for tool visualization
await Console(agent.run_stream(task="Search for Python information"))
Development
Setup
# Install development dependencies
make install
# Run pre-commit checks (format, lint, type-check, test)
make pre-commit
Available Commands
make format- Format code with ruffmake lint- Run linting checksmake type-check- Run type checking with mypymake test- Run testsmake all- Run all checks
Requirements
- Python 3.10+
zep-cloud>=3.2.0autogen-agentchat>=0.6.1autogen-ext[azure,openai]>=0.6.1
License
MIT License - see LICENSE for details.
Support
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
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
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 zep_autogen-1.1.0.tar.gz.
File metadata
- Download URL: zep_autogen-1.1.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
657fab8c94d1ece78b27d5a5a4ae398ebe749e686c15c4f7ce79cbf82113a98b
|
|
| MD5 |
a682e7d07a804f269feecb884a937d95
|
|
| BLAKE2b-256 |
718a22a09e106ee9816198247f8a587403424b6801e1296fc2de90b431d8778f
|
Provenance
The following attestation bundles were made for zep_autogen-1.1.0.tar.gz:
Publisher:
release-integrations.yml on getzep/zep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zep_autogen-1.1.0.tar.gz -
Subject digest:
657fab8c94d1ece78b27d5a5a4ae398ebe749e686c15c4f7ce79cbf82113a98b - Sigstore transparency entry: 383044733
- Sigstore integration time:
-
Permalink:
getzep/zep@811d285fa8788a59518b56a57a6a922d9e394c0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/getzep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integrations.yml@811d285fa8788a59518b56a57a6a922d9e394c0b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zep_autogen-1.1.0-py3-none-any.whl.
File metadata
- Download URL: zep_autogen-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10f211507f2e20a62de078e554771f26dc1cf2b6f9d42b54ff1ccb37e4bb9714
|
|
| MD5 |
a85ee698407264be56b65bf66aabca2f
|
|
| BLAKE2b-256 |
99bd7b1700528420b468bbcd45e50041bdd067f5887ace8f3acf608c863846f6
|
Provenance
The following attestation bundles were made for zep_autogen-1.1.0-py3-none-any.whl:
Publisher:
release-integrations.yml on getzep/zep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zep_autogen-1.1.0-py3-none-any.whl -
Subject digest:
10f211507f2e20a62de078e554771f26dc1cf2b6f9d42b54ff1ccb37e4bb9714 - Sigstore transparency entry: 383044759
- Sigstore integration time:
-
Permalink:
getzep/zep@811d285fa8788a59518b56a57a6a922d9e394c0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/getzep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integrations.yml@811d285fa8788a59518b56a57a6a922d9e394c0b -
Trigger Event:
workflow_dispatch
-
Statement type: