Fix Extra planning (#362)

* fix Extra planning
This commit is contained in:
BUI Van Tuan 2025-01-28 09:21:58 +01:00 committed by GitHub
parent 68f3da12ea
commit 3b5c99e87a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 13 deletions

View File

@ -265,14 +265,14 @@ class MultiStepAgent:
elif isinstance(step_log, PlanningStep):
thought_message = {
"role": MessageRole.ASSISTANT,
"content": "[FACTS LIST]:\n" + step_log.facts.strip(),
"content": [{"type": "text", "text": "[FACTS LIST]:\n" + step_log.facts.strip()}],
}
memory.append(thought_message)
if not summary_mode:
thought_message = {
"role": MessageRole.ASSISTANT,
"content": "[PLAN]:\n" + step_log.plan.strip(),
"content": [{"type": "text", "text": "[PLAN]:\n" + step_log.plan.strip()}],
}
memory.append(thought_message)
@ -700,22 +700,25 @@ Now begin!""",
# Redact updated facts
facts_update_system_prompt = {
"role": MessageRole.SYSTEM,
"content": SYSTEM_PROMPT_FACTS_UPDATE,
"content": [{"type": "text", "text": SYSTEM_PROMPT_FACTS_UPDATE}],
}
facts_update_message = {
"role": MessageRole.USER,
"content": USER_PROMPT_FACTS_UPDATE,
"content": [{"type": "text", "text": USER_PROMPT_FACTS_UPDATE}],
}
facts_update = self.model([facts_update_system_prompt] + agent_memory + [facts_update_message]).content
# Redact updated plan
plan_update_message = {
"role": MessageRole.SYSTEM,
"content": SYSTEM_PROMPT_PLAN_UPDATE.format(task=task),
"content": [{"type": "text", "text": SYSTEM_PROMPT_PLAN_UPDATE.format(task=task)}],
}
plan_update_message_user = {
"role": MessageRole.USER,
"content": USER_PROMPT_PLAN_UPDATE.format(
"content": [
{
"type": "text",
"text": USER_PROMPT_PLAN_UPDATE.format(
task=task,
tool_descriptions=get_tool_descriptions(self.tools, self.tool_description_template),
managed_agents_descriptions=(show_agents_descriptions(self.managed_agents)),
@ -723,6 +726,8 @@ Now begin!""",
remaining_steps=(self.max_steps - step),
),
}
],
}
plan_update = self.model(
[plan_update_message] + agent_memory + [plan_update_message_user],
stop_sequences=["<end_plan>"],

View File

@ -433,7 +433,7 @@ Now begin! Write your plan below."""
SYSTEM_PROMPT_FACTS_UPDATE = """
You are a world expert at gathering known and unknown facts based on a conversation.
Below you will find a task, and ahistory of attempts made to solve the task. You will have to produce a list of these:
Below you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:
### 1. Facts given in the task
### 2. Facts that we have learned
### 3. Facts still to look up