Skip to content

Conversation

@pmukeshreddy
Copy link

Summary

Adds custom_search_prompt config option for customizing entity extraction during graph search.

Problem

The search path uses a hardcoded prompt in _retrieve_nodes_from_data(). This doesn't work for domain-specific use cases where:

  • Entity types need to be constrained (e.g., only Medication, Condition)
  • Terminology mapping is needed (e.g., "heart attack" → "Myocardial Infarction")

Solution

New config option custom_search_prompt parallel to existing custom_prompt (which is for add path).

Usage

config = {
    "graph_store": {
        "provider": "neo4j",
        "config": {...},
        "custom_search_prompt": "Extract medical entities: Medication, Condition, Allergy. Patient: {user_id}"
    }
}

Changes

  • graphs/configs.py: Added custom_search_prompt field to GraphStoreConfig
  • memory/graph_memory.py: Use custom prompt in Neo4j implementation
  • memory/memgraph_memory.py: Use custom prompt in Memgraph implementation
  • graphs/neptune/base.py: Use custom prompt in Neptune implementation

Fixes #3299

- Add custom_search_prompt config option to GraphStoreConfig
- Use custom prompt in _retrieve_nodes_from_data() for Neo4j, Memgraph, Neptune
- Supports {user_id} placeholder substitution
- Falls back to default prompt when not provided

Fixes mem0ai#3299
@CLAassistant
Copy link

CLAassistant commented Dec 31, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants