XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Update styling

0b75e68b
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +8 -7
Modified g4f/Provider/needs_auth/Azure.py +3 -3
@@ -132,8 +132,8 @@ class Azure(OpenaiTemplate):
132 132 stream = False
133 133 if stream:
134 134 kwargs.setdefault("stream_options", {"include_usage": True})
135 if cls.failed.get(model, 0) >= 3:
136 raise MissingAuthError(f"Model {model} has failed too many times.")
135 if cls.failed.get(api_key, 0) >= 3:
136 raise MissingAuthError(f"API key has failed too many times.")
137 137 try:
138 138 async for chunk in super().create_async_generator(
139 139 model=model,
@@ -146,5 +146,5 @@ class Azure(OpenaiTemplate):
146 146 ):
147 147 yield chunk
148 148 except MissingAuthError as e:
149 cls.failed[model] = cls.failed.get(model, 0) + 1
149 cls.failed[api_key] = cls.failed.get(api_key, 0) + 1
150 150 raise MissingAuthError(f"{e}. Ask for help in the {cls.login_url} Discord server.") from e
Modified g4f/requests/__init__.py +5 -4
@@ -168,10 +168,10 @@ async def get_nodriver(
168 168 if not os.path.exists(browser_executable_path):
169 169 browser_executable_path = None
170 170 debug.log(f"Browser executable path: {browser_executable_path}")
171 lock_file = Path(get_cookies_dir()) / ".nodriver_is_open"
172 lock_file.parent.mkdir(exist_ok=True)
173 # Implement a short delay (milliseconds) to prevent race conditions.
174 171 if user_data_dir:
172 lock_file = Path(get_cookies_dir()) / ".nodriver_is_open"
173 lock_file.parent.mkdir(exist_ok=True)
174 # Implement a short delay (milliseconds) to prevent race conditions.
175 175 await asyncio.sleep(0.1 * random.randint(0, 50))
176 176 if lock_file.exists():
177 177 opend_at = float(lock_file.read_text())
@@ -194,9 +194,10 @@ async def get_nodriver(
194 194 lock_file.write_text(str(time.time()))
195 195 debug.log(f"Open nodriver with user_dir: {user_data_dir}")
196 196 try:
197 browser_args = ["--no-sandbox"]
197 198 browser = await nodriver.start(
198 199 user_data_dir=user_data_dir,
199 browser_args=["--no-sandbox"] if proxy is None else ["--no-sandbox", f"--proxy-server={proxy}"],
200 browser_args=[*browser_args, f"--proxy-server={proxy}"] if proxy else browser_args,
200 201 browser_executable_path=browser_executable_path,
201 202 **kwargs
202 203 )