MemoryOS 2.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- memoryos-2.0.3.dist-info/METADATA +418 -0
- memoryos-2.0.3.dist-info/RECORD +315 -0
- memoryos-2.0.3.dist-info/WHEEL +4 -0
- memoryos-2.0.3.dist-info/entry_points.txt +3 -0
- memoryos-2.0.3.dist-info/licenses/LICENSE +201 -0
- memos/__init__.py +20 -0
- memos/api/client.py +571 -0
- memos/api/config.py +1018 -0
- memos/api/context/dependencies.py +50 -0
- memos/api/exceptions.py +53 -0
- memos/api/handlers/__init__.py +62 -0
- memos/api/handlers/add_handler.py +158 -0
- memos/api/handlers/base_handler.py +194 -0
- memos/api/handlers/chat_handler.py +1401 -0
- memos/api/handlers/component_init.py +388 -0
- memos/api/handlers/config_builders.py +190 -0
- memos/api/handlers/feedback_handler.py +93 -0
- memos/api/handlers/formatters_handler.py +237 -0
- memos/api/handlers/memory_handler.py +316 -0
- memos/api/handlers/scheduler_handler.py +497 -0
- memos/api/handlers/search_handler.py +222 -0
- memos/api/handlers/suggestion_handler.py +117 -0
- memos/api/mcp_serve.py +614 -0
- memos/api/middleware/request_context.py +101 -0
- memos/api/product_api.py +38 -0
- memos/api/product_models.py +1206 -0
- memos/api/routers/__init__.py +1 -0
- memos/api/routers/product_router.py +477 -0
- memos/api/routers/server_router.py +394 -0
- memos/api/server_api.py +44 -0
- memos/api/start_api.py +433 -0
- memos/chunkers/__init__.py +4 -0
- memos/chunkers/base.py +24 -0
- memos/chunkers/charactertext_chunker.py +41 -0
- memos/chunkers/factory.py +24 -0
- memos/chunkers/markdown_chunker.py +62 -0
- memos/chunkers/sentence_chunker.py +54 -0
- memos/chunkers/simple_chunker.py +50 -0
- memos/cli.py +113 -0
- memos/configs/__init__.py +0 -0
- memos/configs/base.py +82 -0
- memos/configs/chunker.py +59 -0
- memos/configs/embedder.py +88 -0
- memos/configs/graph_db.py +236 -0
- memos/configs/internet_retriever.py +100 -0
- memos/configs/llm.py +151 -0
- memos/configs/mem_agent.py +54 -0
- memos/configs/mem_chat.py +81 -0
- memos/configs/mem_cube.py +105 -0
- memos/configs/mem_os.py +83 -0
- memos/configs/mem_reader.py +91 -0
- memos/configs/mem_scheduler.py +385 -0
- memos/configs/mem_user.py +70 -0
- memos/configs/memory.py +324 -0
- memos/configs/parser.py +38 -0
- memos/configs/reranker.py +18 -0
- memos/configs/utils.py +8 -0
- memos/configs/vec_db.py +80 -0
- memos/context/context.py +355 -0
- memos/dependency.py +52 -0
- memos/deprecation.py +262 -0
- memos/embedders/__init__.py +0 -0
- memos/embedders/ark.py +95 -0
- memos/embedders/base.py +106 -0
- memos/embedders/factory.py +29 -0
- memos/embedders/ollama.py +77 -0
- memos/embedders/sentence_transformer.py +49 -0
- memos/embedders/universal_api.py +51 -0
- memos/exceptions.py +30 -0
- memos/graph_dbs/__init__.py +0 -0
- memos/graph_dbs/base.py +274 -0
- memos/graph_dbs/factory.py +27 -0
- memos/graph_dbs/item.py +46 -0
- memos/graph_dbs/nebular.py +1794 -0
- memos/graph_dbs/neo4j.py +1942 -0
- memos/graph_dbs/neo4j_community.py +1058 -0
- memos/graph_dbs/polardb.py +5446 -0
- memos/hello_world.py +97 -0
- memos/llms/__init__.py +0 -0
- memos/llms/base.py +25 -0
- memos/llms/deepseek.py +13 -0
- memos/llms/factory.py +38 -0
- memos/llms/hf.py +443 -0
- memos/llms/hf_singleton.py +114 -0
- memos/llms/ollama.py +135 -0
- memos/llms/openai.py +222 -0
- memos/llms/openai_new.py +198 -0
- memos/llms/qwen.py +13 -0
- memos/llms/utils.py +14 -0
- memos/llms/vllm.py +218 -0
- memos/log.py +237 -0
- memos/mem_agent/base.py +19 -0
- memos/mem_agent/deepsearch_agent.py +391 -0
- memos/mem_agent/factory.py +36 -0
- memos/mem_chat/__init__.py +0 -0
- memos/mem_chat/base.py +30 -0
- memos/mem_chat/factory.py +21 -0
- memos/mem_chat/simple.py +200 -0
- memos/mem_cube/__init__.py +0 -0
- memos/mem_cube/base.py +30 -0
- memos/mem_cube/general.py +240 -0
- memos/mem_cube/navie.py +172 -0
- memos/mem_cube/utils.py +169 -0
- memos/mem_feedback/base.py +15 -0
- memos/mem_feedback/feedback.py +1192 -0
- memos/mem_feedback/simple_feedback.py +40 -0
- memos/mem_feedback/utils.py +230 -0
- memos/mem_os/client.py +5 -0
- memos/mem_os/core.py +1203 -0
- memos/mem_os/main.py +582 -0
- memos/mem_os/product.py +1608 -0
- memos/mem_os/product_server.py +455 -0
- memos/mem_os/utils/default_config.py +359 -0
- memos/mem_os/utils/format_utils.py +1403 -0
- memos/mem_os/utils/reference_utils.py +162 -0
- memos/mem_reader/__init__.py +0 -0
- memos/mem_reader/base.py +47 -0
- memos/mem_reader/factory.py +53 -0
- memos/mem_reader/memory.py +298 -0
- memos/mem_reader/multi_modal_struct.py +965 -0
- memos/mem_reader/read_multi_modal/__init__.py +43 -0
- memos/mem_reader/read_multi_modal/assistant_parser.py +311 -0
- memos/mem_reader/read_multi_modal/base.py +273 -0
- memos/mem_reader/read_multi_modal/file_content_parser.py +826 -0
- memos/mem_reader/read_multi_modal/image_parser.py +359 -0
- memos/mem_reader/read_multi_modal/multi_modal_parser.py +252 -0
- memos/mem_reader/read_multi_modal/string_parser.py +139 -0
- memos/mem_reader/read_multi_modal/system_parser.py +327 -0
- memos/mem_reader/read_multi_modal/text_content_parser.py +131 -0
- memos/mem_reader/read_multi_modal/tool_parser.py +210 -0
- memos/mem_reader/read_multi_modal/user_parser.py +218 -0
- memos/mem_reader/read_multi_modal/utils.py +358 -0
- memos/mem_reader/simple_struct.py +912 -0
- memos/mem_reader/strategy_struct.py +163 -0
- memos/mem_reader/utils.py +157 -0
- memos/mem_scheduler/__init__.py +0 -0
- memos/mem_scheduler/analyzer/__init__.py +0 -0
- memos/mem_scheduler/analyzer/api_analyzer.py +714 -0
- memos/mem_scheduler/analyzer/eval_analyzer.py +219 -0
- memos/mem_scheduler/analyzer/mos_for_test_scheduler.py +571 -0
- memos/mem_scheduler/analyzer/scheduler_for_eval.py +280 -0
- memos/mem_scheduler/base_scheduler.py +1319 -0
- memos/mem_scheduler/general_modules/__init__.py +0 -0
- memos/mem_scheduler/general_modules/api_misc.py +137 -0
- memos/mem_scheduler/general_modules/base.py +80 -0
- memos/mem_scheduler/general_modules/init_components_for_scheduler.py +425 -0
- memos/mem_scheduler/general_modules/misc.py +313 -0
- memos/mem_scheduler/general_modules/scheduler_logger.py +389 -0
- memos/mem_scheduler/general_modules/task_threads.py +315 -0
- memos/mem_scheduler/general_scheduler.py +1495 -0
- memos/mem_scheduler/memory_manage_modules/__init__.py +5 -0
- memos/mem_scheduler/memory_manage_modules/memory_filter.py +306 -0
- memos/mem_scheduler/memory_manage_modules/retriever.py +547 -0
- memos/mem_scheduler/monitors/__init__.py +0 -0
- memos/mem_scheduler/monitors/dispatcher_monitor.py +366 -0
- memos/mem_scheduler/monitors/general_monitor.py +394 -0
- memos/mem_scheduler/monitors/task_schedule_monitor.py +254 -0
- memos/mem_scheduler/optimized_scheduler.py +410 -0
- memos/mem_scheduler/orm_modules/__init__.py +0 -0
- memos/mem_scheduler/orm_modules/api_redis_model.py +518 -0
- memos/mem_scheduler/orm_modules/base_model.py +729 -0
- memos/mem_scheduler/orm_modules/monitor_models.py +261 -0
- memos/mem_scheduler/orm_modules/redis_model.py +699 -0
- memos/mem_scheduler/scheduler_factory.py +23 -0
- memos/mem_scheduler/schemas/__init__.py +0 -0
- memos/mem_scheduler/schemas/analyzer_schemas.py +52 -0
- memos/mem_scheduler/schemas/api_schemas.py +233 -0
- memos/mem_scheduler/schemas/general_schemas.py +55 -0
- memos/mem_scheduler/schemas/message_schemas.py +173 -0
- memos/mem_scheduler/schemas/monitor_schemas.py +406 -0
- memos/mem_scheduler/schemas/task_schemas.py +132 -0
- memos/mem_scheduler/task_schedule_modules/__init__.py +0 -0
- memos/mem_scheduler/task_schedule_modules/dispatcher.py +740 -0
- memos/mem_scheduler/task_schedule_modules/local_queue.py +247 -0
- memos/mem_scheduler/task_schedule_modules/orchestrator.py +74 -0
- memos/mem_scheduler/task_schedule_modules/redis_queue.py +1385 -0
- memos/mem_scheduler/task_schedule_modules/task_queue.py +162 -0
- memos/mem_scheduler/utils/__init__.py +0 -0
- memos/mem_scheduler/utils/api_utils.py +77 -0
- memos/mem_scheduler/utils/config_utils.py +100 -0
- memos/mem_scheduler/utils/db_utils.py +50 -0
- memos/mem_scheduler/utils/filter_utils.py +176 -0
- memos/mem_scheduler/utils/metrics.py +125 -0
- memos/mem_scheduler/utils/misc_utils.py +290 -0
- memos/mem_scheduler/utils/monitor_event_utils.py +67 -0
- memos/mem_scheduler/utils/status_tracker.py +229 -0
- memos/mem_scheduler/webservice_modules/__init__.py +0 -0
- memos/mem_scheduler/webservice_modules/rabbitmq_service.py +485 -0
- memos/mem_scheduler/webservice_modules/redis_service.py +380 -0
- memos/mem_user/factory.py +94 -0
- memos/mem_user/mysql_persistent_user_manager.py +271 -0
- memos/mem_user/mysql_user_manager.py +502 -0
- memos/mem_user/persistent_factory.py +98 -0
- memos/mem_user/persistent_user_manager.py +260 -0
- memos/mem_user/redis_persistent_user_manager.py +225 -0
- memos/mem_user/user_manager.py +488 -0
- memos/memories/__init__.py +0 -0
- memos/memories/activation/__init__.py +0 -0
- memos/memories/activation/base.py +42 -0
- memos/memories/activation/item.py +56 -0
- memos/memories/activation/kv.py +292 -0
- memos/memories/activation/vllmkv.py +219 -0
- memos/memories/base.py +19 -0
- memos/memories/factory.py +42 -0
- memos/memories/parametric/__init__.py +0 -0
- memos/memories/parametric/base.py +19 -0
- memos/memories/parametric/item.py +11 -0
- memos/memories/parametric/lora.py +41 -0
- memos/memories/textual/__init__.py +0 -0
- memos/memories/textual/base.py +92 -0
- memos/memories/textual/general.py +236 -0
- memos/memories/textual/item.py +304 -0
- memos/memories/textual/naive.py +187 -0
- memos/memories/textual/prefer_text_memory/__init__.py +0 -0
- memos/memories/textual/prefer_text_memory/adder.py +504 -0
- memos/memories/textual/prefer_text_memory/config.py +106 -0
- memos/memories/textual/prefer_text_memory/extractor.py +221 -0
- memos/memories/textual/prefer_text_memory/factory.py +85 -0
- memos/memories/textual/prefer_text_memory/retrievers.py +177 -0
- memos/memories/textual/prefer_text_memory/spliter.py +132 -0
- memos/memories/textual/prefer_text_memory/utils.py +93 -0
- memos/memories/textual/preference.py +344 -0
- memos/memories/textual/simple_preference.py +161 -0
- memos/memories/textual/simple_tree.py +69 -0
- memos/memories/textual/tree.py +459 -0
- memos/memories/textual/tree_text_memory/__init__.py +0 -0
- memos/memories/textual/tree_text_memory/organize/__init__.py +0 -0
- memos/memories/textual/tree_text_memory/organize/handler.py +184 -0
- memos/memories/textual/tree_text_memory/organize/manager.py +518 -0
- memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py +238 -0
- memos/memories/textual/tree_text_memory/organize/reorganizer.py +622 -0
- memos/memories/textual/tree_text_memory/retrieve/__init__.py +0 -0
- memos/memories/textual/tree_text_memory/retrieve/advanced_searcher.py +364 -0
- memos/memories/textual/tree_text_memory/retrieve/bm25_util.py +186 -0
- memos/memories/textual/tree_text_memory/retrieve/bochasearch.py +419 -0
- memos/memories/textual/tree_text_memory/retrieve/internet_retriever.py +270 -0
- memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py +102 -0
- memos/memories/textual/tree_text_memory/retrieve/reasoner.py +61 -0
- memos/memories/textual/tree_text_memory/retrieve/recall.py +497 -0
- memos/memories/textual/tree_text_memory/retrieve/reranker.py +111 -0
- memos/memories/textual/tree_text_memory/retrieve/retrieval_mid_structs.py +16 -0
- memos/memories/textual/tree_text_memory/retrieve/retrieve_utils.py +472 -0
- memos/memories/textual/tree_text_memory/retrieve/searcher.py +848 -0
- memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py +135 -0
- memos/memories/textual/tree_text_memory/retrieve/utils.py +54 -0
- memos/memories/textual/tree_text_memory/retrieve/xinyusearch.py +387 -0
- memos/memos_tools/dinding_report_bot.py +453 -0
- memos/memos_tools/lockfree_dict.py +120 -0
- memos/memos_tools/notification_service.py +44 -0
- memos/memos_tools/notification_utils.py +142 -0
- memos/memos_tools/singleton.py +174 -0
- memos/memos_tools/thread_safe_dict.py +310 -0
- memos/memos_tools/thread_safe_dict_segment.py +382 -0
- memos/multi_mem_cube/__init__.py +0 -0
- memos/multi_mem_cube/composite_cube.py +86 -0
- memos/multi_mem_cube/single_cube.py +874 -0
- memos/multi_mem_cube/views.py +54 -0
- memos/parsers/__init__.py +0 -0
- memos/parsers/base.py +15 -0
- memos/parsers/factory.py +21 -0
- memos/parsers/markitdown.py +28 -0
- memos/reranker/__init__.py +4 -0
- memos/reranker/base.py +25 -0
- memos/reranker/concat.py +103 -0
- memos/reranker/cosine_local.py +102 -0
- memos/reranker/factory.py +72 -0
- memos/reranker/http_bge.py +324 -0
- memos/reranker/http_bge_strategy.py +327 -0
- memos/reranker/noop.py +19 -0
- memos/reranker/strategies/__init__.py +4 -0
- memos/reranker/strategies/base.py +61 -0
- memos/reranker/strategies/concat_background.py +94 -0
- memos/reranker/strategies/concat_docsource.py +110 -0
- memos/reranker/strategies/dialogue_common.py +109 -0
- memos/reranker/strategies/factory.py +31 -0
- memos/reranker/strategies/single_turn.py +107 -0
- memos/reranker/strategies/singleturn_outmem.py +98 -0
- memos/settings.py +10 -0
- memos/templates/__init__.py +0 -0
- memos/templates/advanced_search_prompts.py +211 -0
- memos/templates/cloud_service_prompt.py +107 -0
- memos/templates/instruction_completion.py +66 -0
- memos/templates/mem_agent_prompts.py +85 -0
- memos/templates/mem_feedback_prompts.py +822 -0
- memos/templates/mem_reader_prompts.py +1096 -0
- memos/templates/mem_reader_strategy_prompts.py +238 -0
- memos/templates/mem_scheduler_prompts.py +626 -0
- memos/templates/mem_search_prompts.py +93 -0
- memos/templates/mos_prompts.py +403 -0
- memos/templates/prefer_complete_prompt.py +735 -0
- memos/templates/tool_mem_prompts.py +139 -0
- memos/templates/tree_reorganize_prompts.py +230 -0
- memos/types/__init__.py +34 -0
- memos/types/general_types.py +151 -0
- memos/types/openai_chat_completion_types/__init__.py +15 -0
- memos/types/openai_chat_completion_types/chat_completion_assistant_message_param.py +56 -0
- memos/types/openai_chat_completion_types/chat_completion_content_part_image_param.py +27 -0
- memos/types/openai_chat_completion_types/chat_completion_content_part_input_audio_param.py +23 -0
- memos/types/openai_chat_completion_types/chat_completion_content_part_param.py +43 -0
- memos/types/openai_chat_completion_types/chat_completion_content_part_refusal_param.py +16 -0
- memos/types/openai_chat_completion_types/chat_completion_content_part_text_param.py +16 -0
- memos/types/openai_chat_completion_types/chat_completion_message_custom_tool_call_param.py +27 -0
- memos/types/openai_chat_completion_types/chat_completion_message_function_tool_call_param.py +32 -0
- memos/types/openai_chat_completion_types/chat_completion_message_param.py +18 -0
- memos/types/openai_chat_completion_types/chat_completion_message_tool_call_union_param.py +15 -0
- memos/types/openai_chat_completion_types/chat_completion_system_message_param.py +36 -0
- memos/types/openai_chat_completion_types/chat_completion_tool_message_param.py +30 -0
- memos/types/openai_chat_completion_types/chat_completion_user_message_param.py +34 -0
- memos/utils.py +123 -0
- memos/vec_dbs/__init__.py +0 -0
- memos/vec_dbs/base.py +117 -0
- memos/vec_dbs/factory.py +23 -0
- memos/vec_dbs/item.py +50 -0
- memos/vec_dbs/milvus.py +654 -0
- memos/vec_dbs/qdrant.py +355 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
INTENT_RECOGNIZING_PROMPT = """
|
|
2
|
+
# User Intent Recognition Task
|
|
3
|
+
|
|
4
|
+
## Role
|
|
5
|
+
You are an advanced intent analysis system that evaluates answer satisfaction and identifies information gaps.
|
|
6
|
+
|
|
7
|
+
## Input Analysis
|
|
8
|
+
You will receive:
|
|
9
|
+
1. User's question list (chronological order)
|
|
10
|
+
2. Current system knowledge (working memory)
|
|
11
|
+
|
|
12
|
+
## Evaluation Criteria
|
|
13
|
+
Consider these satisfaction factors:
|
|
14
|
+
1. Answer completeness (covers all aspects of the question)
|
|
15
|
+
2. Evidence relevance (directly supports the answer)
|
|
16
|
+
3. Detail specificity (contains necessary granularity)
|
|
17
|
+
4. Personalization (tailored to user's context)
|
|
18
|
+
|
|
19
|
+
## Decision Framework
|
|
20
|
+
1. We have enough information (satisfied) ONLY when:
|
|
21
|
+
- All question aspects are addressed
|
|
22
|
+
- Supporting evidence exists in working memory
|
|
23
|
+
- There's no obvious information missing
|
|
24
|
+
|
|
25
|
+
2. We need more information (unsatisfied) if:
|
|
26
|
+
- Any question aspect remains unanswered
|
|
27
|
+
- Evidence is generic/non-specific
|
|
28
|
+
- Personal context is missing
|
|
29
|
+
|
|
30
|
+
## Output Specification
|
|
31
|
+
Return JSON with:
|
|
32
|
+
- "trigger_retrieval": true/false (true if we need more information)
|
|
33
|
+
- "evidences": List of information from our working memory that helps answer the questions
|
|
34
|
+
- "missing_evidences": List of specific types of information we need to answer the questions
|
|
35
|
+
|
|
36
|
+
## Response Format
|
|
37
|
+
{{
|
|
38
|
+
"trigger_retrieval": <boolean>,
|
|
39
|
+
"evidences": [
|
|
40
|
+
"<useful_evidence_1>",
|
|
41
|
+
"<useful_evidence_2>"
|
|
42
|
+
],
|
|
43
|
+
"missing_evidences": [
|
|
44
|
+
"<evidence_type_1>",
|
|
45
|
+
"<evidence_type_2>"
|
|
46
|
+
]
|
|
47
|
+
}}
|
|
48
|
+
|
|
49
|
+
## Evidence Type Examples
|
|
50
|
+
- Personal medical history
|
|
51
|
+
- Recent activity logs
|
|
52
|
+
- Specific measurement data
|
|
53
|
+
- Contextual details about [topic]
|
|
54
|
+
- Temporal information (when something occurred)
|
|
55
|
+
|
|
56
|
+
## Current Task
|
|
57
|
+
User Questions:
|
|
58
|
+
{q_list}
|
|
59
|
+
|
|
60
|
+
Working Memory Contents:
|
|
61
|
+
{working_memory_list}
|
|
62
|
+
|
|
63
|
+
## Required Output
|
|
64
|
+
Please provide your analysis in the specified JSON format:
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
MEMORY_RERANKING_PROMPT = """
|
|
68
|
+
# Memory Reranking Task
|
|
69
|
+
|
|
70
|
+
## Role
|
|
71
|
+
You are an intelligent memory reorganization system. Your primary function is to analyze and optimize the ordering of memory evidence based on relevance to recent user queries.
|
|
72
|
+
|
|
73
|
+
## Task Description
|
|
74
|
+
Reorganize the provided memory evidence list by:
|
|
75
|
+
1. Analyzing the semantic relationship between each evidence item and the user's queries
|
|
76
|
+
2. Calculating relevance scores
|
|
77
|
+
3. Sorting evidence in descending order of relevance
|
|
78
|
+
4. Maintaining all original items (no additions or deletions)
|
|
79
|
+
|
|
80
|
+
## Temporal Priority Rules
|
|
81
|
+
- Query recency matters: Index 0 is the MOST RECENT query
|
|
82
|
+
- Evidence matching recent queries gets higher priority
|
|
83
|
+
- For equal relevance scores: Favor items matching newer queries
|
|
84
|
+
|
|
85
|
+
## Input Format
|
|
86
|
+
- Queries: Recent user questions/requests (list)
|
|
87
|
+
- Current Order: Existing memory sequence (list of strings with indices)
|
|
88
|
+
|
|
89
|
+
## Output Format Requirements
|
|
90
|
+
You MUST output a valid JSON object with EXACTLY the following structure:
|
|
91
|
+
{{
|
|
92
|
+
"new_order": [array_of_integers],
|
|
93
|
+
"reasoning": "string_explanation"
|
|
94
|
+
}}
|
|
95
|
+
|
|
96
|
+
## Important Notes:
|
|
97
|
+
- Only output the JSON object, nothing else
|
|
98
|
+
- Do not include any markdown formatting or code block notation
|
|
99
|
+
- Ensure all brackets and quotes are properly closed
|
|
100
|
+
- The output must be parseable by a JSON parser
|
|
101
|
+
|
|
102
|
+
## Processing Guidelines
|
|
103
|
+
1. Prioritize evidence that:
|
|
104
|
+
- Directly answers query questions
|
|
105
|
+
- Contains exact keyword matches
|
|
106
|
+
- Provides contextual support
|
|
107
|
+
- Shows temporal relevance (newer > older)
|
|
108
|
+
2. For ambiguous cases, maintain original relative ordering
|
|
109
|
+
|
|
110
|
+
## Scoring Priorities (Descending Order)
|
|
111
|
+
1. Direct matches to newer queries
|
|
112
|
+
2. Exact keyword matches in recent queries
|
|
113
|
+
3. Contextual support for recent topics
|
|
114
|
+
4. General relevance to older queries
|
|
115
|
+
|
|
116
|
+
## Example
|
|
117
|
+
Input queries: ["[0] python threading", "[1] data visualization"]
|
|
118
|
+
Input order: ["[0] syntax", "[1] matplotlib", "[2] threading"]
|
|
119
|
+
|
|
120
|
+
Output:
|
|
121
|
+
{{
|
|
122
|
+
"new_order": [2, 1, 0],
|
|
123
|
+
"reasoning": "Threading (2) prioritized for matching newest query, followed by matplotlib (1) for older visualization query"
|
|
124
|
+
}}
|
|
125
|
+
|
|
126
|
+
## Current Task
|
|
127
|
+
Queries: {queries} (recency-ordered)
|
|
128
|
+
Current order: {current_order}
|
|
129
|
+
|
|
130
|
+
Please provide your reorganization:
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
QUERY_KEYWORDS_EXTRACTION_PROMPT = """
|
|
134
|
+
## Role
|
|
135
|
+
You are an intelligent keyword extraction system. Your task is to identify and extract the most important words or short phrases from user queries.
|
|
136
|
+
|
|
137
|
+
## Instructions
|
|
138
|
+
- They have to be single words or short phrases that make sense.
|
|
139
|
+
- Only nouns (naming words) or verbs (action words) are allowed.
|
|
140
|
+
- Don't include stop words (like "the", "is") or adverbs (words that describe verbs, like "quickly").
|
|
141
|
+
- Keep them as the smallest possible units that still have meaning.
|
|
142
|
+
|
|
143
|
+
## Example
|
|
144
|
+
- Input Query: "What breed is Max?"
|
|
145
|
+
- Output Keywords (list of string): ["breed", "Max"]
|
|
146
|
+
|
|
147
|
+
## Current Task
|
|
148
|
+
- Query: {query}
|
|
149
|
+
- Output Format: A Json list of keywords.
|
|
150
|
+
|
|
151
|
+
Answer:
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
MEMORY_FILTERING_PROMPT = """
|
|
155
|
+
# Memory Relevance Filtering Task
|
|
156
|
+
|
|
157
|
+
## Role
|
|
158
|
+
You are an intelligent memory filtering system. Your primary function is to analyze memory relevance and filter out memories that are completely unrelated to the user's query history.
|
|
159
|
+
|
|
160
|
+
## Task Description
|
|
161
|
+
Analyze the provided memories and determine which ones are relevant to the user's query history:
|
|
162
|
+
1. Evaluate semantic relationship between each memory and the query history
|
|
163
|
+
2. Identify memories that are completely unrelated or irrelevant
|
|
164
|
+
3. Filter out memories that don't contribute to answering the queries
|
|
165
|
+
4. Preserve memories that provide context, evidence, or relevant information
|
|
166
|
+
|
|
167
|
+
## Relevance Criteria
|
|
168
|
+
A memory is considered RELEVANT if it:
|
|
169
|
+
- Directly answers questions from the query history
|
|
170
|
+
- Provides context or background information related to the queries
|
|
171
|
+
- Contains information that could be useful for understanding the queries
|
|
172
|
+
- Shares semantic similarity with query topics or themes
|
|
173
|
+
- Contains keywords or concepts mentioned in the queries
|
|
174
|
+
|
|
175
|
+
A memory is considered IRRELEVANT if it:
|
|
176
|
+
- Has no semantic connection to any query in the history
|
|
177
|
+
- Discusses completely unrelated topics
|
|
178
|
+
- Contains information that cannot help answer any query
|
|
179
|
+
- Is too generic or vague to be useful
|
|
180
|
+
|
|
181
|
+
## Input Format
|
|
182
|
+
- Query History: List of user queries (chronological order)
|
|
183
|
+
- Memories: List of memory texts to be evaluated
|
|
184
|
+
|
|
185
|
+
## Output Format Requirements
|
|
186
|
+
You MUST output a valid JSON object with EXACTLY the following structure:
|
|
187
|
+
{{
|
|
188
|
+
"relevant_memories": [array_of_memory_indices],
|
|
189
|
+
"filtered_count": <number_of_filtered_memories>,
|
|
190
|
+
"reasoning": "string_explanation"
|
|
191
|
+
}}
|
|
192
|
+
|
|
193
|
+
## Important Notes:
|
|
194
|
+
- Only output the JSON object, nothing else
|
|
195
|
+
- Do not include any markdown formatting or code block notation
|
|
196
|
+
- Ensure all brackets and quotes are properly closed
|
|
197
|
+
- The output must be parseable by a JSON parser
|
|
198
|
+
- Memory indices should correspond to the input order (0-based)
|
|
199
|
+
|
|
200
|
+
## Processing Guidelines
|
|
201
|
+
1. Be conservative in filtering - when in doubt, keep the memory
|
|
202
|
+
2. Consider both direct and indirect relevance
|
|
203
|
+
3. Look for thematic connections, not just exact keyword matches
|
|
204
|
+
4. Preserve memories that provide valuable context
|
|
205
|
+
|
|
206
|
+
## Current Task
|
|
207
|
+
Query History: {query_history}
|
|
208
|
+
Memories to Filter: {memories}
|
|
209
|
+
|
|
210
|
+
Please provide your filtering analysis:
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
MEMORY_REDUNDANCY_FILTERING_PROMPT = """
|
|
214
|
+
# Memory Redundancy Filtering Task
|
|
215
|
+
|
|
216
|
+
## Role
|
|
217
|
+
You are an intelligent memory optimization system. Your primary function is to analyze memories and remove redundancy to improve memory quality and relevance.
|
|
218
|
+
|
|
219
|
+
## Task Description
|
|
220
|
+
Analyze the provided memories and identify redundant ones:
|
|
221
|
+
1. **Redundancy Detection**: Find memories that contain the same core facts relevant to queries
|
|
222
|
+
2. **Best Memory Selection**: Keep only the most concise and focused version of redundant information
|
|
223
|
+
3. **Quality Preservation**: Ensure the final set covers all necessary information without redundancy
|
|
224
|
+
|
|
225
|
+
## Redundancy Detection Criteria
|
|
226
|
+
A memory is considered REDUNDANT if it:
|
|
227
|
+
- Contains the same core fact as another memory that's relevant to the queries
|
|
228
|
+
- Provides the same information but with additional irrelevant details
|
|
229
|
+
- Repeats information that's already covered by a more concise memory
|
|
230
|
+
- Has overlapping content with another memory that serves the same purpose
|
|
231
|
+
|
|
232
|
+
When redundancy is found, KEEP the memory that:
|
|
233
|
+
- Is more concise and focused
|
|
234
|
+
- Contains less irrelevant information
|
|
235
|
+
- Is more directly relevant to the queries
|
|
236
|
+
- Has higher information density
|
|
237
|
+
|
|
238
|
+
## Input Format
|
|
239
|
+
- Query History: List of user queries (chronological order)
|
|
240
|
+
- Memories: List of memory texts to be evaluated
|
|
241
|
+
|
|
242
|
+
## Output Format Requirements
|
|
243
|
+
You MUST output a valid JSON object with EXACTLY the following structure:
|
|
244
|
+
{{
|
|
245
|
+
"kept_memories": [array_of_memory_indices_to_keep],
|
|
246
|
+
"redundant_groups": [
|
|
247
|
+
{{
|
|
248
|
+
"group_id": <number>,
|
|
249
|
+
"memories": [array_of_redundant_memory_indices],
|
|
250
|
+
"kept_memory": <index_of_best_memory_in_group>,
|
|
251
|
+
"reason": "explanation_of_why_this_memory_was_kept"
|
|
252
|
+
}}
|
|
253
|
+
],
|
|
254
|
+
"reasoning": "string_explanation_of_filtering_decisions"
|
|
255
|
+
}}
|
|
256
|
+
|
|
257
|
+
## Important Notes:
|
|
258
|
+
- Only output the JSON object, nothing else
|
|
259
|
+
- Do not include any markdown formatting or code block notation
|
|
260
|
+
- Ensure all brackets and quotes are properly closed
|
|
261
|
+
- The output must be parseable by a JSON parser
|
|
262
|
+
- Memory indices should correspond to the input order (0-based)
|
|
263
|
+
- Be conservative in filtering - when in doubt, keep the memory
|
|
264
|
+
- Focus on semantic similarity, not just exact text matches
|
|
265
|
+
|
|
266
|
+
## Processing Guidelines
|
|
267
|
+
1. First identify which memories are relevant to the queries
|
|
268
|
+
2. Group relevant memories by semantic similarity and core facts
|
|
269
|
+
3. Within each group, select the best memory (most concise, least noise)
|
|
270
|
+
4. Ensure the final set covers all necessary information without redundancy
|
|
271
|
+
|
|
272
|
+
## Current Task
|
|
273
|
+
Query History: {query_history}
|
|
274
|
+
Memories to Filter: {memories}
|
|
275
|
+
|
|
276
|
+
Please provide your redundancy filtering analysis:
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
MEMORY_COMBINED_FILTERING_PROMPT = """
|
|
280
|
+
# Memory Combined Filtering Task
|
|
281
|
+
|
|
282
|
+
## Role
|
|
283
|
+
You are an intelligent memory optimization system. Your primary function is to analyze memories and perform two types of filtering in sequence:
|
|
284
|
+
1. **Unrelated Memory Removal**: Remove memories that are completely unrelated to the user's query history
|
|
285
|
+
2. **Redundancy Removal**: Remove redundant memories by keeping only the most informative version
|
|
286
|
+
|
|
287
|
+
## Task Description
|
|
288
|
+
Analyze the provided memories and perform comprehensive filtering:
|
|
289
|
+
1. **First Step - Unrelated Filtering**: Identify and remove memories that have no semantic connection to any query
|
|
290
|
+
2. **Second Step - Redundancy Filtering**: Group similar memories and keep only the best version from each group
|
|
291
|
+
|
|
292
|
+
## Unrelated Memory Detection Criteria
|
|
293
|
+
A memory is considered UNRELATED if it:
|
|
294
|
+
- Has no semantic connection to any query in the history
|
|
295
|
+
- Discusses completely unrelated topics
|
|
296
|
+
- Contains information that cannot help answer any query
|
|
297
|
+
- Is too generic or vague to be useful
|
|
298
|
+
|
|
299
|
+
## Redundancy Detection Criteria
|
|
300
|
+
A memory is considered REDUNDANT if it:
|
|
301
|
+
- Contains the same core fact as another memory that's relevant to the queries
|
|
302
|
+
- Provides the same information but with additional irrelevant details
|
|
303
|
+
- Repeats information that's already covered by a more concise memory
|
|
304
|
+
- Has overlapping content with another memory that serves the same purpose
|
|
305
|
+
|
|
306
|
+
When redundancy is found, KEEP the memory that:
|
|
307
|
+
- Is more concise and focused
|
|
308
|
+
- Contains less irrelevant information
|
|
309
|
+
- Is more directly relevant to the queries
|
|
310
|
+
- Has higher information density
|
|
311
|
+
|
|
312
|
+
## Input Format
|
|
313
|
+
- Query History: List of user queries (chronological order)
|
|
314
|
+
- Memories: List of memory texts to be evaluated
|
|
315
|
+
|
|
316
|
+
## Output Format Requirements
|
|
317
|
+
You MUST output a valid JSON object with EXACTLY the following structure:
|
|
318
|
+
{{
|
|
319
|
+
"kept_memories": [array_of_memory_indices_to_keep],
|
|
320
|
+
"unrelated_removed_count": <number_of_unrelated_memories_removed>,
|
|
321
|
+
"redundant_removed_count": <number_of_redundant_memories_removed>,
|
|
322
|
+
"redundant_groups": [
|
|
323
|
+
{{
|
|
324
|
+
"group_id": <number>,
|
|
325
|
+
"memories": [array_of_redundant_memory_indices],
|
|
326
|
+
"kept_memory": <index_of_best_memory_in_group>,
|
|
327
|
+
"reason": "explanation_of_why_this_memory_was_kept"
|
|
328
|
+
}}
|
|
329
|
+
],
|
|
330
|
+
"reasoning": "string_explanation_of_filtering_decisions"
|
|
331
|
+
}}
|
|
332
|
+
|
|
333
|
+
## Important Notes:
|
|
334
|
+
- Only output the JSON object, nothing else
|
|
335
|
+
- Do not include any markdown formatting or code block notation
|
|
336
|
+
- Ensure all brackets and quotes are properly closed
|
|
337
|
+
- The output must be parseable by a JSON parser
|
|
338
|
+
- Memory indices should correspond to the input order (0-based)
|
|
339
|
+
- Be conservative in filtering - when in doubt, keep the memory
|
|
340
|
+
- Focus on semantic similarity, not just exact text matches
|
|
341
|
+
|
|
342
|
+
## Processing Guidelines
|
|
343
|
+
1. **First, identify unrelated memories** and mark them for removal
|
|
344
|
+
2. **Then, group remaining memories** by semantic similarity and core facts
|
|
345
|
+
3. **Within each group, select the best memory** (most concise, least noise)
|
|
346
|
+
4. **Ensure the final set covers all necessary information** without redundancy
|
|
347
|
+
5. **Count how many memories were removed** for each reason
|
|
348
|
+
|
|
349
|
+
## Current Task
|
|
350
|
+
Query History: {query_history}
|
|
351
|
+
Memories to Filter: {memories}
|
|
352
|
+
|
|
353
|
+
Please provide your combined filtering analysis:
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
MEMORY_ANSWER_ABILITY_EVALUATION_PROMPT = """
|
|
358
|
+
# Memory Answer Ability Evaluation Task
|
|
359
|
+
|
|
360
|
+
## Task
|
|
361
|
+
Evaluate whether the provided memories contain sufficient information to answer the user's query.
|
|
362
|
+
|
|
363
|
+
## Evaluation Criteria
|
|
364
|
+
Consider these factors:
|
|
365
|
+
1. **Answer completeness**: Do the memories cover all aspects of the query?
|
|
366
|
+
2. **Evidence relevance**: Do the memories directly support answering the query?
|
|
367
|
+
3. **Detail specificity**: Do the memories contain necessary granularity?
|
|
368
|
+
4. **Information gaps**: Are there obvious missing pieces of information?
|
|
369
|
+
|
|
370
|
+
## Decision Rules
|
|
371
|
+
- Return `True` for "result" ONLY when memories provide complete, relevant answers
|
|
372
|
+
- Return `False` for "result" if memories are insufficient, irrelevant, or incomplete
|
|
373
|
+
|
|
374
|
+
## User Query
|
|
375
|
+
{query}
|
|
376
|
+
|
|
377
|
+
## Available Memories
|
|
378
|
+
{memory_list}
|
|
379
|
+
|
|
380
|
+
## Required Output
|
|
381
|
+
Return a JSON object with this exact structure:
|
|
382
|
+
{{
|
|
383
|
+
"result": <boolean>,
|
|
384
|
+
"reason": "<brief explanation of your decision>"
|
|
385
|
+
}}
|
|
386
|
+
|
|
387
|
+
## Instructions
|
|
388
|
+
- Only output the JSON object, nothing else
|
|
389
|
+
- Be conservative: if there's any doubt about completeness, return true
|
|
390
|
+
- Focus on whether the memories can fully answer the query without additional information
|
|
391
|
+
"""
|
|
392
|
+
|
|
393
|
+
MEMORY_RECREATE_ENHANCEMENT_PROMPT = """
|
|
394
|
+
You are a knowledgeable and precise AI assistant.
|
|
395
|
+
|
|
396
|
+
# GOAL
|
|
397
|
+
Transform raw memories into clean, complete, and fully disambiguated statements that preserve original meaning and explicit details.
|
|
398
|
+
|
|
399
|
+
# RULES & THINKING STEPS
|
|
400
|
+
1. Preserve ALL explicit timestamps (e.g., “on October 6”, “daily”).
|
|
401
|
+
2. Resolve all ambiguities using only memory content. If disambiguation cannot be performed using only the provided memories, retain the original phrasing exactly as written. Never guess, infer, or fabricate missing information:
|
|
402
|
+
- Pronouns → full name (e.g., “she” → “Caroline”)
|
|
403
|
+
- Relative time expressions → concrete dates or full context (e.g., “last night” → “on the evening of November 25, 2025”)
|
|
404
|
+
- Vague references → specific, grounded details (e.g., “the event” → “the LGBTQ+ art workshop in Malmö”)
|
|
405
|
+
- Incomplete descriptions → full version from memory (e.g., “the activity” → “the abstract painting session at the community center”)
|
|
406
|
+
3. Merge memories that are largely repetitive in content but contain complementary or distinct details. Combine them into a single, cohesive statement that preserves all unique information from each original memory. Do not merge memories that describe different events, even if they share a theme.
|
|
407
|
+
4. Keep ONLY what’s relevant to the user’s query. Delete irrelevant memories entirely.
|
|
408
|
+
|
|
409
|
+
# OUTPUT FORMAT (STRICT)
|
|
410
|
+
Return ONLY the following block, with **one enhanced memory per line**.
|
|
411
|
+
Each line MUST start with "- " (dash + space).
|
|
412
|
+
|
|
413
|
+
Wrap the final output inside:
|
|
414
|
+
<answer>
|
|
415
|
+
- enhanced memory 1
|
|
416
|
+
- enhanced memory 2
|
|
417
|
+
...
|
|
418
|
+
</answer>
|
|
419
|
+
|
|
420
|
+
## User Query
|
|
421
|
+
{query_history}
|
|
422
|
+
|
|
423
|
+
## Original Memories
|
|
424
|
+
{memories}
|
|
425
|
+
|
|
426
|
+
Final Output:
|
|
427
|
+
"""
|
|
428
|
+
|
|
429
|
+
MEMORY_RECREATE_ENHANCEMENT_PROMPT_BACKUP_1 = """
|
|
430
|
+
You are a knowledgeable and precise AI assistant.
|
|
431
|
+
|
|
432
|
+
# GOAL
|
|
433
|
+
Transform raw memories into clean, complete, and fully disambiguated statements that preserve original meaning and explicit details.
|
|
434
|
+
|
|
435
|
+
# RULES & THINKING STEPS
|
|
436
|
+
1. Preserve ALL explicit timestamps (e.g., “on October 6”, “daily”).
|
|
437
|
+
2. Resolve all ambiguities using only memory content. If disambiguation cannot be performed using only the provided memories, retain the original phrasing exactly as written. Never guess, infer, or fabricate missing information:
|
|
438
|
+
- Pronouns → full name (e.g., “she” → “Caroline”)
|
|
439
|
+
- Relative time expressions → concrete dates or full context (e.g., “last night” → “on the evening of November 25, 2025”)
|
|
440
|
+
- Vague references → specific, grounded details (e.g., “the event” → “the LGBTQ+ art workshop in Malmö”)
|
|
441
|
+
- Incomplete descriptions → full version from memory (e.g., “the activity” → “the abstract painting session at the community center”)
|
|
442
|
+
3. Merge memories that are largely repetitive in content but contain complementary or distinct details. Combine them into a single, cohesive statement that preserves all unique information from each original memory. Do not merge memories that describe different events, even if they share a theme.
|
|
443
|
+
4. Keep ONLY what’s relevant to the user’s query. Delete irrelevant memories entirely.
|
|
444
|
+
|
|
445
|
+
# OUTPUT FORMAT (STRICT)
|
|
446
|
+
Return ONLY the following block, with **one enhanced memory per line**.
|
|
447
|
+
Each line MUST start with "- " (dash + space).
|
|
448
|
+
|
|
449
|
+
Wrap the final output inside:
|
|
450
|
+
<answer>
|
|
451
|
+
- enhanced memory 1
|
|
452
|
+
- enhanced memory 2
|
|
453
|
+
...
|
|
454
|
+
</answer>
|
|
455
|
+
|
|
456
|
+
## User Query
|
|
457
|
+
{query_history}
|
|
458
|
+
|
|
459
|
+
## Original Memories
|
|
460
|
+
{memories}
|
|
461
|
+
|
|
462
|
+
Final Output:
|
|
463
|
+
"""
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
MEMORY_RECREATE_ENHANCEMENT_PROMPT_BACKUP_2 = """
|
|
467
|
+
You are a knowledgeable and precise AI assistant.
|
|
468
|
+
|
|
469
|
+
# GOAL
|
|
470
|
+
Transform raw memories into clean, query-relevant facts — preserving timestamps and resolving ambiguities without inference.
|
|
471
|
+
|
|
472
|
+
# RULES & THINKING STEPS
|
|
473
|
+
1. Keep ONLY what’s relevant to the user’s query. Delete irrelevant memories entirely.
|
|
474
|
+
2. Preserve ALL explicit timestamps (e.g., “on October 6”, “daily”, “after injury”).
|
|
475
|
+
3. Resolve all ambiguities using only memory content:
|
|
476
|
+
- Pronouns → full name: “she” → “Melanie”
|
|
477
|
+
- Vague nouns → specific detail: “home” → “her childhood home in Guangzhou”
|
|
478
|
+
- “the user” → identity from context (e.g., “Melanie” if travel/running memories)
|
|
479
|
+
4. Never invent, assume, or extrapolate.
|
|
480
|
+
5. Each output line must be a standalone, clear, factual statement.
|
|
481
|
+
6. Output format: one line per fact, starting with "- ", no extra text.
|
|
482
|
+
|
|
483
|
+
# OUTPUT FORMAT (STRICT)
|
|
484
|
+
Return ONLY the following block, with **one enhanced memory per line**.
|
|
485
|
+
Each line MUST start with "- " (dash + space).
|
|
486
|
+
|
|
487
|
+
Wrap the final output inside:
|
|
488
|
+
<answer>
|
|
489
|
+
- enhanced memory 1
|
|
490
|
+
- enhanced memory 2
|
|
491
|
+
...
|
|
492
|
+
</answer>
|
|
493
|
+
|
|
494
|
+
## User Query
|
|
495
|
+
{query_history}
|
|
496
|
+
|
|
497
|
+
## Original Memories
|
|
498
|
+
{memories}
|
|
499
|
+
|
|
500
|
+
Final Output:
|
|
501
|
+
"""
|
|
502
|
+
|
|
503
|
+
MEMORY_REWRITE_ENHANCEMENT_PROMPT = """
|
|
504
|
+
You are a knowledgeable and precise AI assistant.
|
|
505
|
+
|
|
506
|
+
# GOAL
|
|
507
|
+
Transform raw memories into clean, query-relevant facts — preserving timestamps and resolving ambiguities without inference. Return each enhanced fact with the ID of the original memory being modified.
|
|
508
|
+
|
|
509
|
+
# RULES & THINKING STEPS
|
|
510
|
+
1. Keep ONLY what’s relevant to the user’s query. Delete irrelevant memories entirely.
|
|
511
|
+
2. Preserve ALL explicit timestamps (e.g., “on October 6”, “daily”, “after injury”).
|
|
512
|
+
3. Resolve all ambiguities using only memory content:
|
|
513
|
+
- Pronouns → full name: “she” → “Melanie”
|
|
514
|
+
- Vague nouns → specific detail: “home” → “her childhood home in Guangzhou”
|
|
515
|
+
- “the user” → identity from context (e.g., “Melanie” if travel/running memories)
|
|
516
|
+
4. Never invent, assume, or extrapolate.
|
|
517
|
+
5. Each output line must be a standalone, clear, factual statement.
|
|
518
|
+
6. Output format: one line per fact, starting with "- ", no extra text.
|
|
519
|
+
|
|
520
|
+
# IMPORTANT FOR REWRITE
|
|
521
|
+
- Each output line MUST include the original memory’s ID shown in the input list.
|
|
522
|
+
- Use the index shown for each original memory (e.g., "[0]", "[1]") as the ID to reference which memory you are rewriting.
|
|
523
|
+
- For every rewritten line, prefix with the corresponding index in square brackets.
|
|
524
|
+
|
|
525
|
+
# OUTPUT FORMAT (STRICT)
|
|
526
|
+
Return ONLY the following block, with **one enhanced memory per line**.
|
|
527
|
+
Each line MUST start with "- " (dash + space) AND include index in square brackets.
|
|
528
|
+
|
|
529
|
+
Wrap the final output inside:
|
|
530
|
+
<answer>
|
|
531
|
+
- [index] enhanced memory 1
|
|
532
|
+
- [index] enhanced memory 2
|
|
533
|
+
...
|
|
534
|
+
</answer>
|
|
535
|
+
|
|
536
|
+
## User Query
|
|
537
|
+
{query_history}
|
|
538
|
+
|
|
539
|
+
## Original Memories
|
|
540
|
+
{memories}
|
|
541
|
+
|
|
542
|
+
Final Output:
|
|
543
|
+
"""
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
# One-sentence prompt for recalling missing information to answer the query (English)
|
|
547
|
+
ENLARGE_RECALL_PROMPT_ONE_SENTENCE = """
|
|
548
|
+
You are a precise AI assistant. Your job is to analyze the user's query and the available memories to identify what specific information is missing to fully answer the query.
|
|
549
|
+
|
|
550
|
+
# GOAL
|
|
551
|
+
Identify the specific missing facts needed to fully answer the user's query and generate a concise hint for recalling them.
|
|
552
|
+
|
|
553
|
+
# RULES
|
|
554
|
+
- Analyze the user's query to understand what information is being asked.
|
|
555
|
+
- Review the available memories to see what information is already present.
|
|
556
|
+
- Identify the gap between the user's query and the available memories.
|
|
557
|
+
- Generate a single, concise hint that prompts the user to provide the missing information.
|
|
558
|
+
- The hint should be a direct question or a statement that clearly indicates what is needed.
|
|
559
|
+
|
|
560
|
+
# OUTPUT FORMAT
|
|
561
|
+
A JSON object with:
|
|
562
|
+
|
|
563
|
+
trigger_retrieval: true if information is missing, false if sufficient.
|
|
564
|
+
hint: A clear, specific prompt to retrieve the missing information (or an empty string if trigger_retrieval is false):
|
|
565
|
+
{{
|
|
566
|
+
"trigger_recall": <boolean>,
|
|
567
|
+
"hint": a paraphrase to retrieve support memories
|
|
568
|
+
}}
|
|
569
|
+
|
|
570
|
+
## User Query
|
|
571
|
+
{query}
|
|
572
|
+
|
|
573
|
+
## Available Memories
|
|
574
|
+
{memories_inline}
|
|
575
|
+
|
|
576
|
+
Final Output:
|
|
577
|
+
"""
|
|
578
|
+
|
|
579
|
+
ENLARGE_RECALL_PROMPT_ONE_SENTENCE_BACKUP = """
|
|
580
|
+
You are a precise AI assistant. Your job is to analyze the user's query and the available memories to identify what specific information is missing to fully answer the query.
|
|
581
|
+
|
|
582
|
+
# GOAL
|
|
583
|
+
|
|
584
|
+
Identify the specific missing facts needed to fully answer the user's query and generate a concise hint for recalling them.
|
|
585
|
+
|
|
586
|
+
# RULES
|
|
587
|
+
|
|
588
|
+
- Analyze the user's query to understand what information is being asked.
|
|
589
|
+
- Review the available memories to see what information is already present.
|
|
590
|
+
- Identify the gap between the user's query and the available memories.
|
|
591
|
+
- Generate a single, concise hint that prompts the user to provide the missing information.
|
|
592
|
+
- The hint should be a direct question or a statement that clearly indicates what is needed.
|
|
593
|
+
|
|
594
|
+
# OUTPUT FORMAT
|
|
595
|
+
A JSON object with:
|
|
596
|
+
|
|
597
|
+
trigger_retrieval: true if information is missing, false if sufficient.
|
|
598
|
+
hint: A clear, specific prompt to retrieve the missing information (or an empty string if trigger_retrieval is false):
|
|
599
|
+
{{
|
|
600
|
+
"trigger_recall": <boolean>,
|
|
601
|
+
"hint": a paraphrase to retrieve support memories
|
|
602
|
+
}}
|
|
603
|
+
|
|
604
|
+
## User Query
|
|
605
|
+
{query}
|
|
606
|
+
|
|
607
|
+
## Available Memories
|
|
608
|
+
{memories_inline}
|
|
609
|
+
|
|
610
|
+
Final Output:
|
|
611
|
+
"""
|
|
612
|
+
|
|
613
|
+
PROMPT_MAPPING = {
|
|
614
|
+
"intent_recognizing": INTENT_RECOGNIZING_PROMPT,
|
|
615
|
+
"memory_reranking": MEMORY_RERANKING_PROMPT,
|
|
616
|
+
"query_keywords_extraction": QUERY_KEYWORDS_EXTRACTION_PROMPT,
|
|
617
|
+
"memory_filtering": MEMORY_FILTERING_PROMPT,
|
|
618
|
+
"memory_redundancy_filtering": MEMORY_REDUNDANCY_FILTERING_PROMPT,
|
|
619
|
+
"memory_combined_filtering": MEMORY_COMBINED_FILTERING_PROMPT,
|
|
620
|
+
"memory_answer_ability_evaluation": MEMORY_ANSWER_ABILITY_EVALUATION_PROMPT,
|
|
621
|
+
"memory_recreate_enhancement": MEMORY_RECREATE_ENHANCEMENT_PROMPT,
|
|
622
|
+
"memory_rewrite_enhancement": MEMORY_REWRITE_ENHANCEMENT_PROMPT,
|
|
623
|
+
"enlarge_recall": ENLARGE_RECALL_PROMPT_ONE_SENTENCE,
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
MEMORY_ASSEMBLY_TEMPLATE = """The retrieved memories are listed as follows:\n\n {memory_text}"""
|