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

XFEstudio/gpt4free

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

2dfa807c
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +11 -7
Modified etc/tool/create_provider.py +7 -4
@@ -5,10 +5,14 @@ from os import path
5 5
6 6 sys.path.append(str(Path(__file__).parent.parent.parent))
7 7
8 # Enable logging
8 9 import g4f
9
10 10 g4f.debug.logging = True
11 11
12 # Read auth files
13 from g4f.cookies import read_cookie_files
14 read_cookie_files()
15
12 16 def read_code(text):
13 17 if match := re.search(r"```(python|py|)\n(?P<code>[\S\s]+?)\n```", text):
14 18 return match.group("code")
@@ -114,9 +118,8 @@ And replace "gpt-3.5-turbo" with `model`.
114 118 print("Create code...")
115 119 response = []
116 120 for chunk in g4f.ChatCompletion.create(
117 model=g4f.models.gpt_4o,
118 messages=[{"role": "user", "content": prompt}],
119 timeout=300,
121 model=g4f.models.default,
122 messages=prompt,
120 123 stream=True,
121 124 ):
122 125 print(chunk, end="", flush=True)
Modified g4f/api/__init__.py +1 -1
@@ -372,7 +372,7 @@ class Api:
372 372 "vision": model in getattr(provider, "vision_models", []),
373 373 "audio": model in getattr(provider, "audio_models", []),
374 374 "video": model in getattr(provider, "video_models", []),
375 "type": "image" if model in getattr(provider, "image_models", []) else "text",
375 "type": "image" if model in getattr(provider, "image_models", []) else "chat",
376 376 } for model in models]
377 377 }
378 378
Modified g4f/config.py +3 -2
@@ -24,6 +24,7 @@ GITHUB_REPOSITORY = f"xtekky/{ORGANIZATION}"
24 24 STATIC_DOMAIN = f"{PACKAGE_NAME}.dev"
25 25 STATIC_URL = f"https://{STATIC_DOMAIN}/"
26 26 DIST_DIR = f"./{STATIC_DOMAIN}/dist"
27 DOWNLOAD_URL = f"https://raw.githubusercontent.com/{ORGANIZATION}/{STATIC_DOMAIN}/refs/heads/main/"
28 27 DEFAULT_MODEL = "openai/gpt-oss-120b"
29 JSDELIVR_URL = "https://cdn.jsdelivr.net/"
28 JSDELIVR_URL = "https://cdn.jsdelivr.net/"
29 DOWNLOAD_URL = f"{JSDELIVR_URL}gh/{ORGANIZATION}/{STATIC_DOMAIN}/"
30 # DOWNLOAD_URL = f"https://raw.githubusercontent.com/{ORGANIZATION}/{STATIC_DOMAIN}/refs/heads/main/"