Commit Graph
4 Commits
Author SHA1 Message Date
anishamahuli 99797a183b Add unit tests for normalize_facts covering all LLM fact shapes
Tests plain strings, {"fact": ...}, {"text": ...}, mixed lists,
and empty string filtering.
2026-03-05 12:19:40 -05:00
anishamahuli 206ec3531d Wire normalize_facts into sync and async fact extraction paths
After parsing LLM JSON response, normalize facts before passing them
to the embedding model. Fixes 'list'/'dict' object has no attribute
'replace' when smaller LLMs return malformed fact objects.
2026-03-05 12:16:35 -05:00
anishamahuli 3ae1120403 Add normalize_facts() utility for malformed LLM fact extraction output
Port of TypeScript FactRetrievalSchema to Python.
Normalizes facts that smaller LLMs return as {"fact": "..."} or
{"text": "..."} objects back into plain strings before embedding.
2026-03-05 12:12:53 -05:00
anishamahuli b3ec0978d3 Add reproduction test for infer=true AttributeError on malformed LLM facts
When smaller LLMs return facts as objects ({"fact": "..."}) instead of
plain strings, embedding_model.embed() crashes with
'dict' object has no attribute 'replace'. This test confirms the bug
by mocking the LLM to return dict-shaped facts and asserting the
failure at mem0/memory/main.py:473.
2026-03-05 11:41:30 -05:00