fix : planner agent bug

This commit is contained in:
martin legrand
2025-04-24 13:23:17 +02:00
parent b9a954a058
commit 8b199869c7
3 changed files with 17 additions and 3 deletions
-1
View File
@@ -142,7 +142,6 @@ function App() {
console.log('Response:', res.data);
const data = res.data;
updateData(data);
fetchLatestAnswer();
} catch (err) {
console.error('Error:', err);
setError('Failed to process query.');
+16 -1
View File
@@ -287,7 +287,19 @@ class BrowserAgent(Agent):
for res in search_result:
pretty_print(f"Title: {res['title']} - ", color="info", no_newline=True)
pretty_print(f"Link: {res['link']}", color="status")
def stuck_prompt(self, user_prompt: str, unvisited: List[str]) -> str:
"""
Prompt for when the agent repeat itself, can happen when fail to extract a link.
"""
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
prompt += f"""
You previously said:
{self.answer}
You must consider other options. Choose other link.
"""
return prompt
async def process(self, user_prompt: str, speech_module: type) -> Tuple[str, str]:
"""
Process the user prompt to conduct an autonomous web search.
@@ -320,6 +332,9 @@ class BrowserAgent(Agent):
print("Debug history:", self.search_history)
unvisited = self.select_unvisited(search_result)
answer, reasoning = await self.llm_decide(prompt, show_reasoning = False)
if self.last_answer == answer:
prompt = self.stuck_prompt(user_prompt, unvisited)
continue
self.last_answer = answer
pretty_print(''*32, color="status")
+1 -1
View File
@@ -80,7 +80,7 @@ class PlannerAgent(Agent):
if len(tasks_names) != len(tasks):
names = [task['task'] for task in tasks]
return list(map(list, zip(names, tasks)))
return list(map(list, zip(names, tasks)))
return list(map(list, zip(tasks_names, tasks)))
def make_prompt(self, task: str, agent_infos_dict: dict) -> str:
"""