Update styling

This commit is contained in:
hlohaus 2025-08-25 00:19:42 +02:00
parent 2cf62a8e63
commit 0b75e68b51
2 changed files with 8 additions and 7 deletions

View file

@ -132,8 +132,8 @@ class Azure(OpenaiTemplate):
stream = False
if stream:
kwargs.setdefault("stream_options", {"include_usage": True})
if cls.failed.get(model, 0) >= 3:
raise MissingAuthError(f"Model {model} has failed too many times.")
if cls.failed.get(api_key, 0) >= 3:
raise MissingAuthError(f"API key has failed too many times.")
try:
async for chunk in super().create_async_generator(
model=model,
@ -146,5 +146,5 @@ class Azure(OpenaiTemplate):
):
yield chunk
except MissingAuthError as e:
cls.failed[model] = cls.failed.get(model, 0) + 1
cls.failed[api_key] = cls.failed.get(api_key, 0) + 1
raise MissingAuthError(f"{e}. Ask for help in the {cls.login_url} Discord server.") from e

View file

@ -168,10 +168,10 @@ async def get_nodriver(
if not os.path.exists(browser_executable_path):
browser_executable_path = None
debug.log(f"Browser executable path: {browser_executable_path}")
lock_file = Path(get_cookies_dir()) / ".nodriver_is_open"
lock_file.parent.mkdir(exist_ok=True)
# Implement a short delay (milliseconds) to prevent race conditions.
if user_data_dir:
lock_file = Path(get_cookies_dir()) / ".nodriver_is_open"
lock_file.parent.mkdir(exist_ok=True)
# Implement a short delay (milliseconds) to prevent race conditions.
await asyncio.sleep(0.1 * random.randint(0, 50))
if lock_file.exists():
opend_at = float(lock_file.read_text())
@ -194,9 +194,10 @@ async def get_nodriver(
lock_file.write_text(str(time.time()))
debug.log(f"Open nodriver with user_dir: {user_data_dir}")
try:
browser_args = ["--no-sandbox"]
browser = await nodriver.start(
user_data_dir=user_data_dir,
browser_args=["--no-sandbox"] if proxy is None else ["--no-sandbox", f"--proxy-server={proxy}"],
browser_args=[*browser_args, f"--proxy-server={proxy}"] if proxy else browser_args,
browser_executable_path=browser_executable_path,
**kwargs
)