mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-04 18:20:09 +00:00
feat : improve chrome path check + no query refusal on complex task
This commit is contained in:
parent
4342677344
commit
a3ca718131
@ -44,6 +44,11 @@ def get_chrome_path() -> str:
|
||||
for path in paths:
|
||||
if os.path.exists(path) and os.access(path, os.X_OK): # Check if executable
|
||||
return path
|
||||
print("Looking for Google Chrome in these locations failed:")
|
||||
print('\n'.join(paths))
|
||||
path = input("Google Chrome not found. Please enter the path to the Chrome executable: ")
|
||||
if os.path.exists(path) and os.access(path, os.X_OK):
|
||||
return path
|
||||
return None
|
||||
|
||||
def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx") -> webdriver.Chrome:
|
||||
|
@ -7,7 +7,9 @@ import requests
|
||||
import subprocess
|
||||
import ipaddress
|
||||
import httpx
|
||||
import socket
|
||||
import platform
|
||||
from urllib.parse import urlparse
|
||||
from dotenv import load_dotenv, set_key
|
||||
from openai import OpenAI
|
||||
from huggingface_hub import InferenceClient
|
||||
@ -95,25 +97,26 @@ class Provider:
|
||||
raise Exception(f"Provider {self.provider_name} failed: {str(e)}") from e
|
||||
return thought
|
||||
|
||||
def is_ip_online(self, ip_address):
|
||||
def is_ip_online(self, address: str, timeout: int = 10) -> bool:
|
||||
"""
|
||||
Check if an IP address is online by sending a ping request.
|
||||
Check if an address is online by sending a ping request.
|
||||
"""
|
||||
if ip_address == "127.0.0.1":
|
||||
if not address:
|
||||
return False
|
||||
if address.lower() in ["127.0.0.1", "localhost", "0.0.0.0"]:
|
||||
return True
|
||||
hostname = urlparse(f'http://{address}' if not address.startswith(('http://', 'https://')) else address).hostname or address
|
||||
try:
|
||||
ip_address = socket.gethostbyname(hostname)
|
||||
except socket.gaierror:
|
||||
self.logger.error(f"Cannot resolve: {hostname}")
|
||||
return False
|
||||
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
||||
command = ['ping', param, '1', ip_address]
|
||||
try:
|
||||
output = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15)
|
||||
if output.returncode == 0:
|
||||
return True
|
||||
else:
|
||||
self.logger.error(f"Ping command returned code: {output.returncode}")
|
||||
return False
|
||||
except subprocess.TimeoutExpired:
|
||||
return False
|
||||
except Exception as e:
|
||||
pretty_print(f"Error with ping request {str(e)}", color="failure")
|
||||
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
|
||||
return result.returncode == 0
|
||||
except (subprocess.TimeoutExpired, subprocess.SubprocessError) as e:
|
||||
return False
|
||||
|
||||
def server_fn(self, history, verbose = False):
|
||||
|
@ -402,8 +402,6 @@ class AgentRouter:
|
||||
if confidence < 0.4:
|
||||
self.logger.info(f"Low confidence in complexity estimation: {confidence}")
|
||||
return "LOW"
|
||||
if complexity == "HIGH" and len(text) < 64:
|
||||
return None # ask for more info
|
||||
if complexity == "HIGH":
|
||||
return "HIGH"
|
||||
elif complexity == "LOW":
|
||||
@ -440,11 +438,6 @@ class AgentRouter:
|
||||
text = self.lang_analysis.translate(text, lang)
|
||||
labels = [agent.role for agent in self.agents]
|
||||
complexity = self.estimate_complexity(text)
|
||||
if complexity == None and self.asked_clarify == False:
|
||||
self.asked_clarify = True
|
||||
pretty_print(f"Humm, the task seem complex but you gave very little information. can you clarify?", color="info")
|
||||
return None
|
||||
self.asked_clarify = False
|
||||
if complexity == "HIGH":
|
||||
pretty_print(f"Complex task detected, routing to planner agent.", color="info")
|
||||
return self.find_planner_agent()
|
||||
|
Loading…
x
Reference in New Issue
Block a user