mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +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:
|
for path in paths:
|
||||||
if os.path.exists(path) and os.access(path, os.X_OK): # Check if executable
|
if os.path.exists(path) and os.access(path, os.X_OK): # Check if executable
|
||||||
return path
|
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
|
return None
|
||||||
|
|
||||||
def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx") -> webdriver.Chrome:
|
def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx") -> webdriver.Chrome:
|
||||||
|
@ -7,7 +7,9 @@ import requests
|
|||||||
import subprocess
|
import subprocess
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import httpx
|
import httpx
|
||||||
|
import socket
|
||||||
import platform
|
import platform
|
||||||
|
from urllib.parse import urlparse
|
||||||
from dotenv import load_dotenv, set_key
|
from dotenv import load_dotenv, set_key
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
from huggingface_hub import InferenceClient
|
from huggingface_hub import InferenceClient
|
||||||
@ -95,25 +97,26 @@ class Provider:
|
|||||||
raise Exception(f"Provider {self.provider_name} failed: {str(e)}") from e
|
raise Exception(f"Provider {self.provider_name} failed: {str(e)}") from e
|
||||||
return thought
|
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
|
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'
|
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
||||||
command = ['ping', param, '1', ip_address]
|
command = ['ping', param, '1', ip_address]
|
||||||
try:
|
try:
|
||||||
output = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15)
|
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
|
||||||
if output.returncode == 0:
|
return result.returncode == 0
|
||||||
return True
|
except (subprocess.TimeoutExpired, subprocess.SubprocessError) as e:
|
||||||
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")
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def server_fn(self, history, verbose = False):
|
def server_fn(self, history, verbose = False):
|
||||||
|
@ -402,8 +402,6 @@ class AgentRouter:
|
|||||||
if confidence < 0.4:
|
if confidence < 0.4:
|
||||||
self.logger.info(f"Low confidence in complexity estimation: {confidence}")
|
self.logger.info(f"Low confidence in complexity estimation: {confidence}")
|
||||||
return "LOW"
|
return "LOW"
|
||||||
if complexity == "HIGH" and len(text) < 64:
|
|
||||||
return None # ask for more info
|
|
||||||
if complexity == "HIGH":
|
if complexity == "HIGH":
|
||||||
return "HIGH"
|
return "HIGH"
|
||||||
elif complexity == "LOW":
|
elif complexity == "LOW":
|
||||||
@ -440,11 +438,6 @@ class AgentRouter:
|
|||||||
text = self.lang_analysis.translate(text, lang)
|
text = self.lang_analysis.translate(text, lang)
|
||||||
labels = [agent.role for agent in self.agents]
|
labels = [agent.role for agent in self.agents]
|
||||||
complexity = self.estimate_complexity(text)
|
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":
|
if complexity == "HIGH":
|
||||||
pretty_print(f"Complex task detected, routing to planner agent.", color="info")
|
pretty_print(f"Complex task detected, routing to planner agent.", color="info")
|
||||||
return self.find_planner_agent()
|
return self.find_planner_agent()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user