diff --git a/media/exemples/web_search.png b/media/exemples/web_search.png new file mode 100644 index 0000000..cea4e05 Binary files /dev/null and b/media/exemples/web_search.png differ diff --git a/sources/agents/browser_agent.py b/sources/agents/browser_agent.py index 8738c79..c97afa7 100644 --- a/sources/agents/browser_agent.py +++ b/sources/agents/browser_agent.py @@ -41,10 +41,15 @@ class BrowserAgent(Agent): Navigable links: {format_links} - Remember, you must seek the information the user want. - The user query was : {user_prompt} - You must choose a link to navigate to. + You must choose a link to navigate to or do a new search. + Remember, you seek the information the user want. + The user query was : {user_prompt} + If you want to do a new search, use the "web_search" tool. + Exemple: + ```web_search + weather in tokyo + ``` If you have an answer and want to exit the browser, please say "REQUEST_EXIT". """ @@ -68,13 +73,17 @@ class BrowserAgent(Agent): animate_thinking("Thinking...", color="status") self.memory.push('user', user_prompt) answer, reasoning = self.llm_request(prompt) + pretty_print("-"*100) + pretty_print(answer, color="output") + pretty_print("-"*100) if "REQUEST_EXIT" in answer: complete = True break links = self.extract_links(answer) links_clean = self.clean_links(links) if len(links_clean) == 0: - prompt = "Please choose a link to navigate to." + prompt = f"Please choose a link to navigate to or do a new search. Links found:\n{links_clean}" + pretty_print("No links found, doing a new search.", color="warning") continue animate_thinking(f"Navigating to {links[0]}", color="status") speech_module.speak(f"Navigating to {links[0]}") diff --git a/sources/browser.py b/sources/browser.py index 1287def..8d62eb3 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -41,6 +41,8 @@ class Browser: def is_sentence(self, text): """Check if the text is a sentence.""" + if "404" in text: + return True # we want the ai to see the error return len(text.split(" ")) > 5 and '.' in text def getText(self):