[ Fix ]TypeError when using Chat completion (#1922)
This commit is contained in:
@@ -6,6 +6,8 @@ from typing import List, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
import mem0
|
||||
|
||||
try:
|
||||
import litellm
|
||||
except ImportError:
|
||||
@@ -178,5 +180,10 @@ class Completions:
|
||||
)
|
||||
|
||||
def _format_query_with_memories(self, messages, relevant_memories):
|
||||
memories_text = "\n".join(memory["memory"] for memory in relevant_memories)
|
||||
# Check if self.mem0_client is an instance of Memory or MemoryClient
|
||||
|
||||
if isinstance(self.mem0_client, mem0.memory.main.Memory):
|
||||
memories_text = "\n".join(memory["memory"] for memory in relevant_memories['results'])
|
||||
elif isinstance(self.mem0_client, mem0.client.main.MemoryClient):
|
||||
memories_text = "\n".join(memory["memory"] for memory in relevant_memories)
|
||||
return f"- Relevant Memories/Facts: {memories_text}\n\n- User Question: {messages[-1]['content']}"
|
||||
|
||||
Reference in New Issue
Block a user