Commit Graph
458 Commits
Author SHA1 Message Date
kartik-mem0 c3f48d093e refactor: update MemoryClient to use entity options instead of filters 2026-04-14 17:13:52 +05:30
kartik-mem0 28cc8fcee4 refactor: update MemoryClient to use filters for entity parameters 2026-04-14 16:17:50 +05:30
Saket Aryan de6f9abc6c Update main.py 2026-04-14 02:49:22 +05:30
Soumil RathiandClaude Opus 4.6 66446bd118 fix: address reviewer bugs — metadata mutation, test args, embedding dict, output_format
1. Fix _create_procedural_memory metadata mutation: use spread operator
   instead of in-place dict assignment (sync + async)
2. Fix test_add assertion: remove trailing None arg that doesn't match
   _add_to_vector_store(messages, metadata, filters, infer) signature
3. Restore output_format: "v1.1" in TS client search payload as fallback
4. Fix infer=False path: pass {text: embedding} dict to _create_memory
   instead of raw embedding list to avoid redundant embed() calls (sync + async)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:50:56 -07:00
Soumil RathiandClaude Opus 4.6 3ae22be8a2 fix: resolve CI failures — lint errors, pytz in redis, lockfile mismatch
- Remove unused imports: get_update_memory_messages, get_fact_retrieval_messages
- Fix pytz.timezone("US/Pacific") → timezone.utc in redis vector store
- Remove unused entity_types variable in test_entity_extraction
- Regenerate pnpm-lock.yaml after neo4j-driver removal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:24:14 -07:00
Soumil RathiandClaude Opus 4.6 730b2ff422 fix: restore complete _SENSITIVE_FIELDS_EXACT list from original commit
Was missing 13 entries (credentials, token, access_token, refresh_token,
auth_token, session_token, client_secret, auth_client_secret,
azure_client_secret, service_account_json, aws_session_token, credential,
secret). Now matches the original list from commit 46b4b2e9.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:03:49 -07:00
Soumil RathiandClaude Opus 4.6 573ca54637 fix: restore _is_sensitive_field and sensitive field redaction in _safe_deepcopy_config
The function and associated constants (_SENSITIVE_FIELDS_EXACT,
_SENSITIVE_SUFFIXES) were accidentally dropped during the merge.
Restores telemetry-safe config cloning that redacts API keys,
passwords, and other secrets while preserving runtime auth objects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:53:56 -07:00
Soumil RathiandClaude Opus 4.6 59880a6f8f feat: TS SDK v3 port, graph store removal, client v3 API migration
TypeScript SDK v3 pipeline (full parity with Python):
- Single-pass additive extraction with ADDITIVE_EXTRACTION_PROMPT
- Hybrid search (semantic + BM25 + entity boost) with additive scoring
- 8-phase batch pipeline (batch embed, persist, entity linking)
- New utils: scoring.ts, lemmatization.ts (natural), entity_extraction.ts (compromise)
- keywordSearch() on 8 vector stores (3 full: PGVector, Memory, Azure AI Search)
- Message persistence in SQLiteManager (rolling window of 10)
- Entity store as second vector collection
- MAX_BATCH=100 chunking guard on OpenAI/Azure embedBatch
- Updated default LLM model to gpt-4.1-nano-2025-04-14
- compromise + natural added as peer dependencies

Graph store removal (Python + TypeScript):
- Removed Neo4j, Memgraph, Kuzu, Neptune, Apache AGE integrations
- Deleted 18 graph-related files across both SDKs
- Removed GraphStoreFactory, GraphStoreConfig, graph_store config field
- Removed "relations" key from all API responses
- Removed graph optional dependency group from pyproject.toml
- Removed neo4j-driver from TS peerDependencies
- Simplified add/search/delete/reset (no more parallel graph operations)

Client SDK v3 API migration:
- add() endpoint: /v1/memories/ -> /v3/memories/ (async response)
- search() endpoint: /v2/memories/search/ -> /v3/memories/search/
- Removed output_format injection and v1.1 unwrapping logic
- Applied to both Python (sync + async) and TypeScript clients

Review feedback fixes:
- Removed deprecated custom_update_memory_prompt from MemoryConfig
- Added MAX_BATCH=100 chunking to Python + TS embed_batch
- Moved all inline imports to top level in main.py
- Cleaned up GraphStoreError dead code from exceptions.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:45:40 -07:00
Soumil RathiandClaude Opus 4.6 3402c67805 fix: address PR review feedback
- Remove deprecated custom_update_memory_prompt from MemoryConfig entirely
- Add MAX_BATCH=100 chunking guard to embed_batch in openai.py and azure_openai.py
- Move all inline imports (mem0.utils.*) to top-level in main.py
- Remove custom_update_memory_prompt from test fixture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:01:07 -07:00
Soumil Rathi c0343aec1b Merge remote-tracking branch 'origin/feat/v3-pipeline' into feat/v3-pipeline
# Conflicts:
#	mem0-ts/src/oss/src/utils/factory.ts
#	mem0/vector_stores/milvus.py
#	mem0/vector_stores/qdrant.py
2026-04-12 16:30:05 -07:00
Soumil RathiandClaude Opus 4.6 b9e26acf4d merge: integrate main into feat/v3-pipeline + port AsyncMemory to v3
Merge 190 commits from main including:
- limit→top_k rename across all vector store APIs
- custom_fact_extraction_prompt→custom_instructions rename
- enable_graph flag removal (use self.graph truthiness)
- US/Pacific→timezone.utc normalization
- 18 Category A bug fixes (partial updates, graph cleanup on delete,
  telemetry gating, metadata mutation prevention, filter operator
  merging, delete timestamps, actor_id preservation, etc.)

Conflict resolutions:
- openai.py: merged _pass_dimensions_to_api with embed_batch
- milvus.py: merged partial-update logic with BM25 text field
- qdrant.py: took main's enhanced _create_filter, merged BM25
  sparse vectors with partial-update endpoints
- test_main.py: adopted main's test structure, removed obsolete
  test_custom_prompts, kept hybrid search over-fetch assertion

AsyncMemory v3 port (full parity):
- Rewrote AsyncMemory._add_to_vector_store with the same 8-phase
  batch pipeline as sync Memory (single LLM call, batch embed,
  hash dedup, batch persist, batch entity linking, message saving)
- All blocking calls wrapped in await asyncio.to_thread()
- Moved _build_session_scope to module level for shared access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 16:26:10 -07:00
9d6b79a14e fix(sdk): removing the enable graph flag and switching from snake case to camel case for client ts sdk (#4776)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 02:40:54 +05:30
KartikandGitHub e44b46ef2e fix(sdk): removing deprecating param from our sdk and docs changes with it (#4740) 2026-04-12 00:34:58 +05:30
Gabriel SteinandGitHub 9d82e2329d refactor(telemetry): sample OSS hot-path events at 10% to reduce PostHog volume (#4771) 2026-04-11 16:25:38 +05:30
398445c691 fix: filters did not support AND, OR and NOT in Qdant and other vector stores (#4780)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:43:12 +05:30
081eca6d8f fix: guard temp_uuid_mapping lookups against LLM-hallucinated IDs (fixes #3931) (#4674)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-08 21:55:52 +05:30
Rakhee SinghandGitHub 3ffea554bc fix(azure_openai): forward response_format to Azure OpenAI API (#4689) 2026-04-08 19:22:02 +05:30
Soumil RathiandClaude Sonnet 4.6 90f9e6a550 Fix: use caller-provided timestamp for memory created_at instead of always using datetime.now()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 12:52:43 -07:00
DEVAN CHAUHANandGitHub c55447c1e4 [fix] groq model (#4700) 2026-04-04 21:36:17 +05:30
Soumil Rathi a6130c5436 perf: skip ThreadPoolExecutor when graph store is disabled
Avoids spawning 2 threads per add() call when graph is not configured.
Fixes thread leakage under high concurrency (was accumulating 3500+ threads
per worker). Calls _add_to_vector_store directly in the current thread.

Applied to both sync Memory and async AsyncMemory classes.
2026-04-03 07:42:32 -07:00
fcbb70ab3b fix: prevent thread and memory leaks from PostHog telemetry (#4535)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-03 20:01:04 +05:30
Soumil Rathi cb64d978fc perf: batch entity linking — embed, search, insert in bulk instead of per-entity
- Replace sequential _upsert_entity() loop with batched pipeline:
  1. Global dedup: collect unique entities across all memories
  2. Single embed_batch() call for all entity texts
  3. Batch search via search_batch() (Qdrant query_batch_points)
  4. Batch insert for new entities, individual updates for existing
- Add search_batch() to VectorStoreBase (sequential fallback)
- Add native search_batch() to Qdrant using query_batch_points
- ~6-10x reduction in entity linking network round trips
2026-04-02 19:32:29 -07:00
Soumil RathiandClaude Opus 4.6 41532d8850 refactor(oss): trim and update ADDITIVE_EXTRACTION_PROMPT
Streamline prompt guidelines and update examples for clarity.
Remove redundant sections and verbose explanations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:11:52 -07:00
Soumil RathiandClaude Opus 4.6 9c9b3d54e2 feat(oss): make spaCy an optional dependency
Move spacy from core dependencies to optional [nlp] extra.
The system gracefully degrades without spaCy:
- Lemmatization falls back to raw text
- Entity extraction returns empty (no entity boost)
- BM25 keyword search still works on raw text
- Semantic search and additive scoring unaffected

Install with NLP support: pip install mem0ai[nlp]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:04:38 -07:00
Soumil Rathi 70c62ea54f fix: add text_lemmatized to create/update memory + fix keyword search across vector stores
- Add text_lemmatized to _create_memory() and _update_memory() (sync + async)
  so BM25/keyword search works for all code paths, not just the batch pipeline
- pgvector: add GIN index on text_lemmatized for fast full-text search
- pgvector: add error logging to keyword_search
- milvus: add sparse BM25 field + function to create_col() so keyword_search works
- mongodb: auto-create Atlas Search text index in create_col()
- azure_mysql: add generated column + FULLTEXT index for keyword_search
2026-04-02 10:34:03 -07:00
Soumil Rathi 4534acdfbe feat(qdrant): implement client-side BM25 sparse vectors via fastembed
- Add sparse_vectors_config with 'bm25' named vector to create_col()
- Compute BM25 sparse vectors from text_lemmatized during insert/update
- Use client-side fastembed Qdrant/bm25 encoder instead of server-side inference
- Graceful fallback if fastembed not installed
- Fixes keyword_search() returning None on self-hosted Qdrant
2026-04-02 10:23:17 -07:00
868b63af63 fix: use DatetimeRange for datetime string values in Qdrant range filters (#4659)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-02 18:43:58 +05:30
6cc1c15320 feat(sdk): add multilingual param to project update (#4314)
Co-authored-by: Soumil Rathi <soumilrathi@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 18:38:26 +05:30
7a20da59ee fix(configs): add missing ConfigDict to vector store configs (#4656)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-04-02 18:05:54 +05:30
Soumil RathiandClaude Opus 4.6 80749b92bf fix(oss): align API naming with platform v3
- Rename `observation_date` param to `timestamp` (matches platform)
- Change `rerank` default from True to False (matches platform)
- Internal prompt builder still uses "Observation Date" section heading
  for LLM compatibility with ADDITIVE_EXTRACTION_PROMPT

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 21:49:21 -07:00
Prithvi MonangiandGitHub f94ea06588 fix(configs): migrate CassandraConfig and AzureMySQLConfig to pydantic v2 ConfigDict (#4646) 2026-04-01 15:02:22 +05:30
Soumil RathiandClaude Opus 4.6 a33c557a25 feat(oss): port v3 pipeline with hybrid search, entity extraction, and additive scoring
Replace the 2-LLM-call add pipeline with a single-pass additive extraction
using ADDITIVE_EXTRACTION_PROMPT. Memories now accumulate (ADD-only) instead
of being updated/deleted during extraction.

Search pipeline upgraded to hybrid scoring combining three signals:
- Semantic similarity (vector search)
- BM25 keyword matching (native per vector store, 15 stores supported)
- Entity boost (spaCy NER with entity collection linking)

Combined score = (semantic + bm25 + entity_boost) / max_possible, where
max_possible adapts based on which signals are active.

Key changes:
- Add spaCy-based lemmatization for BM25 keyword search
- Add spaCy-based entity extraction (PROPER, QUOTED, COMPOUND, NOUN types)
- Add entity store as second vector collection ({collection}_entities)
- Add native keyword_search() to 15 vector store adapters
- Add batch embedding support (embed_batch) for OpenAI and Azure OpenAI
- Add message persistence in SQLite (rolling window of 10 per scope)
- Add additive scoring with adaptive normalization
- Add observation_date parameter to add()
- Add custom_instructions config field
- Default search threshold changed to 0.1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 14:09:37 -07:00
Noah StappandGitHub 215d8b5a71 fix: only list authorized collections when listing MongoDB collections (#3888) 2026-03-31 23:09:36 +05:30
Rakhee SinghandGitHub 93bd4e248c fix(deepseek): forward response_format to OpenAI-compatible API (#4635) 2026-03-31 18:06:53 +05:30
dbac83218f fix(vllm): forward response_format to OpenAI-compatible API (#4608)
Co-authored-by: rasingh5 <rasingh@demandbase.com>
2026-03-31 13:25:45 +05:30
HUANG XIAOandGitHub 5d30af9560 feat(bedrock): add MiniMax provider support for AWS Bedrock (#4609) 2026-03-30 20:40:24 +05:30
7213e1b1a6 fix: reset graph database in Memory.reset() (#4185)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
2026-03-30 18:45:38 +05:30
Br1anandGitHub 97291aa119 fix: make AsyncMemory.from_config a regular classmethod (#4183) 2026-03-30 16:19:37 +05:30
HimanshuandGitHub ae49edec44 fix(memory): centralize entity cleanup and skip malformed LLM relation dicts (#4515) 2026-03-28 21:23:05 +05:30
Br1anandGitHub 27a6e7863e fix: rebuild FAISS index on vector deletion (#4178) 2026-03-28 20:56:39 +05:30
KartikandGitHub cd2dd7cc54 refactor: update default Gemini and Vertex AI embedder model to gemini-embedding-001 (#4571) 2026-03-28 20:39:27 +05:30
KartikandGitHub c2698f2b71 fix: preserve original actor_id during memory update (#4570) 2026-03-28 00:02:58 +05:30
e87240d4d9 fix(vector_stores): handle vector=None in Milvus and Qdrant update methods (#4568)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:50:54 +05:30
Gopal BagaswarandGitHub 68cf4e118d feat: add reasoning_effort parameter support for reasoning models (#4461) 2026-03-27 17:54:44 +05:30
12624555b4 fix(memory): set updated_at on creation and preserve pre-existing created_at (#4499)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 16:59:44 +05:30
3ac4e047de fix: merge multiple filter operators for same key (#4559)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 20:28:37 +05:30
a2ffca3266 fix: prevent SQL injection in Databricks vector store (#4558)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 20:22:34 +05:30
5edc0cc99f fix: update parameter added to the update function which is exposed t… (#3799)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 20:02:33 +05:30
VictorECDSAandGitHub 1aecfadf45 fix: add timestamps for DELETE operations in history (#4492) 2026-03-26 18:52:10 +05:30
2a59c9fd99 fix: handle chatty LLM responses in JSON parsing (#4525)
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:39:17 +05:30