mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-15 07:22:44 +00:00
refactor: increase memory recall limit and improve formatting
- Updated memory recall limit from 5 to 10 in the Agent class to enhance memory retrieval capabilities. - Improved formatting of memory output by changing the join method to use double newlines for better readability in multiple locations.
This commit is contained in:
@@ -384,9 +384,9 @@ class Agent(BaseAgent):
|
||||
)
|
||||
if unified_memory is not None:
|
||||
query = task.description
|
||||
matches = unified_memory.recall(query, limit=5)
|
||||
matches = unified_memory.recall(query, limit=10)
|
||||
if matches:
|
||||
memory = "Relevant memories:\n" + "\n".join(
|
||||
memory = "Relevant memories:\n" + "\n\n".join(
|
||||
m.format() for m in matches
|
||||
)
|
||||
if memory.strip() != "":
|
||||
@@ -1811,10 +1811,10 @@ class Agent(BaseAgent):
|
||||
),
|
||||
)
|
||||
start_time = time.time()
|
||||
matches = agent_memory.recall(formatted_messages, limit=5)
|
||||
matches = agent_memory.recall(formatted_messages, limit=10)
|
||||
memory_block = ""
|
||||
if matches:
|
||||
memory_block = "Relevant memories:\n" + "\n".join(
|
||||
memory_block = "Relevant memories:\n" + "\n\n".join(
|
||||
m.format() for m in matches
|
||||
)
|
||||
if memory_block:
|
||||
|
||||
@@ -100,7 +100,11 @@ class MemoryMatch(BaseModel):
|
||||
if self.record.metadata:
|
||||
for key, value in self.record.metadata.items():
|
||||
if value:
|
||||
lines.append(f" {key}: {value}")
|
||||
if isinstance(value, list):
|
||||
rendered_value = ", ".join(str(item) for item in value)
|
||||
else:
|
||||
rendered_value = str(value)
|
||||
lines.append(f" {key}: {rendered_value}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class RecallMemoryTool(BaseTool):
|
||||
|
||||
if not all_lines:
|
||||
return "No relevant memories found."
|
||||
return "Found memories:\n" + "\n".join(all_lines)
|
||||
return "Found memories:\n" + "\n\n".join(all_lines)
|
||||
|
||||
|
||||
class RememberSchema(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user