-
Notifications
You must be signed in to change notification settings - Fork 45
fix: forward hybrid/keyword search params through all search paths and update docs #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
07a9ce1
9178c57
67ae703
e47412f
4ac1b79
6d175bf
eb2e92e
436b442
49008ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1386,7 +1386,7 @@ async def handle_tool_calls(client, tool_calls): | |
| "type": "function", | ||
| "function": { | ||
| "name": "search_memory", | ||
| "description": "Search long-term memory for relevant information using semantic vector search. Use this when you need to find previously stored information about the user, such as their preferences, past conversations, or important facts. Examples: 'Find information about user food preferences', 'What did they say about their job?', 'Look for travel preferences'. This searches only long-term memory, not current working memory - use get_working_memory for current session info. IMPORTANT: The result includes 'memories' with an 'id' field; use these IDs when calling edit_long_term_memory or delete_long_term_memories.", | ||
| "description": "Search long-term memory for relevant information using semantic, keyword, or hybrid search. Use this when you need to find previously stored information about the user, such as their preferences, past conversations, or important facts. Examples: 'Find information about user food preferences', 'What did they say about their job?', 'Look for travel preferences'. This searches only long-term memory, not current working memory - use get_or_create_working_memory for current session info. IMPORTANT: The result includes 'memories' with an 'id' field; use these IDs when calling edit_long_term_memory or delete_long_term_memories.", | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "parameters": { | ||
nkanu17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "object", | ||
| "properties": { | ||
nkanu17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -1875,7 +1875,7 @@ def get_update_memory_data_tool_schema(cls) -> ToolSchema: | |
| "type": "function", | ||
| "function": { | ||
| "name": "update_working_memory_data", | ||
| "description": "Store or update structured session data (JSON objects) in working memory. Use this for complex session-specific information that needs to be accessed and modified during the conversation. Examples: Travel itinerary {'destination': 'Paris', 'dates': ['2024-03-15', '2024-03-20']}, project details {'name': 'Website Redesign', 'deadline': '2024-04-01', 'status': 'in_progress'}. Different from add_memory_to_working_memory which stores simple text facts.", | ||
| "description": "Store or update structured session data (JSON objects) in working memory. Use this for complex session-specific information that needs to be accessed and modified during the conversation. Examples: Travel itinerary {'destination': 'Paris', 'dates': ['2024-03-15', '2024-03-20']}, project details {'name': 'Website Redesign', 'deadline': '2024-04-01', 'status': 'in_progress'}. Different from lazily_create_long_term_memory which stores simple text facts for later promotion to long-term storage.", | ||
| "parameters": { | ||
| "type": "object", | ||
| "properties": { | ||
|
|
@@ -2706,7 +2706,7 @@ async def _resolve_search_memory(self, args: dict[str, Any]) -> dict[str, Any]: | |
| async def _resolve_get_working_memory( | ||
| self, session_id: str, namespace: str | None, user_id: str | None = None | ||
| ) -> dict[str, Any]: | ||
| """Resolve get_working_memory function call.""" | ||
| """Resolve get_working_memory (deprecated) function call.""" | ||
| return await self.get_working_memory_tool( | ||
| session_id=session_id, | ||
| namespace=namespace, | ||
|
|
@@ -2731,7 +2731,7 @@ async def _resolve_add_memory( | |
| namespace: str | None, | ||
| user_id: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| """Resolve add_memory_to_working_memory function call.""" | ||
| """Resolve lazily_create_long_term_memory (formerly add_memory_to_working_memory) function call.""" | ||
| text = args.get("text", "") | ||
| if not text: | ||
| raise ValueError("Text parameter is required for adding memory") | ||
|
|
@@ -2790,11 +2790,11 @@ async def _resolve_get_long_term_memory( | |
| async def _resolve_create_long_term_memory( | ||
| self, args: dict[str, Any], namespace: str | None, user_id: str | None = None | ||
| ) -> dict[str, Any]: | ||
| """Resolve create_long_term_memory function call.""" | ||
| """Resolve eagerly_create_long_term_memory (and deprecated create_long_term_memory alias) function call.""" | ||
| memories_data = args.get("memories") | ||
| if not memories_data: | ||
| raise ValueError( | ||
| "memories parameter is required for create_long_term_memory" | ||
| "memories parameter is required for eagerly_create_long_term_memory" | ||
| ) | ||
|
||
|
|
||
| # Convert dict memories to ClientMemoryRecord objects | ||
|
|
@@ -2907,7 +2907,7 @@ async def resolve_function_calls( | |
| # Handle multiple function calls | ||
| calls = [ | ||
| {"name": "search_memory", "arguments": {"query": "user preferences"}}, | ||
| {"name": "get_working_memory", "arguments": {}}, | ||
| {"name": "get_or_create_working_memory", "arguments": {}}, | ||
| ] | ||
|
|
||
| results = await client.resolve_function_calls(calls, "session123") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,14 +4,14 @@ Long-term memory is **persistent**, **cross-session** storage designed for knowl | |
|
|
||
| ## Overview | ||
|
|
||
| Long-term memory provides persistent storage that survives server restarts and session expiration. It's optimized for semantic search, deduplication, and rich metadata to enable intelligent retrieval of relevant information. | ||
| Long-term memory provides persistent storage that survives server restarts and session expiration. It's optimized for semantic, keyword, and hybrid search, deduplication, and rich metadata to enable intelligent retrieval of relevant information. | ||
|
|
||
| | Feature | Details | | ||
| |---------|---------| | ||
| | **Scope** | Cross-session, persistent | | ||
| | **Lifespan** | Permanent until manually deleted | | ||
| | **Storage** | Redis with vector indexing | | ||
| | **Search** | Semantic vector search | | ||
| | **Search** | Semantic, keyword, and hybrid search | | ||
| | **Capacity** | Unlimited (with compaction) | | ||
| | **Use Case** | Knowledge base, user preferences | | ||
| | **Indexing** | Vector embeddings + metadata | | ||
|
||
|
|
@@ -126,17 +126,38 @@ POST /v1/long-term-memory/search | |
|
|
||
| ## Search Capabilities | ||
|
|
||
| Long-term memory provides powerful search features: | ||
| Long-term memory supports three search modes: **semantic** (vector similarity), **keyword** (full-text matching), and **hybrid** (combined). | ||
|
|
||
| ### Semantic Vector Search | ||
| ### Semantic Search (Default) | ||
| ```json | ||
| { | ||
| "text": "python programming help", | ||
| "search_mode": "semantic", | ||
| "limit": 10, | ||
| "distance_threshold": 0.8 | ||
| } | ||
| ``` | ||
|
|
||
| ### Keyword Search | ||
| ```json | ||
| { | ||
| "text": "TechCorp engineer", | ||
| "search_mode": "keyword", | ||
| "limit": 10 | ||
| } | ||
| ``` | ||
|
|
||
| ### Hybrid Search | ||
| Combines vector similarity with full-text keyword matching. Use `hybrid_alpha` to control the balance (0.0 = pure keyword, 1.0 = pure semantic, default 0.7). | ||
| ```json | ||
| { | ||
| "text": "python programming help", | ||
| "search_mode": "hybrid", | ||
| "hybrid_alpha": 0.7, | ||
| "limit": 10 | ||
| } | ||
| ``` | ||
|
|
||
| ### Advanced Filtering | ||
| ```json | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.