summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/helper.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-04 10:40:18 +0200
committerGitHub <noreply@github.com>2023-10-04 10:40:18 +0200
commit6eb3fa3e5fa5675363dc09209cf77fba0542a506 (patch)
tree0ca69953cbf4820667500a195c8f97c5da75c88e /g4f/Provider/helper.py
parent ~ | g4f v-0.1.4.6 `pip install -U g4f` (diff)
parentSort providers in new dirs (diff)
downloadgpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar.gz
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar.bz2
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar.lz
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar.xz
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.tar.zst
gpt4free-6eb3fa3e5fa5675363dc09209cf77fba0542a506.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/helper.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/g4f/Provider/helper.py b/g4f/Provider/helper.py
index 8f09239a..c127f241 100644
--- a/g4f/Provider/helper.py
+++ b/g4f/Provider/helper.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import asyncio, sys
from asyncio import AbstractEventLoop
-
+from os import path
import browser_cookie3
# Change event loop policy on windows
@@ -60,24 +60,11 @@ def format_prompt(messages: list[dict[str, str]], add_special_tokens=False):
def get_browser(user_data_dir: str = None):
- try:
- from undetected_chromedriver import Chrome
- except ImportError:
- return None
+ from undetected_chromedriver import Chrome
+ from platformdirs import user_config_dir
- def get_user_data_dir():
- dirs = [
- '~/.config/google-chrome/Default',
- '~/.var/app/com.google.Chrome/config/google-chrome/Default',
- '%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default',
- '~/Library/Application Support/Google/Chrome/Default',
- ]
- from os import path
- for dir in dirs:
- dir = path.expandvars(dir)
- if path.exists(dir):
- return dir
if not user_data_dir:
- user_data_dir = get_user_data_dir()
+ user_data_dir = user_config_dir("g4f")
+ user_data_dir = path.join(user_data_dir, "Default")
return Chrome(user_data_dir=user_data_dir) \ No newline at end of file