fix : planner agent bug
This commit is contained in:
@@ -142,7 +142,6 @@ function App() {
|
|||||||
console.log('Response:', res.data);
|
console.log('Response:', res.data);
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
updateData(data);
|
updateData(data);
|
||||||
fetchLatestAnswer();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error:', err);
|
console.error('Error:', err);
|
||||||
setError('Failed to process query.');
|
setError('Failed to process query.');
|
||||||
|
|||||||
@@ -288,6 +288,18 @@ class BrowserAgent(Agent):
|
|||||||
pretty_print(f"Title: {res['title']} - ", color="info", no_newline=True)
|
pretty_print(f"Title: {res['title']} - ", color="info", no_newline=True)
|
||||||
pretty_print(f"Link: {res['link']}", color="status")
|
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]:
|
async def process(self, user_prompt: str, speech_module: type) -> Tuple[str, str]:
|
||||||
"""
|
"""
|
||||||
Process the user prompt to conduct an autonomous web search.
|
Process the user prompt to conduct an autonomous web search.
|
||||||
@@ -320,6 +332,9 @@ class BrowserAgent(Agent):
|
|||||||
print("Debug history:", self.search_history)
|
print("Debug history:", self.search_history)
|
||||||
unvisited = self.select_unvisited(search_result)
|
unvisited = self.select_unvisited(search_result)
|
||||||
answer, reasoning = await self.llm_decide(prompt, show_reasoning = False)
|
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
|
self.last_answer = answer
|
||||||
pretty_print('▂'*32, color="status")
|
pretty_print('▂'*32, color="status")
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class PlannerAgent(Agent):
|
|||||||
if len(tasks_names) != len(tasks):
|
if len(tasks_names) != len(tasks):
|
||||||
names = [task['task'] for task in 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(names, tasks)))
|
return list(map(list, zip(tasks_names, tasks)))
|
||||||
|
|
||||||
def make_prompt(self, task: str, agent_infos_dict: dict) -> str:
|
def make_prompt(self, task: str, agent_infos_dict: dict) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user