diff --git a/sources/agents/planner_agent.py b/sources/agents/planner_agent.py index aaafc3a..1760c33 100644 --- a/sources/agents/planner_agent.py +++ b/sources/agents/planner_agent.py @@ -3,7 +3,7 @@ from sources.utility import pretty_print, animate_thinking from sources.agents.agent import Agent from sources.agents.code_agent import CoderAgent from sources.agents.file_agent import FileAgent -from sources.agents.casual_agent import CasualAgent +from sources.agents.browser_agent import BrowserAgent from sources.tools.tools import Tools class PlannerAgent(Agent): @@ -19,9 +19,9 @@ class PlannerAgent(Agent): self.agents = { "coder": CoderAgent(model, name, prompt_path, provider), "file": FileAgent(model, name, prompt_path, provider), - "web": CasualAgent(model, name, prompt_path, provider) + "web": BrowserAgent(model, name, prompt_path, provider) } - self.role = "complex programming tasks and web research" + self.role = "Manage complex tasks" self.tag = "json" def parse_agent_tasks(self, text): diff --git a/sources/browser.py b/sources/browser.py index 11556c2..32c280f 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -38,12 +38,10 @@ class Browser: chrome_options.add_argument("--disable-dev-shm-usage") # Automatically find ChromeDriver path chromedriver_path = shutil.which("chromedriver") + if not chromedriver_path: + raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.") service = Service(chromedriver_path) - if chromedriver_path: - self.driver = webdriver.Chrome(service=service, options=chrome_options) - else: - self.driver = webdriver.Chrome(service=service) - #raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.") + self.driver = webdriver.Chrome(service=service, options=chrome_options) self.wait = WebDriverWait(self.driver, 10) self.logger = logging.getLogger(__name__) self.logger.info("Browser initialized successfully") @@ -115,6 +113,7 @@ class Browser: return None def clean_url(self, url): + """Clean URL to keep only the part needed for navigation to the page""" clean = url.split('#')[0] parts = clean.split('?', 1) base_url = parts[0] diff --git a/sources/interaction.py b/sources/interaction.py index 6ae82ff..6a1282a 100644 --- a/sources/interaction.py +++ b/sources/interaction.py @@ -102,6 +102,7 @@ class Interaction: self.current_agent = agent # get history from previous agent, good ? self.current_agent.memory.push('user', self.last_query) + self.current_agent.memory.push('assistant', self.last_answer) self.last_answer, _ = agent.process(self.last_query, self.speech) def show_answer(self) -> None: diff --git a/sources/tools/searxSearch.py b/sources/tools/searxSearch.py index 9b8a0fb..7f3cac7 100644 --- a/sources/tools/searxSearch.py +++ b/sources/tools/searxSearch.py @@ -91,10 +91,10 @@ class searxSearch(Tools): description = article.find('p', class_='content').text.strip() if article.find('p', class_='content') else "No Description" results.append(f"Title:{title}\nSnippet:{description}\nLink:{url}") if len(results) == 0: - raise Exception("Searx search failed. did you run start_services.sh? Did docker die?") + return "No search results, web search failed." return "\n\n".join(results) # Return results as a single string, separated by newlines except requests.exceptions.RequestException as e: - return f"Error during search: {str(e)}" + raise Exception("\nSearxng search failed. did you run start_services.sh? is docker still running?") from e def execution_failure_check(self, output: str) -> bool: """