zep-crewai 0.1.0__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zep_crewai/__init__.py +42 -18
- zep_crewai/graph_storage.py +147 -0
- zep_crewai/tools.py +318 -0
- zep_crewai/user_storage.py +208 -0
- zep_crewai/utils.py +139 -0
- zep_crewai-1.0.0.dist-info/METADATA +404 -0
- zep_crewai-1.0.0.dist-info/RECORD +10 -0
- zep_crewai-0.1.0.dist-info/METADATA +0 -186
- zep_crewai-0.1.0.dist-info/RECORD +0 -6
- {zep_crewai-0.1.0.dist-info → zep_crewai-1.0.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,404 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: zep-crewai
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: CrewAI integration for Zep
|
5
|
+
Project-URL: Homepage, https://github.com/getzep/zep
|
6
|
+
Project-URL: Documentation, https://help.getzep.com
|
7
|
+
Project-URL: Repository, https://github.com/getzep/zep
|
8
|
+
Project-URL: Bug Tracker, https://github.com/getzep/zep/issues
|
9
|
+
Requires-Python: >=3.10
|
10
|
+
Requires-Dist: aiohttp>=3.8.0
|
11
|
+
Requires-Dist: crewai>=0.80.0
|
12
|
+
Requires-Dist: python-dotenv>=1.0.0
|
13
|
+
Requires-Dist: python-slugify>=8.0.4
|
14
|
+
Requires-Dist: rich>=14.0.0
|
15
|
+
Requires-Dist: zep-cloud>=3.4.1
|
16
|
+
Provides-Extra: dev
|
17
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
18
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
19
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
20
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
21
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
22
|
+
Description-Content-Type: text/markdown
|
23
|
+
|
24
|
+
# Zep CrewAI Integration
|
25
|
+
|
26
|
+
A comprehensive integration package that enables [CrewAI](https://github.com/joaomdmoura/crewai) agents to leverage [Zep](https://getzep.com)'s powerful memory platform for persistent storage, knowledge graphs, and intelligent tool usage.
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
```bash
|
31
|
+
pip install zep-crewai
|
32
|
+
```
|
33
|
+
|
34
|
+
## Quick Start
|
35
|
+
|
36
|
+
### User Storage with Conversation Memory
|
37
|
+
|
38
|
+
```python
|
39
|
+
import os
|
40
|
+
from zep_cloud.client import Zep
|
41
|
+
from zep_crewai import ZepUserStorage
|
42
|
+
from crewai import Agent, Crew, Task
|
43
|
+
from crewai.memory.external.external_memory import ExternalMemory
|
44
|
+
|
45
|
+
# Initialize Zep client
|
46
|
+
zep_client = Zep(api_key=os.getenv("ZEP_API_KEY"))
|
47
|
+
|
48
|
+
# Create user and thread
|
49
|
+
zep_client.user.add(user_id="alice_123", first_name="Alice")
|
50
|
+
zep_client.thread.create(user_id="alice_123", thread_id="project_456")
|
51
|
+
|
52
|
+
# Create user storage
|
53
|
+
user_storage = ZepUserStorage(
|
54
|
+
client=zep_client,
|
55
|
+
user_id="alice_123",
|
56
|
+
thread_id="project_456", # Optional: for conversation context
|
57
|
+
mode="summary" # "summary" or "raw_messages" for thread context
|
58
|
+
)
|
59
|
+
|
60
|
+
# Create crew with user memory
|
61
|
+
crew = Crew(
|
62
|
+
agents=[...],
|
63
|
+
tasks=[...],
|
64
|
+
external_memory=ExternalMemory(storage=user_storage)
|
65
|
+
)
|
66
|
+
```
|
67
|
+
|
68
|
+
### Knowledge Graph Storage
|
69
|
+
|
70
|
+
```python
|
71
|
+
from zep_crewai import ZepGraphStorage
|
72
|
+
|
73
|
+
# Create graph storage for shared knowledge
|
74
|
+
graph_storage = ZepGraphStorage(
|
75
|
+
client=zep_client,
|
76
|
+
graph_id="company_knowledge",
|
77
|
+
search_filters={"node_labels": ["Technology", "Project"]}
|
78
|
+
)
|
79
|
+
|
80
|
+
# Create crew with graph memory
|
81
|
+
crew = Crew(
|
82
|
+
agents=[...],
|
83
|
+
tasks=[...],
|
84
|
+
external_memory=ExternalMemory(storage=graph_storage)
|
85
|
+
)
|
86
|
+
```
|
87
|
+
|
88
|
+
### Tool-Equipped Agents
|
89
|
+
|
90
|
+
```python
|
91
|
+
from zep_crewai import create_search_tool, create_add_data_tool
|
92
|
+
|
93
|
+
# Create tools for user or graph
|
94
|
+
search_tool = create_search_tool(zep_client, user_id="alice_123")
|
95
|
+
add_tool = create_add_data_tool(zep_client, graph_id="knowledge_base")
|
96
|
+
|
97
|
+
# Create agent with Zep tools
|
98
|
+
agent = Agent(
|
99
|
+
role="Knowledge Assistant",
|
100
|
+
goal="Manage and retrieve information efficiently",
|
101
|
+
tools=[search_tool, add_tool],
|
102
|
+
llm="gpt-4o-mini"
|
103
|
+
)
|
104
|
+
```
|
105
|
+
|
106
|
+
## Features
|
107
|
+
|
108
|
+
### Storage Classes
|
109
|
+
|
110
|
+
#### ZepUserStorage
|
111
|
+
Manages user-specific memories and conversations:
|
112
|
+
- **Thread Messages**: Conversation history with role-based storage
|
113
|
+
- **User Graph**: Personal knowledge, preferences, and context
|
114
|
+
- **Parallel Search**: Simultaneous search across threads and graphs
|
115
|
+
- **Search Filters**: Target specific node types and relationships
|
116
|
+
- **Thread Context**: Uses `thread.get_user_context` with configurable mode (summary/raw_messages)
|
117
|
+
|
118
|
+
#### ZepGraphStorage
|
119
|
+
Manages generic knowledge graphs for shared information:
|
120
|
+
- **Structured Knowledge**: Store entities with defined ontologies
|
121
|
+
- **Multi-scope Search**: Search edges (facts), nodes (entities), and episodes
|
122
|
+
- **Search Filters**: Filter by node labels and attributes
|
123
|
+
- **Persistent Storage**: Knowledge persists across sessions
|
124
|
+
- **Context Composition**: Uses `compose_context_string` for formatted context
|
125
|
+
|
126
|
+
### Tool Integration
|
127
|
+
|
128
|
+
#### Search Tool
|
129
|
+
```python
|
130
|
+
search_tool = create_search_tool(
|
131
|
+
zep_client,
|
132
|
+
user_id="user_123" # OR graph_id="knowledge_base"
|
133
|
+
)
|
134
|
+
```
|
135
|
+
- Search across edges, nodes, and episodes
|
136
|
+
- Configurable result limits
|
137
|
+
- Scope filtering (edges, nodes, episodes, or all)
|
138
|
+
- Natural language queries
|
139
|
+
|
140
|
+
#### Add Data Tool
|
141
|
+
```python
|
142
|
+
add_tool = create_add_data_tool(
|
143
|
+
zep_client,
|
144
|
+
graph_id="knowledge_base" # OR user_id="user_123"
|
145
|
+
)
|
146
|
+
```
|
147
|
+
- Add text, JSON, or message data
|
148
|
+
- Automatic type detection
|
149
|
+
- Structured data support
|
150
|
+
- Metadata preservation
|
151
|
+
|
152
|
+
## Advanced Usage
|
153
|
+
|
154
|
+
### Graph Storage with Ontology
|
155
|
+
|
156
|
+
Define structured entities for better organization:
|
157
|
+
|
158
|
+
```python
|
159
|
+
from zep_cloud.external_clients.ontology import EntityModel, EntityText
|
160
|
+
from pydantic import Field
|
161
|
+
|
162
|
+
class ProjectEntity(EntityModel):
|
163
|
+
status: EntityText = Field(description="project status")
|
164
|
+
priority: EntityText = Field(description="priority level")
|
165
|
+
team_size: EntityText = Field(description="team size")
|
166
|
+
|
167
|
+
# Set ontology
|
168
|
+
zep_client.graph.set_ontology(
|
169
|
+
graph_id="projects",
|
170
|
+
entities={"Project": ProjectEntity},
|
171
|
+
edges={}
|
172
|
+
)
|
173
|
+
|
174
|
+
# Use with filtered search and context limits
|
175
|
+
graph_storage = ZepGraphStorage(
|
176
|
+
client=zep_client,
|
177
|
+
graph_id="projects",
|
178
|
+
search_filters={"node_labels": ["Project"]},
|
179
|
+
facts_limit=20, # Max facts for context
|
180
|
+
entity_limit=5 # Max entities for context
|
181
|
+
)
|
182
|
+
|
183
|
+
# Get formatted context
|
184
|
+
context = graph_storage.get_context("project status")
|
185
|
+
print(context) # Formatted string with facts and entities
|
186
|
+
```
|
187
|
+
|
188
|
+
### Multi-Agent with Mixed Storage
|
189
|
+
|
190
|
+
```python
|
191
|
+
# User-specific storage for personal agent
|
192
|
+
personal_storage = ZepUserStorage(
|
193
|
+
client=zep_client,
|
194
|
+
user_id="user_123",
|
195
|
+
thread_id="thread_456",
|
196
|
+
facts_limit=20, # Max facts for context
|
197
|
+
entity_limit=5, # Max entities for context
|
198
|
+
mode="summary" # Or "raw_messages" for full conversation history
|
199
|
+
)
|
200
|
+
|
201
|
+
# Get formatted context from thread
|
202
|
+
context = personal_storage.get_context()
|
203
|
+
print(context) # Thread context based on configured mode
|
204
|
+
|
205
|
+
# Shared knowledge graph for team agent
|
206
|
+
team_storage = ZepGraphStorage(
|
207
|
+
client=zep_client,
|
208
|
+
graph_id="team_knowledge"
|
209
|
+
)
|
210
|
+
|
211
|
+
# Create agents with different storage
|
212
|
+
personal_agent = Agent(
|
213
|
+
name="Personal Assistant",
|
214
|
+
tools=[create_search_tool(zep_client, user_id="user_123")]
|
215
|
+
)
|
216
|
+
|
217
|
+
team_agent = Agent(
|
218
|
+
name="Team Coordinator",
|
219
|
+
tools=[create_search_tool(zep_client, graph_id="team_knowledge")]
|
220
|
+
)
|
221
|
+
```
|
222
|
+
|
223
|
+
### Storage Routing
|
224
|
+
|
225
|
+
Different data types are automatically routed:
|
226
|
+
|
227
|
+
```python
|
228
|
+
# Messages go to thread (if thread_id is set)
|
229
|
+
external_memory.save(
|
230
|
+
"How can I help you today?",
|
231
|
+
metadata={"type": "message", "role": "assistant", "name": "Helper"}
|
232
|
+
)
|
233
|
+
|
234
|
+
# JSON data goes to graph
|
235
|
+
external_memory.save(
|
236
|
+
'{"project": "Alpha", "status": "active", "budget": 50000}',
|
237
|
+
metadata={"type": "json"}
|
238
|
+
)
|
239
|
+
|
240
|
+
# Text data goes to graph
|
241
|
+
external_memory.save(
|
242
|
+
"Project Alpha requires Python and React expertise",
|
243
|
+
metadata={"type": "text"}
|
244
|
+
)
|
245
|
+
```
|
246
|
+
|
247
|
+
## Examples
|
248
|
+
|
249
|
+
### Complete Examples
|
250
|
+
|
251
|
+
- **[User Storage](examples/crewai_user.py)**: Personal assistant with conversation memory
|
252
|
+
- **[Graph Storage](examples/crewai_graph.py)**: Knowledge graph with ontology
|
253
|
+
- **[Tools Usage](examples/crewai_tools.py)**: Agents using search and add tools
|
254
|
+
- **[Simple Example](examples/simple_example.py)**: Basic setup and usage
|
255
|
+
|
256
|
+
### Common Patterns
|
257
|
+
|
258
|
+
#### Personal Assistant
|
259
|
+
```python
|
260
|
+
# Store user preferences and context
|
261
|
+
user_storage = ZepUserStorage(client=zep_client, user_id="user_123")
|
262
|
+
external_memory = ExternalMemory(storage=user_storage)
|
263
|
+
|
264
|
+
# Agent automatically retrieves relevant context
|
265
|
+
personal_assistant = Agent(
|
266
|
+
role="Personal Assistant",
|
267
|
+
backstory="You know the user's preferences and history"
|
268
|
+
)
|
269
|
+
```
|
270
|
+
|
271
|
+
#### Knowledge Base Management
|
272
|
+
```python
|
273
|
+
# Shared knowledge with search tools
|
274
|
+
knowledge_tools = [
|
275
|
+
create_search_tool(zep_client, graph_id="knowledge"),
|
276
|
+
create_add_data_tool(zep_client, graph_id="knowledge")
|
277
|
+
]
|
278
|
+
|
279
|
+
curator = Agent(
|
280
|
+
role="Knowledge Curator",
|
281
|
+
tools=knowledge_tools,
|
282
|
+
backstory="You maintain the organization's knowledge base"
|
283
|
+
)
|
284
|
+
```
|
285
|
+
|
286
|
+
#### Multi-Modal Memory
|
287
|
+
```python
|
288
|
+
# Combine user and graph storage with tools
|
289
|
+
research_agent = Agent(
|
290
|
+
role="Research Analyst",
|
291
|
+
tools=[
|
292
|
+
create_search_tool(zep_client, user_id="user_123"),
|
293
|
+
create_search_tool(zep_client, graph_id="research_data")
|
294
|
+
],
|
295
|
+
backstory="You analyze both personal and organizational data"
|
296
|
+
)
|
297
|
+
```
|
298
|
+
|
299
|
+
## Configuration
|
300
|
+
|
301
|
+
### Environment Variables
|
302
|
+
|
303
|
+
```bash
|
304
|
+
# Required: Your Zep Cloud API key
|
305
|
+
export ZEP_API_KEY="your-zep-api-key"
|
306
|
+
```
|
307
|
+
|
308
|
+
### Storage Parameters
|
309
|
+
|
310
|
+
#### ZepUserStorage
|
311
|
+
- `client`: Zep client instance (required)
|
312
|
+
- `user_id`: User identifier (required)
|
313
|
+
- `thread_id`: Thread identifier (optional)
|
314
|
+
- `search_filters`: Search filters (optional)
|
315
|
+
- `facts_limit`: Maximum facts for context (default: 20)
|
316
|
+
- `entity_limit`: Maximum entities for context (default: 5)
|
317
|
+
- `mode`: Context retrieval mode - "summary" or "raw_messages" (default: "summary")
|
318
|
+
|
319
|
+
#### ZepGraphStorage
|
320
|
+
- `client`: Zep client instance (required)
|
321
|
+
- `graph_id`: Graph identifier (required)
|
322
|
+
- `search_filters`: Search filters (optional)
|
323
|
+
- `facts_limit`: Maximum facts for context (default: 20)
|
324
|
+
- `entity_limit`: Maximum entities for context (default: 5)
|
325
|
+
|
326
|
+
### Tool Parameters
|
327
|
+
|
328
|
+
#### Search Tool
|
329
|
+
- `query`: Search query string
|
330
|
+
- `limit`: Maximum results (default: 10)
|
331
|
+
- `scope`: Search scope - "edges", "nodes", "episodes", or "all"
|
332
|
+
|
333
|
+
#### Add Data Tool
|
334
|
+
- `data`: Content to store
|
335
|
+
- `data_type`: Type - "text", "json", or "message"
|
336
|
+
|
337
|
+
## Development
|
338
|
+
|
339
|
+
### Setup
|
340
|
+
```bash
|
341
|
+
# Clone the repository
|
342
|
+
git clone https://github.com/getzep/zep.git
|
343
|
+
cd integrations/python/zep_crewai
|
344
|
+
|
345
|
+
# Install dependencies
|
346
|
+
pip install -e .
|
347
|
+
pip install -r requirements-dev.txt
|
348
|
+
```
|
349
|
+
|
350
|
+
### Testing
|
351
|
+
```bash
|
352
|
+
# Run tests
|
353
|
+
pytest tests/
|
354
|
+
|
355
|
+
# Run with coverage
|
356
|
+
pytest --cov=zep_crewai tests/
|
357
|
+
```
|
358
|
+
|
359
|
+
### Type Checking
|
360
|
+
```bash
|
361
|
+
mypy src/zep_crewai
|
362
|
+
```
|
363
|
+
|
364
|
+
## Requirements
|
365
|
+
|
366
|
+
- Python 3.10+
|
367
|
+
- `zep-cloud>=3.0.0`
|
368
|
+
- `crewai>=0.80.0`
|
369
|
+
- `pydantic>=2.0.0`
|
370
|
+
|
371
|
+
## Best Practices
|
372
|
+
|
373
|
+
1. **Storage Selection**
|
374
|
+
- Use `ZepUserStorage` for user-specific, personal data
|
375
|
+
- Use `ZepGraphStorage` for shared, organizational knowledge
|
376
|
+
|
377
|
+
2. **Tool Usage**
|
378
|
+
- Bind tools to specific users or graphs at creation
|
379
|
+
- Use search scope "all" sparingly (more expensive)
|
380
|
+
- Add data with appropriate types for better organization
|
381
|
+
|
382
|
+
3. **Memory Management**
|
383
|
+
- Set up ontologies for structured data
|
384
|
+
- Use search filters to improve relevance
|
385
|
+
- Combine storage types for comprehensive memory
|
386
|
+
|
387
|
+
4. **Performance**
|
388
|
+
- Allow 10-20 seconds for data processing after additions
|
389
|
+
- Use parallel search for better performance
|
390
|
+
- Limit search results appropriately
|
391
|
+
|
392
|
+
## Support
|
393
|
+
|
394
|
+
- [Zep Documentation](https://help.getzep.com)
|
395
|
+
- [CrewAI Documentation](https://docs.crewai.com)
|
396
|
+
- [GitHub Issues](https://github.com/getzep/zep/issues)
|
397
|
+
|
398
|
+
## License
|
399
|
+
|
400
|
+
Apache 2.0 - see [LICENSE](LICENSE) for details.
|
401
|
+
|
402
|
+
## Contributing
|
403
|
+
|
404
|
+
Contributions are welcome! Please see our [Contributing Guide](../../../CONTRIBUTING.md) for details.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
zep_crewai/__init__.py,sha256=Cv-cAbPf7VDS4iQGXQsgN0LVrVotBlwfmVfJ4P-qUkk,1958
|
2
|
+
zep_crewai/exceptions.py,sha256=buRZJt5TDankN7PvLq_u0wDlQ0Sp6LKXroS1qTj6koY,403
|
3
|
+
zep_crewai/graph_storage.py,sha256=HhrM7GyYbXeKMtbtFy-X-OIMNlXprB7t3uik9uqsdJ4,4797
|
4
|
+
zep_crewai/memory.py,sha256=lhoOsmJK6Yfe9OULt7OQ98Rk963pCY9_HGbHTnA22u8,6082
|
5
|
+
zep_crewai/tools.py,sha256=S0Pk5UZMkajX3QebU-kKfAz2bkyAjiUjBOijUC3Jlbk,10649
|
6
|
+
zep_crewai/user_storage.py,sha256=YXh8TGafNj7Sjvyp5HRsUDOkLqkh88RVyGd54IsZ_Nw,6882
|
7
|
+
zep_crewai/utils.py,sha256=Xu0aRNMYbhHz1a8H93E4uhhDyWI51zEbPBobb7mc3BM,4550
|
8
|
+
zep_crewai-1.0.0.dist-info/METADATA,sha256=Fg-GRZRx0Wv3EHKylql9s8r_ircfEbqax55GqcheBec,10846
|
9
|
+
zep_crewai-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
zep_crewai-1.0.0.dist-info/RECORD,,
|
@@ -1,186 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: zep-crewai
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: CrewAI integration for Zep
|
5
|
-
Project-URL: Homepage, https://github.com/getzep/zep
|
6
|
-
Project-URL: Documentation, https://help.getzep.com
|
7
|
-
Project-URL: Repository, https://github.com/getzep/zep
|
8
|
-
Project-URL: Bug Tracker, https://github.com/getzep/zep/issues
|
9
|
-
Requires-Python: >=3.10
|
10
|
-
Requires-Dist: aiohttp>=3.8.0
|
11
|
-
Requires-Dist: crewai>=0.80.0
|
12
|
-
Requires-Dist: python-dotenv>=1.0.0
|
13
|
-
Requires-Dist: python-slugify>=8.0.4
|
14
|
-
Requires-Dist: rich>=14.0.0
|
15
|
-
Requires-Dist: zep-cloud>=3.0.0rc1
|
16
|
-
Provides-Extra: dev
|
17
|
-
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
18
|
-
Requires-Dist: pytest-asyncio; extra == 'dev'
|
19
|
-
Requires-Dist: pytest-cov; extra == 'dev'
|
20
|
-
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
21
|
-
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
22
|
-
Description-Content-Type: text/markdown
|
23
|
-
|
24
|
-
# Zep CrewAI Integration Tutorial
|
25
|
-
|
26
|
-
Learn how to add persistent memory to your CrewAI agents using Zep's powerful memory platform.
|
27
|
-
|
28
|
-
## Installation
|
29
|
-
|
30
|
-
Install the Zep CrewAI integration package:
|
31
|
-
|
32
|
-
```bash
|
33
|
-
pip install zep-crewai
|
34
|
-
```
|
35
|
-
|
36
|
-
## Setup
|
37
|
-
|
38
|
-
### 1. Get Your API Key
|
39
|
-
|
40
|
-
Sign up at [Zep Cloud](https://app.getzep.com) and get your API key.
|
41
|
-
|
42
|
-
### 2. Set Environment Variable
|
43
|
-
|
44
|
-
```bash
|
45
|
-
export ZEP_API_KEY="your-zep-api-key"
|
46
|
-
```
|
47
|
-
|
48
|
-
## Basic Usage
|
49
|
-
|
50
|
-
### 1. Initialize Zep Client
|
51
|
-
|
52
|
-
```python
|
53
|
-
import os
|
54
|
-
from zep_cloud.client import Zep
|
55
|
-
|
56
|
-
# Initialize Zep client
|
57
|
-
zep_client = Zep(api_key=os.getenv("ZEP_API_KEY"))
|
58
|
-
```
|
59
|
-
|
60
|
-
### 2. Create User and Thread
|
61
|
-
|
62
|
-
**Important**: You must create a user and thread in Zep before using ZepStorage.
|
63
|
-
|
64
|
-
```python
|
65
|
-
# Create a user
|
66
|
-
user_id = "john_doe_123"
|
67
|
-
zep_client.user.add(
|
68
|
-
user_id=user_id,
|
69
|
-
first_name="John",
|
70
|
-
last_name="Doe",
|
71
|
-
email="john.doe@example.com"
|
72
|
-
)
|
73
|
-
|
74
|
-
# Create a thread
|
75
|
-
thread_id = "project_alpha_456"
|
76
|
-
zep_client.thread.create(
|
77
|
-
user_id=user_id,
|
78
|
-
thread_id=thread_id
|
79
|
-
)
|
80
|
-
```
|
81
|
-
|
82
|
-
### 3. Initialize ZepStorage
|
83
|
-
|
84
|
-
```python
|
85
|
-
from zep_crewai import ZepStorage
|
86
|
-
from crewai.memory.external.external_memory import ExternalMemory
|
87
|
-
|
88
|
-
# Create storage for your project
|
89
|
-
zep_storage = ZepStorage(
|
90
|
-
client=zep_client,
|
91
|
-
user_id=user_id,
|
92
|
-
thread_id=thread_id
|
93
|
-
)
|
94
|
-
|
95
|
-
# Wrap in CrewAI's external memory
|
96
|
-
external_memory = ExternalMemory(storage=zep_storage)
|
97
|
-
```
|
98
|
-
|
99
|
-
### 4. Create Crew with Persistent Memory
|
100
|
-
|
101
|
-
```python
|
102
|
-
from crewai import Agent, Crew, Task, Process
|
103
|
-
|
104
|
-
# Create your agents
|
105
|
-
research_agent = Agent(
|
106
|
-
role='Research Analyst',
|
107
|
-
goal='Analyze market trends and provide insights',
|
108
|
-
backstory='You are an expert at finding and analyzing market data...',
|
109
|
-
)
|
110
|
-
|
111
|
-
# Create crew with Zep memory
|
112
|
-
crew = Crew(
|
113
|
-
agents=[research_agent],
|
114
|
-
tasks=[...],
|
115
|
-
external_memory=external_memory, # This enables the crew to search Zep
|
116
|
-
process=Process.sequential,
|
117
|
-
)
|
118
|
-
|
119
|
-
# Run your crew - memories will be automatically saved and retrieved
|
120
|
-
result = crew.kickoff()
|
121
|
-
```
|
122
|
-
|
123
|
-
## How Memory Works
|
124
|
-
|
125
|
-
Zep stores different types of content using metadata-based routing.
|
126
|
-
|
127
|
-
### Messages (Conversation Context)
|
128
|
-
Stored in Zep threads for conversation history:
|
129
|
-
|
130
|
-
```python
|
131
|
-
external_memory.save(
|
132
|
-
"I need help planning a business trip to New York",
|
133
|
-
metadata={"type": "message", "role": "user", "name": "John Doe"}
|
134
|
-
)
|
135
|
-
|
136
|
-
external_memory.save(
|
137
|
-
"I'd be happy to help you plan your trip!",
|
138
|
-
metadata={"type": "message", "role": "assistant", "name": "Travel Agent"}
|
139
|
-
)
|
140
|
-
```
|
141
|
-
|
142
|
-
### Structured Data
|
143
|
-
Added as episodes to the user knowledge graph in Zep:
|
144
|
-
|
145
|
-
```python
|
146
|
-
# JSON data
|
147
|
-
external_memory.save(
|
148
|
-
'{"destination": "New York", "duration": "3 days", "budget": 2000}',
|
149
|
-
metadata={"type": "json"}
|
150
|
-
)
|
151
|
-
|
152
|
-
# Text facts and insights
|
153
|
-
external_memory.save(
|
154
|
-
"User prefers mid-range hotels with business amenities",
|
155
|
-
metadata={"type": "text"}
|
156
|
-
)
|
157
|
-
```
|
158
|
-
|
159
|
-
### Automatic Memory Retrieval
|
160
|
-
|
161
|
-
CrewAI automatically searches your memories when agents need context:
|
162
|
-
|
163
|
-
```python
|
164
|
-
# When agents run, they automatically get relevant context from Zep
|
165
|
-
results = crew.kickoff()
|
166
|
-
|
167
|
-
# You can also search manually
|
168
|
-
memory_results = zep_storage.search("hotel preferences", limit=5)
|
169
|
-
for result in memory_results:
|
170
|
-
print(result['memory'])
|
171
|
-
```
|
172
|
-
|
173
|
-
## Complete Example
|
174
|
-
|
175
|
-
For a full working example, check out [`examples/simple_example.py`](examples/simple_example.py) in this repository. This example demonstrates:
|
176
|
-
|
177
|
-
- Setting up Zep user and thread
|
178
|
-
- Saving different types of memory (messages, JSON data, text)
|
179
|
-
- Creating CrewAI agents with access to Zep memory
|
180
|
-
- Automatic context retrieval during agent execution
|
181
|
-
|
182
|
-
## Requirements
|
183
|
-
|
184
|
-
- Python 3.10+
|
185
|
-
- `zep-cloud>=3.0.0rc1`
|
186
|
-
- `crewai>=0.80.0`
|
@@ -1,6 +0,0 @@
|
|
1
|
-
zep_crewai/__init__.py,sha256=H8xpqfQd79JPRbd7h9wHjgSbsKrQGiTDV_CePgeo_cQ,1280
|
2
|
-
zep_crewai/exceptions.py,sha256=buRZJt5TDankN7PvLq_u0wDlQ0Sp6LKXroS1qTj6koY,403
|
3
|
-
zep_crewai/memory.py,sha256=lhoOsmJK6Yfe9OULt7OQ98Rk963pCY9_HGbHTnA22u8,6082
|
4
|
-
zep_crewai-0.1.0.dist-info/METADATA,sha256=panKSkdvw1uRiGebFgNZ8lfL_xQaPd_L5mSH6bDku-8,4470
|
5
|
-
zep_crewai-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
zep_crewai-0.1.0.dist-info/RECORD,,
|
File without changes
|