diff --git a/config.ini b/config.ini index cbd7b34..19cb1e4 100644 --- a/config.ini +++ b/config.ini @@ -3,14 +3,14 @@ is_local = True provider_name = ollama provider_model = deepseek-r1:14b provider_server_address = 127.0.0.1:11434 -agent_name = Friday +agent_name = Name_of_your_AI recover_last_session = False save_session = False speak = False listen = False -work_dir = /Users/mlg/Documents/ai_folder +work_dir = /Users/mlg/Documents/workspace_for_agenticseek jarvis_personality = False languages = en [BROWSER] -headless_browser = False -stealth_mode = True \ No newline at end of file +headless_browser = True +stealth_mode = False \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 715523f..a63646c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +kokoro==0.9.4 +certifi==2025.4.26 fastapi>=0.115.12 flask>=3.1.0 celery>=5.5.1 @@ -18,10 +20,10 @@ torch>=2.4.1 python-dotenv>=1.0.0 ollama>=0.4.7 scipy>=1.9.3 -kokoro>=0.7.12 soundfile>=0.13.1 protobuf>=3.20.3 termcolor>=2.4.0 +pypdf>=5.4.0 ipython>=8.13.0 pyaudio>=0.2.14 librosa>=0.10.2.post1 @@ -39,11 +41,8 @@ fake_useragent>=2.1.0 selenium_stealth>=1.0.6 undetected-chromedriver>=3.5.5 sentencepiece>=0.2.0 +tqdm>4 openai sniffio -tqdm>4 -# if use chinese ordered_set pypinyin -cn2an -jieba diff --git a/sources/browser.py b/sources/browser.py index a5dc67f..be511ad 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -13,6 +13,8 @@ from fake_useragent import UserAgent from selenium_stealth import stealth import undetected_chromedriver as uc import chromedriver_autoinstaller +import certifi +import ssl import time import random import os @@ -27,6 +29,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sources.utility import pretty_print, animate_thinking from sources.logger import Logger + def get_chrome_path() -> str: """Get the path to the Chrome executable.""" if sys.platform.startswith("win"): @@ -84,6 +87,30 @@ def install_chromedriver() -> str: raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.") return chromedriver_path +def bypass_ssl() -> str: + """ + This is a fallback for stealth mode to bypass SSL verification. Which can fail on some setup. + """ + pretty_print("This is a workaround for SSL issues but upsafe we strongly advice you update your certifi SSL certificate.", color="warning") + ssl._create_default_https_context = ssl._create_unverified_context + +def create_undetected_chromedriver(service, chrome_options) -> webdriver.Chrome: + """Create an undetected ChromeDriver instance.""" + try: + driver = uc.Chrome(service=service, options=chrome_options) + except Exception as e: + pretty_print(f"Failed to create Chrome driver: {str(e)}. Trying to bypass SSL...", color="failure") + try: + bypass_ssl() + driver = uc.Chrome(service=service, options=chrome_options) + except Exception as e: + pretty_print(f"Failed to create Chrome driver, fallback failed:\n{str(e)}.", color="failure") + raise e + raise e + # hide webdriver flag + driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") + return driver + def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx") -> webdriver.Chrome: """Create a Chrome WebDriver with specified options.""" chrome_options = Options() @@ -122,8 +149,7 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx service = Service(chromedriver_path) if stealth_mode: chrome_options.add_argument("--disable-blink-features=AutomationControlled") - driver = uc.Chrome(service=service, options=chrome_options) - driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") + driver = create_undetected_chromedriver(service, chrome_options) chrome_version = driver.capabilities['browserVersion'] stealth(driver, languages=["en-US", "en"], diff --git a/sources/text_to_speech.py b/sources/text_to_speech.py index e50d742..dff9d3f 100644 --- a/sources/text_to_speech.py +++ b/sources/text_to_speech.py @@ -9,7 +9,10 @@ from kokoro import KPipeline from IPython.display import display, Audio import soundfile as sf -from sources.utility import pretty_print, animate_thinking +if __name__ == "__main__": + from utility import pretty_print, animate_thinking +else: + from sources.utility import pretty_print, animate_thinking class Speech(): """