mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 19:15:28 +00:00
Fix : agent never exiting
This commit is contained in:
parent
f6e3b38e6a
commit
3ff8bc68c3
@ -125,6 +125,7 @@ class BrowserAgent(Agent):
|
|||||||
|
|
||||||
def conclude_prompt(self, user_query):
|
def conclude_prompt(self, user_query):
|
||||||
search_note = '\n -'.join(self.notes)
|
search_note = '\n -'.join(self.notes)
|
||||||
|
print("AI research notes:\n", search_note)
|
||||||
return f"""
|
return f"""
|
||||||
Following a web search about:
|
Following a web search about:
|
||||||
{user_query}
|
{user_query}
|
||||||
@ -138,7 +139,7 @@ class BrowserAgent(Agent):
|
|||||||
animate_thinking(f"Searching...", color="status")
|
animate_thinking(f"Searching...", color="status")
|
||||||
search_result_raw = self.tools["web_search"].execute([user_prompt], False)
|
search_result_raw = self.tools["web_search"].execute([user_prompt], False)
|
||||||
search_result = self.jsonify_search_results(search_result_raw)
|
search_result = self.jsonify_search_results(search_result_raw)
|
||||||
search_result = search_result[:10] # until futher improvement
|
search_result = search_result[:5] # until futher improvement
|
||||||
prompt = self.make_newsearch_prompt(user_prompt, search_result)
|
prompt = self.make_newsearch_prompt(user_prompt, search_result)
|
||||||
unvisited = [None]
|
unvisited = [None]
|
||||||
while not complete:
|
while not complete:
|
||||||
@ -148,14 +149,14 @@ class BrowserAgent(Agent):
|
|||||||
complete = True
|
complete = True
|
||||||
break
|
break
|
||||||
links = self.extract_links(answer)
|
links = self.extract_links(answer)
|
||||||
|
if len(unvisited) == 0:
|
||||||
|
break
|
||||||
if len(links) == 0 or "GO_BACK" in answer:
|
if len(links) == 0 or "GO_BACK" in answer:
|
||||||
unvisited = self.select_unvisited(search_result)
|
unvisited = self.select_unvisited(search_result)
|
||||||
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
|
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
|
||||||
pretty_print(f"Going back to results. Still {len(unvisited)}", color="warning")
|
pretty_print(f"Going back to results. Still {len(unvisited)}", color="warning")
|
||||||
links = []
|
links = []
|
||||||
continue
|
continue
|
||||||
if len(unvisited) == 0:
|
|
||||||
break
|
|
||||||
animate_thinking(f"Navigating to {links[0]}", color="status")
|
animate_thinking(f"Navigating to {links[0]}", color="status")
|
||||||
speech_module.speak(f"Navigating to {links[0]}")
|
speech_module.speak(f"Navigating to {links[0]}")
|
||||||
self.browser.go_to(links[0])
|
self.browser.go_to(links[0])
|
||||||
@ -164,11 +165,11 @@ class BrowserAgent(Agent):
|
|||||||
self.navigable_links = self.browser.get_navigable()
|
self.navigable_links = self.browser.get_navigable()
|
||||||
prompt = self.make_navigation_prompt(user_prompt, page_text)
|
prompt = self.make_navigation_prompt(user_prompt, page_text)
|
||||||
|
|
||||||
speech_module.speak(answer)
|
|
||||||
self.browser.close()
|
self.browser.close()
|
||||||
prompt = self.conclude_prompt(user_prompt)
|
prompt = self.conclude_prompt(user_prompt)
|
||||||
answer, reasoning = self.llm_request(prompt)
|
answer, reasoning = self.llm_request(prompt)
|
||||||
pretty_print(answer, color="output")
|
pretty_print(answer, color="output")
|
||||||
|
speech_module.speak(answer)
|
||||||
return answer, reasoning
|
return answer, reasoning
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user