-
Notifications
You must be signed in to change notification settings - Fork 487
fix: modify bug in skill memory #1060
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -486,7 +486,7 @@ def _extract_skill_memory_by_llm_md( | |
| seen_messages = set() | ||
|
|
||
| for mem in old_memories_dict: | ||
| if mem["metadata"]["memory_type"] == "SkillMemory" and mem["metadata"]["relativity"] > 0.02: | ||
| if mem["metadata"]["memory_type"] == "SkillMemory": | ||
| old_skill_content.append( | ||
| { | ||
| "id": mem["id"], | ||
|
|
@@ -524,19 +524,21 @@ def _extract_skill_memory_by_llm_md( | |
| ) | ||
| chat_history_context = chat_history_context[-chat_history_max_length:] | ||
|
|
||
| # Prepare prompt | ||
| lang = detect_lang(messages_context) | ||
|
|
||
| # Prepare old memories context | ||
| old_skill_content = ( | ||
| ("Exsit Skill Schemas: \n" + json.dumps(old_skill_content, ensure_ascii=False, indent=2)) | ||
| "已有技能列表: \n" if lang == "zh" else "Exsit Skill Schemas: \n" + | ||
| json.dumps(old_skill_content, ensure_ascii=False, indent=2) | ||
| if old_skill_content | ||
| else "" | ||
| ) | ||
|
|
||
| old_memories_context = "Relavant Context:\n" + "\n".join( | ||
| old_memories_context = "相关历史对话:\n" if lang == "zh" else "Relavant Context:\n" + "\n".join( | ||
| [f"{k}:\n{v}" for k, v in old_memories_context.items()] | ||
|
Comment on lines
+532
to
539
|
||
| ) | ||
|
Comment on lines
+538
to
540
|
||
|
|
||
| # Prepare prompt | ||
| lang = detect_lang(messages_context) | ||
| template = ( | ||
| SKILL_MEMORY_EXTRACTION_PROMPT_MD_ZH if lang == "zh" else SKILL_MEMORY_EXTRACTION_PROMPT_MD | ||
| ) | ||
|
|
@@ -570,6 +572,10 @@ def _extract_skill_memory_by_llm_md( | |
| "[PROCESS_SKILLS] No skill memory extracted from conversation (LLM returned null)" | ||
| ) | ||
| return None | ||
| # If no old skill content, set update to False (for llm hallucination) | ||
| if not old_skill_content: | ||
| skill_memory["old_memory_id"] = '' | ||
| skill_memory["update"] = False | ||
|
Comment on lines
+575
to
+578
|
||
|
|
||
| return skill_memory | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional expression building
old_skill_contentis parsed such that whenlang == "zh"it always returns only the header ("已有技能列表") and never appends the JSON payload (and it will even return the header when the skill list is empty). Restructure this so the language-specific header is combined withjson.dumps(...)only when the original skill list is non-empty (e.g., compute aheaderfirst, thenheader + dumps), otherwise use an empty string.