Refactor provider type determination to use 'chat' for non-image models and update download URL configuration

This commit is contained in:
hlohaus 2025-09-04 12:07:42 +02:00
parent 01e7af68c0
commit 2dfa807cfb
3 changed files with 11 additions and 7 deletions

View file

@ -5,10 +5,14 @@ from os import path
sys.path.append(str(Path(__file__).parent.parent.parent))
# Enable logging
import g4f
g4f.debug.logging = True
# Read auth files
from g4f.cookies import read_cookie_files
read_cookie_files()
def read_code(text):
if match := re.search(r"```(python|py|)\n(?P<code>[\S\s]+?)\n```", text):
return match.group("code")
@ -114,9 +118,8 @@ And replace "gpt-3.5-turbo" with `model`.
print("Create code...")
response = []
for chunk in g4f.ChatCompletion.create(
model=g4f.models.gpt_4o,
messages=[{"role": "user", "content": prompt}],
timeout=300,
model=g4f.models.default,
messages=prompt,
stream=True,
):
print(chunk, end="", flush=True)

View file

@ -372,7 +372,7 @@ class Api:
"vision": model in getattr(provider, "vision_models", []),
"audio": model in getattr(provider, "audio_models", []),
"video": model in getattr(provider, "video_models", []),
"type": "image" if model in getattr(provider, "image_models", []) else "text",
"type": "image" if model in getattr(provider, "image_models", []) else "chat",
} for model in models]
}

View file

@ -24,6 +24,7 @@ GITHUB_REPOSITORY = f"xtekky/{ORGANIZATION}"
STATIC_DOMAIN = f"{PACKAGE_NAME}.dev"
STATIC_URL = f"https://{STATIC_DOMAIN}/"
DIST_DIR = f"./{STATIC_DOMAIN}/dist"
DOWNLOAD_URL = f"https://raw.githubusercontent.com/{ORGANIZATION}/{STATIC_DOMAIN}/refs/heads/main/"
DEFAULT_MODEL = "openai/gpt-oss-120b"
JSDELIVR_URL = "https://cdn.jsdelivr.net/"
DOWNLOAD_URL = f"{JSDELIVR_URL}gh/{ORGANIZATION}/{STATIC_DOMAIN}/"
# DOWNLOAD_URL = f"https://raw.githubusercontent.com/{ORGANIZATION}/{STATIC_DOMAIN}/refs/heads/main/"