скачал обновления
This commit is contained in:
@@ -11,6 +11,7 @@ import threading
|
||||
# GPT Library
|
||||
import g4f
|
||||
from g4f.api import run_api
|
||||
from g4f.errors import MissingAuthError, NoValidHarFileError, ProviderNotFoundError, RetryProviderError
|
||||
|
||||
# Server
|
||||
from flask import Flask, redirect, render_template
|
||||
@@ -450,6 +451,7 @@ async def index() -> str:
|
||||
proxy = f"{proxy['protocol']}://{proxy['username']}:{proxy['password']}@{proxy['ip']}:{proxy['port']}"
|
||||
print("Proxy: " + proxy)
|
||||
|
||||
try:
|
||||
if (args.provider == "Auto"):
|
||||
response = (
|
||||
await g4f.ChatCompletion.create_async(
|
||||
@@ -486,6 +488,13 @@ async def index() -> str:
|
||||
resp_str = re.sub(r"\[\^[0-9]+\^\]\[[0-9]+\]", "", str(resp_str[0]))
|
||||
# Returns the response
|
||||
return resp_str
|
||||
except (MissingAuthError, NoValidHarFileError, ProviderNotFoundError, RetryProviderError) as e:
|
||||
print(f"[X] Provider error: {type(e).__name__}: {e}")
|
||||
print("[!] Returning empty JSON response")
|
||||
return '{"translation_text": "", "short_text": "", "title": "", "category": ""}'
|
||||
except Exception as e:
|
||||
print(f"[X] Unexpected error: {type(e).__name__}: {e}")
|
||||
return '{"translation_text": "", "short_text": "", "title": "", "category": ""}'
|
||||
# return "<p id='response'>" + resp + "</p>" # Uncomment if preferred
|
||||
|
||||
def auth():
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user