Skip to content

feat: adding oss version of companion cookbook#4564

Merged
whysosaket merged 5 commits intomainfrom
feat/oss-companion-cookbook
Mar 28, 2026
Merged

feat: adding oss version of companion cookbook#4564
whysosaket merged 5 commits intomainfrom
feat/oss-companion-cookbook

Conversation

@kartik-mem0
Copy link
Copy Markdown
Contributor

Description

Audited and tested the Open Source tab of the "Build a Companion with Mem0" cookbook (docs/cookbooks/essentials/building-ai-companion.mdx) to verify all code snippets work end-to-end with the
exact stack described: Ollama (LLM + embeddings) + Qdrant server (Docker).

Tested 9 cookbook patterns — all API calls, config, and filter syntax are correct and functional:

  1. Basic chat loop with memory (retrieve → generate → store)
  2. Organizing memory by type (metadata buckets with memory_bucket)
  3. Filtering what gets stored (custom_fact_extraction_prompt)
  4. Agent memory for personality (infer=False)
  5. Time-bound memories (expires_on in metadata)
  6. Episodic stories with run_id
  7. Handling contradictions (memory.update)
  8. Metadata tagging and filtering
  9. Pruning old memories (delete_all with run_id)

One issue found: custom_fact_extraction_prompt doesn't work reliably with llama3.1:8b — the model can't follow the structured JSON extraction prompt, causing it to drop all facts
including valid ones. The default extraction (without the custom prompt) already filters filler correctly.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (no functional changes)
  • Documentation update

Breaking Changes

N/A

Test Coverage

  • I added/updated unit tests
  • I added/updated integration tests
  • I tested manually (describe below)
  • No tests needed (explain why)

Ran test_companion.py against the exact cookbook stack (Ollama llama3.1 + nomic-embed-text + Qdrant server on Docker). 17/17 automated checks passed.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation if needed

@mintlify
Copy link
Copy Markdown
Contributor

mintlify bot commented Mar 27, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
mem0 🟢 Ready View Preview Mar 27, 2026, 10:02 AM

utkarsh240799
utkarsh240799 previously approved these changes Mar 27, 2026
Tell Mem0 what matters:

```python
MEMORY_CONFIG["custom_fact_extraction_prompt"] = """
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify from code if this is the right key name. (Just want to double check)

<Tab title="Open Source">
```python
memory.add(
"Max wants direct, data-driven feedback. Skip motivational language.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not encourage use to unstructured add, it should be kv pair as in other places.

speed_sessions = memory.search(
"speed work",
user_id="max",
filters={"workout_type": "speed"},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we confirm if filters like this work on oss?

@whysosaket whysosaket merged commit 41abb57 into main Mar 28, 2026
4 checks passed
@whysosaket whysosaket deleted the feat/oss-companion-cookbook branch March 28, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants