mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 19:15:28 +00:00
Fix : searxng now failing gracefully
This commit is contained in:
parent
0616f39e35
commit
372da19f30
@ -3,7 +3,7 @@ from sources.utility import pretty_print, animate_thinking
|
|||||||
from sources.agents.agent import Agent
|
from sources.agents.agent import Agent
|
||||||
from sources.agents.code_agent import CoderAgent
|
from sources.agents.code_agent import CoderAgent
|
||||||
from sources.agents.file_agent import FileAgent
|
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
|
from sources.tools.tools import Tools
|
||||||
|
|
||||||
class PlannerAgent(Agent):
|
class PlannerAgent(Agent):
|
||||||
@ -19,9 +19,9 @@ class PlannerAgent(Agent):
|
|||||||
self.agents = {
|
self.agents = {
|
||||||
"coder": CoderAgent(model, name, prompt_path, provider),
|
"coder": CoderAgent(model, name, prompt_path, provider),
|
||||||
"file": FileAgent(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"
|
self.tag = "json"
|
||||||
|
|
||||||
def parse_agent_tasks(self, text):
|
def parse_agent_tasks(self, text):
|
||||||
|
@ -38,12 +38,10 @@ class Browser:
|
|||||||
chrome_options.add_argument("--disable-dev-shm-usage")
|
chrome_options.add_argument("--disable-dev-shm-usage")
|
||||||
# Automatically find ChromeDriver path
|
# Automatically find ChromeDriver path
|
||||||
chromedriver_path = shutil.which("chromedriver")
|
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)
|
service = Service(chromedriver_path)
|
||||||
if chromedriver_path:
|
self.driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||||
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.wait = WebDriverWait(self.driver, 10)
|
self.wait = WebDriverWait(self.driver, 10)
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
self.logger.info("Browser initialized successfully")
|
self.logger.info("Browser initialized successfully")
|
||||||
@ -115,6 +113,7 @@ class Browser:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def clean_url(self, url):
|
def clean_url(self, url):
|
||||||
|
"""Clean URL to keep only the part needed for navigation to the page"""
|
||||||
clean = url.split('#')[0]
|
clean = url.split('#')[0]
|
||||||
parts = clean.split('?', 1)
|
parts = clean.split('?', 1)
|
||||||
base_url = parts[0]
|
base_url = parts[0]
|
||||||
|
@ -102,6 +102,7 @@ class Interaction:
|
|||||||
self.current_agent = agent
|
self.current_agent = agent
|
||||||
# get history from previous agent, good ?
|
# get history from previous agent, good ?
|
||||||
self.current_agent.memory.push('user', self.last_query)
|
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)
|
self.last_answer, _ = agent.process(self.last_query, self.speech)
|
||||||
|
|
||||||
def show_answer(self) -> None:
|
def show_answer(self) -> None:
|
||||||
|
@ -91,10 +91,10 @@ class searxSearch(Tools):
|
|||||||
description = article.find('p', class_='content').text.strip() if article.find('p', class_='content') else "No Description"
|
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}")
|
results.append(f"Title:{title}\nSnippet:{description}\nLink:{url}")
|
||||||
if len(results) == 0:
|
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
|
return "\n\n".join(results) # Return results as a single string, separated by newlines
|
||||||
except requests.exceptions.RequestException as e:
|
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:
|
def execution_failure_check(self, output: str) -> bool:
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user