fix: remove dead code, fix JSON parsing, add facts validation
This commit is contained in:
@@ -58,13 +58,9 @@ class Mem0MemoryStore:
|
||||
if key in raw_config:
|
||||
mem0_cfg_dict[key] = raw_config[key]
|
||||
logger.debug(f"Extracted for MemoryConfig: {list(mem0_cfg_dict.keys())}")
|
||||
logger.debug(f"Custom prompt length: {len(custom_prompt)} chars")
|
||||
mem0_cfg_dict["custom_fact_extraction_prompt"] = custom_prompt
|
||||
mem0_config = MemoryConfig(**mem0_cfg_dict)
|
||||
logger.debug(f"MemoryConfig created: vector_store={mem0_config.vector_store.provider if mem0_config.vector_store else None}")
|
||||
logger.debug(f"MemoryConfig.custom_fact_extraction_prompt is None: {mem0_config.custom_fact_extraction_prompt is None}")
|
||||
self.memory = Memory(config=mem0_config)
|
||||
logger.debug(f"Memory.config.custom_fact_extraction_prompt is None: {self.memory.config.custom_fact_extraction_prompt is None}")
|
||||
|
||||
logger.info("Mem0 memory system initialized with custom nanobot prompt")
|
||||
|
||||
@@ -187,8 +183,12 @@ class Mem0MemoryStore:
|
||||
text = text.split("```")[1]
|
||||
if text.startswith("json"):
|
||||
text = text[4:]
|
||||
text = text.strip()
|
||||
data = _json.loads(text)
|
||||
facts = data.get("facts", [])
|
||||
if not isinstance(facts, list):
|
||||
logger.warning(f"LLM returned non-list facts: {type(facts)}")
|
||||
return []
|
||||
logger.debug(f"Extracted {len(facts)} facts using {model}")
|
||||
return facts
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user