summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Gemini.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-05-16 20:06:57 +0200
committerGitHub <noreply@github.com>2024-05-16 20:06:57 +0200
commit0332c0c0dd01dd71aabca62f007ad9e8809ee48f (patch)
treef9a4170ef8c5b0358bc4cf7189f997e3098ee0f3 /g4f/Provider/needs_auth/Gemini.py
parentUpdate README.md (diff)
parentAdd needs auth to provierds, Add PerplexityApi provider (diff)
downloadgpt4free-0.3.1.2.tar
gpt4free-0.3.1.2.tar.gz
gpt4free-0.3.1.2.tar.bz2
gpt4free-0.3.1.2.tar.lz
gpt4free-0.3.1.2.tar.xz
gpt4free-0.3.1.2.tar.zst
gpt4free-0.3.1.2.zip
Diffstat (limited to 'g4f/Provider/needs_auth/Gemini.py')
-rw-r--r--g4f/Provider/needs_auth/Gemini.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/g4f/Provider/needs_auth/Gemini.py b/g4f/Provider/needs_auth/Gemini.py
index 25ad1c6e..e468f64a 100644
--- a/g4f/Provider/needs_auth/Gemini.py
+++ b/g4f/Provider/needs_auth/Gemini.py
@@ -59,7 +59,7 @@ class Gemini(AsyncGeneratorProvider):
_cookies: Cookies = None
@classmethod
- async def nodriver_login(cls) -> AsyncIterator[str]:
+ async def nodriver_login(cls, proxy: str = None) -> AsyncIterator[str]:
try:
import nodriver as uc
except ImportError:
@@ -71,7 +71,10 @@ class Gemini(AsyncGeneratorProvider):
user_data_dir = None
if debug.logging:
print(f"Open nodriver with user_dir: {user_data_dir}")
- browser = await uc.start(user_data_dir=user_data_dir)
+ browser = await uc.start(
+ user_data_dir=user_data_dir,
+ browser_args=None if proxy is None else [f"--proxy-server={proxy}"],
+ )
login_url = os.environ.get("G4F_LOGIN_URL")
if login_url:
yield f"Please login: [Google Gemini]({login_url})\n\n"
@@ -134,7 +137,7 @@ class Gemini(AsyncGeneratorProvider):
) as session:
snlm0e = await cls.fetch_snlm0e(session, cls._cookies) if cls._cookies else None
if not snlm0e:
- async for chunk in cls.nodriver_login():
+ async for chunk in cls.nodriver_login(proxy):
yield chunk
if cls._cookies is None:
async for chunk in cls.webdriver_login(proxy):