From 469551c2b50f407e974ac2c5f11ee75e4a9d6dea Mon Sep 17 00:00:00 2001 From: martin legrand Date: Tue, 8 Apr 2025 10:43:28 +0200 Subject: [PATCH] fix : stuck for and back same webpage link --- sources/agents/browser_agent.py | 2 +- sources/router.py | 1 + tests/test_browser_agent_parsing.py | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sources/agents/browser_agent.py b/sources/agents/browser_agent.py index fcf5632..308332d 100644 --- a/sources/agents/browser_agent.py +++ b/sources/agents/browser_agent.py @@ -336,7 +336,7 @@ class BrowserAgent(Agent): complete = True break - if link == None or Action.GO_BACK.value in answer: + if link == None or Action.GO_BACK.value in answer or link in self.search_history: pretty_print(f"Going back to results. Still {len(unvisited)}", color="status") unvisited = self.select_unvisited(search_result) prompt = self.make_newsearch_prompt(user_prompt, unvisited) diff --git a/sources/router.py b/sources/router.py index 5681404..6b0f011 100644 --- a/sources/router.py +++ b/sources/router.py @@ -128,6 +128,7 @@ class AgentRouter: ("Check if a file named ‘project_proposal.pdf’ exists in my Documents", "LOW"), ("Search the web for tips on improving coding skills", "LOW"), ("Write a Python script to count words in a text file", "LOW"), + ("Search the web for restaurant", "LOW"), ("Find a public API for sports scores and build a web app to show live updates", "HIGH"), ("Create a simple HTML page with CSS styling", "LOW"), ("hi", "LOW"), diff --git a/tests/test_browser_agent_parsing.py b/tests/test_browser_agent_parsing.py index 8035d4e..e8c5b9f 100644 --- a/tests/test_browser_agent_parsing.py +++ b/tests/test_browser_agent_parsing.py @@ -17,12 +17,13 @@ class TestBrowserAgentParsing(unittest.TestCase): # Test various link formats test_text = """ Check this out: https://thriveonai.com/15-ai-startups-in-japan-to-take-note-of, and www.google.com! - Also try https://test.org/about?page=1. + Also try https://test.org/about?page=1, hey this one as well bro https://weatherstack.com/documentation. """ expected = [ "https://thriveonai.com/15-ai-startups-in-japan-to-take-note-of", "www.google.com", - "https://test.org/about?page=1" + "https://test.org/about?page=1", + "https://weatherstack.com/documentation" ] result = self.agent.extract_links(test_text) self.assertEqual(result, expected)