fix: rename loop variable to avoid shadowing Memory object

Fixes #449

The loop variable 'memory' in the memory iteration was shadowing the
Memory object from mem0, causing 'AttributeError: dict object has no
attribute add' when memory.add() was called later.

Renamed to 'mem' to match the pattern already used in other parts of
the codebase.

Affected files:
- ai_travel_agent_memory/travel_agent_memory.py
- multi_llm_memory/multi_llm_memory.py
This commit is contained in:
awesomekoder
2026-01-31 20:14:28 -08:00
parent f1f9794fbe
commit e2dc13fb21
2 changed files with 6 additions and 6 deletions

View File

@@ -70,9 +70,9 @@ if openai_api_key:
relevant_memories = memory.search(query=prompt, user_id=user_id)
context = "Relevant past information:\n"
if relevant_memories and "results" in relevant_memories:
for memory in relevant_memories["results"]:
if "memory" in memory:
context += f"- {memory['memory']}\n"
for mem in relevant_memories["results"]:
if "memory" in mem:
context += f"- {mem['memory']}\n"
# Prepare the full prompt
full_prompt = f"{context}\nHuman: {prompt}\nAI:"

View File

@@ -51,9 +51,9 @@ if openai_api_key and anthropic_api_key:
relevant_memories = memory.search(query=prompt, user_id=user_id)
context = "Relevant past information:\n"
if relevant_memories and "results" in relevant_memories:
for memory in relevant_memories["results"]:
if "memory" in memory:
context += f"- {memory['memory']}\n"
for mem in relevant_memories["results"]:
if "memory" in mem:
context += f"- {mem['memory']}\n"
full_prompt = f"{context}\nHuman: {prompt}\nAI:"