Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4c78cf9
add mem0 memory implementation
alpha-xone May 11, 2025
41fd2aa
remove secrets
alpha-xone May 11, 2025
42f82af
Merge branch 'main' into mem0-memory
alpha-xone May 11, 2025
64f9005
add documentation
alpha-xone May 12, 2025
63aa592
fix load_component
alpha-xone May 12, 2025
343d363
fix demo
alpha-xone May 12, 2025
455d4ab
Merge branch 'main' into mem0-memory
victordibia May 12, 2025
b360f78
Merge branch 'main' into mem0-memory
ekzhu May 13, 2025
042ccf4
add unitest
alpha-xone May 13, 2025
b55669a
Merge branch 'mem0-memory' of https://github.com/alpha-xone/autogen i…
alpha-xone May 13, 2025
f7a2a85
add workflow to test
alpha-xone May 13, 2025
7931b47
fix install dependencies
alpha-xone May 13, 2025
3f4db19
fix dependencies
alpha-xone May 13, 2025
b675474
env variables ref fix
alpha-xone May 13, 2025
317841e
coverage in console
alpha-xone May 13, 2025
6fb0ed3
Merge branch 'main' into mem0-memory
victordibia May 13, 2025
caa825e
add tests for local mem0 storeage
alpha-xone May 16, 2025
f8f0b4d
Merge branch 'mem0-memory' of https://github.com/alpha-xone/autogen i…
alpha-xone May 16, 2025
07180fe
fix neo4j container
alpha-xone May 16, 2025
22fc898
fix neo4j docker
alpha-xone May 22, 2025
11639a3
fix neo4j docker
alpha-xone May 22, 2025
4b0698b
fix neo4j docker
alpha-xone May 22, 2025
d496a5f
fix test mem0
alpha-xone May 22, 2025
8be595f
add example of local deployment
alpha-xone May 22, 2025
76a7d04
Merge branch 'main' into mem0-memory
ekzhu May 22, 2025
5867837
Merge branch 'main' into mem0-memory
alpha-xone May 24, 2025
17b5955
add dependency in toml
alpha-xone May 24, 2025
0080d67
test poe modifications
alpha-xone May 24, 2025
72b30a9
revert minor fix
alpha-xone May 24, 2025
a913603
minor fix in CI
alpha-xone May 25, 2025
8ecfbfd
fix poe check
alpha-xone May 25, 2025
250e5bc
fix mypy
alpha-xone May 25, 2025
41b3aa8
use MagicMock as client for unit test
alpha-xone Jun 2, 2025
4c4bdca
Merge branch 'main' into mem0-memory
rickyloynd-microsoft Jun 3, 2025
7cd453c
test with magicmock
alpha-xone Jun 3, 2025
4085d7b
Merge branch 'mem0-memory' of https://github.com/alpha-xone/autogen i…
alpha-xone Jun 3, 2025
c51860b
Merge branch 'main' into mem0-memory
rickyloynd-microsoft Jun 3, 2025
2584a6e
Merge branch 'main' into mem0-memory
alpha-xone Jun 6, 2025
d615eae
correct format
alpha-xone Jun 6, 2025
72878f6
updated uv.lock
alpha-xone Jun 6, 2025
b8345db
formating
alpha-xone Jun 6, 2025
e902e03
commit for approval of CI
alpha-xone Jun 7, 2025
3d3980d
updated uv.lock
alpha-xone Jun 7, 2025
ab95e5b
try fixing uv.lock
alpha-xone Jun 7, 2025
7ed5163
fix uv.lock
alpha-xone Jun 8, 2025
1d09b07
Merge branch 'main' into mem0-memory
rickyloynd-microsoft Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/pytest-mem0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Mem0 Memory Tests

on:
# Run on pushes to any branch
push:
# Also run on pull requests to main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

services:
neo4j:
image: neo4j:5.26.6
ports:
- 7474:7474 # HTTP
- 7687:7687 # BOLT
env:
NEO4J_AUTH: neo4j/password
NEO4J_dbms_security_procedures_unrestricted: apoc.*
# Add this to ensure Neo4j is ready for connections quickly
NEO4J_dbms_memory_pagecache_size: 100M
NEO4J_dbms_memory_heap_initial__size: 100M
NEO4J_dbms_memory_heap_max__size: 500M
# Try a different health check approach
options: >-
--health-cmd "wget -O /dev/null -q http://localhost:7474 || exit 1"
--health-interval 5s
--health-timeout 15s
--health-retries 10
--health-start-period 30s

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Wait for Neo4j
run: |
# Give Neo4j some extra time to start up
sleep 10
# Try to connect to Neo4j
timeout 30s bash -c 'until curl -s http://localhost:7474 > /dev/null; do sleep 1; done'

- name: Install dependencies
run: |
python -m pip install --upgrade pip

# Install core packages first (in the right order)
cd python/packages/autogen-core
pip install -e .

cd ../autogen-agentchat
pip install -e .

# Now install autogen-ext with its dependencies
cd ../autogen-ext
pip install -e ".[dev,mem0,mem0-local]"

# Install test dependencies
pip install pytest pytest-asyncio pytest-cov
pip install python-dotenv

# Install dependencies for complex configuration tests
pip install "openai>=1.0.0"
pip install deepseek-ai

# Update test config to match the simplified Neo4j setup
- name: Update Neo4j password in tests
run: |
echo "NEO4J_PASSWORD=password" >> $GITHUB_ENV

- name: Run tests with coverage
# env:
# MEM0_API_KEY: ${{ secrets.MEM0_API_KEY }}
# SF_API_KEY: ${{ secrets.SF_API_KEY }}
# DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
run: |
cd python/packages/autogen-ext
pytest --cov=autogen_ext.memory.mem0 tests/memory/test_mem0.py -v --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./python/packages/autogen-ext/coverage.xml
name: codecov-mem0
fail_ci_if_error: false
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,98 @@
"4. Optimize embedding models for your specific domain\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mem0Memory Example\n",
"\n",
"`autogen_ext.memory.mem0.Mem0Memory` provides integration with `Mem0.ai`'s memory system. It supports both cloud-based and local backends, offering advanced memory capabilities for agents. The implementation handles proper retrieval and context updating, making it suitable for production environments.\n",
"\n",
"In the following example, we'll demonstrate how to use `Mem0Memory` to maintain persistent memories across conversations:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
"from autogen_agentchat.ui import Console\n",
"from autogen_core.memory import MemoryContent, MemoryMimeType\n",
"from autogen_ext.memory.mem0 import Mem0Memory\n",
"from autogen_ext.models.openai import OpenAIChatCompletionClient\n",
"\n",
"# Initialize Mem0 cloud memory (requires API key)\n",
"# For local deployment, use is_cloud=False with appropriate config\n",
"mem0_memory = Mem0Memory(\n",
" is_cloud=True,\n",
" limit=5, # Maximum number of memories to retrieve\n",
")\n",
"\n",
"# Add user preferences to memory\n",
"await mem0_memory.add(\n",
" MemoryContent(\n",
" content=\"The weather should be in metric units\",\n",
" mime_type=MemoryMimeType.TEXT,\n",
" metadata={\"category\": \"preferences\", \"type\": \"units\"},\n",
" )\n",
")\n",
"\n",
"await mem0_memory.add(\n",
" MemoryContent(\n",
" content=\"Meal recipe must be vegan\",\n",
" mime_type=MemoryMimeType.TEXT,\n",
" metadata={\"category\": \"preferences\", \"type\": \"dietary\"},\n",
" )\n",
")\n",
"\n",
"# Create assistant with mem0 memory\n",
"assistant_agent = AssistantAgent(\n",
" name=\"assistant_agent\",\n",
" model_client=OpenAIChatCompletionClient(\n",
" model=\"gpt-4o-2024-08-06\",\n",
" ),\n",
" tools=[get_weather],\n",
" memory=[mem0_memory],\n",
")\n",
"\n",
"# Ask about the weather\n",
"stream = assistant_agent.run_stream(task=\"What are my dietary preferences?\")\n",
"await Console(stream)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The example above demonstrates how Mem0Memory can be used with an assistant agent. The memory integration ensures that:\n",
"\n",
"1. All agent interactions are stored in Mem0 for future reference\n",
"2. Relevant memories (like user preferences) are automatically retrieved and added to the context\n",
"3. The agent can maintain consistent behavior based on stored memories\n",
"\n",
"Mem0Memory is particularly useful for:\n",
"- Long-running agent deployments that need persistent memory\n",
"- Applications requiring enhanced privacy controls\n",
"- Teams wanting unified memory management across agents\n",
"- Use cases needing advanced memory filtering and analytics\n",
"\n",
"Just like ChromaDBVectorMemory, you can serialize Mem0Memory configurations:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Serialize the memory configuration\n",
"config_json = mem0_memory.dump_component().model_dump_json()\n",
"print(f\"Memory config JSON: {config_json[:100]}...\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
6 changes: 6 additions & 0 deletions python/packages/autogen-ext/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ llama-cpp = [

graphrag = ["graphrag>=1.0.1"]
chromadb = ["chromadb>=1.0.0"]
mem0 = ["mem0ai>=0.1.98"]
mem0-local = [
"mem0ai>=0.1.98",
"neo4j>=5.25.0",
"chromadb>=1.0.0"
]
web-surfer = [
"autogen-agentchat==0.6.1",
"playwright>=1.48.0",
Expand Down
Loading
Loading