From 06e6b2798b94c874f8eadcb1d03f2e37f0d47ea8 Mon Sep 17 00:00:00 2001 From: martin legrand Date: Fri, 11 Apr 2025 14:11:09 +0200 Subject: [PATCH] fix : lang error --- sources/agents/browser_agent.py | 1 + sources/router.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sources/agents/browser_agent.py b/sources/agents/browser_agent.py index 604fed6..289812a 100644 --- a/sources/agents/browser_agent.py +++ b/sources/agents/browser_agent.py @@ -166,6 +166,7 @@ class BrowserAgent(Agent): You previously took these notes: {notes} Do not Step-by-Step explanation. Write Notes or Error as a long paragraph followed by your action. + Do not go to tutorials or help pages. """ def llm_decide(self, prompt: str, show_reasoning: bool = False) -> Tuple[str, str]: diff --git a/sources/router.py b/sources/router.py index d52547c..5f65fe2 100644 --- a/sources/router.py +++ b/sources/router.py @@ -430,7 +430,8 @@ class AgentRouter: Returns: Agent: The selected agent """ - if len(self.agents) == 0: + assert len(self.agents) > 0, "No agents available." + if len(self.agents) == 1: return self.agents[0] lang = self.lang_analysis.detect_language(text) text = self.find_first_sentence(text) @@ -449,7 +450,8 @@ class AgentRouter: raise e for agent in self.agents: if best_agent == agent.role["en"]: - pretty_print(f"Selected agent: {agent.agent_name} (roles: {agent.role[lang]})", color="warning") + role_name = agent.role[lang] if lang in agent.role else agent.role["en"] + pretty_print(f"Selected agent: {agent.agent_name} (roles: {role_name})", color="warning") return agent pretty_print(f"Error choosing agent.", color="failure") self.logger.error("No agent selected.")