From 2dfa807cfb02db1ddfb1dfaf91e7c799da5ba9b8 Mon Sep 17 00:00:00 2001 From: hlohaus <983577+hlohaus@users.noreply.github.com> Date: Thu, 4 Sep 2025 12:07:42 +0200 Subject: [PATCH] Refactor provider type determination to use 'chat' for non-image models and update download URL configuration --- etc/tool/create_provider.py | 11 +++++++---- g4f/api/__init__.py | 2 +- g4f/config.py | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/etc/tool/create_provider.py b/etc/tool/create_provider.py index 57751937..fa585e0c 100644 --- a/etc/tool/create_provider.py +++ b/etc/tool/create_provider.py @@ -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[\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) diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 86ba1140..7745a97b 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -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] } diff --git a/g4f/config.py b/g4f/config.py index 57e406c4..fa2e6096 100644 --- a/g4f/config.py +++ b/g4f/config.py @@ -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/" \ No newline at end of file +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/" \ No newline at end of file