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

XFEstudio/gpt4free

Improve update script

295103f2
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

4 个文件 +12 -13
Modified g4f/Provider/Cloudflare.py +2 -2
@@ -82,14 +82,14 @@ class Cloudflare(AsyncGeneratorProvider, ProviderModelMixin, AuthFileMixin):
82 82 cls._args = await get_args_from_nodriver(cls.url)
83 83 read_models()
84 84 except Exception as e:
85 debug.log(f"Nodriver is not available: {type(e).__name__}: {e}")
85 debug.error(f"Nodriver is not available:", e)
86 86 cls.models = cls.fallback_models
87 87 get_running_loop(check_nested=True)
88 88 try:
89 89 task = asyncio.create_task(nodriver_read_models())
90 90 asyncio.run(task)
91 91 except RuntimeError as e:
92 debug.log("Nodriver is not available:", e)
92 debug.error("Nodriver is not available:", e)
93 93 cls.models = cls.fallback_models
94 94 task.cancel()
95 95 else:
Modified g4f/Provider/LambdaChat.py +1 -1
@@ -22,7 +22,7 @@ class LambdaChat(AsyncGeneratorProvider, ProviderModelMixin):
22 22
23 23 working = True
24 24
25 default_model = "deepseek-v3-0324"
25 default_model = "deepseek-v3"
26 26 models = [
27 27 "deepseek-llama3.3-70b",
28 28 "deepseek-r1",
Modified g4f/Provider/needs_auth/Video.py +1 -1
@@ -32,7 +32,7 @@ class RequestConfig:
32 32 @classmethod
33 33 async def get_response(cls, prompt: str) -> VideoResponse | None:
34 34 if prompt in cls.urls and cls.urls[prompt]:
35 unique_list = list(set(cls.urls[prompt]))
35 unique_list = list(set(cls.urls[prompt]))[:10]
36 36 return VideoResponse(unique_list, prompt, {
37 37 "headers": {"authorization": cls.headers.get("authorization")} if cls.headers.get("authorization") else {},
38 38 "preview": [url.replace("md.mp4", "thumb.webp") for url in unique_list]
Modified g4f/image/__init__.py +8 -9
@@ -10,12 +10,11 @@ from typing import Optional
10 10
11 11 try:
12 12 from PIL import Image, ImageOps
13 from PIL import open as open_image
14 13 has_requirements = True
15 14 except ImportError:
16 15 has_requirements = False
17 16
18 from ..typing import ImageType, Image
17 from ..typing import ImageType
19 18 from ..errors import MissingRequirementsError
20 19
21 20 EXTENSIONS_MAP: dict[str, str] = {
@@ -41,7 +40,7 @@ EXTENSIONS_MAP: dict[str, str] = {
41 40 MEDIA_TYPE_MAP: dict[str, str] = {value: key for key, value in EXTENSIONS_MAP.items()}
42 41 MEDIA_TYPE_MAP["audio/webm"] = "webm"
43 42
44 def to_image(image: ImageType, is_svg: bool = False) -> Image:
43 def to_image(image: ImageType, is_svg: bool = False) -> Image.Image:
45 44 """
46 45 Converts the input image to a PIL Image object.
47 46
@@ -67,13 +66,13 @@ def to_image(image: ImageType, is_svg: bool = False) -> Image:
67 66 image = image.read()
68 67 buffer = BytesIO()
69 68 cairosvg.svg2png(image, write_to=buffer)
70 return open_image(buffer)
69 return Image.open(buffer)
71 70
72 71 if isinstance(image, bytes):
73 72 is_accepted_format(image)
74 return open_image(BytesIO(image))
75 elif not isinstance(image, Image):
76 image = open_image(image)
73 return Image.open(BytesIO(image))
74 elif not isinstance(image, Image.Image):
75 image = Image.open(image)
77 76 image.load()
78 77 return image
79 78
@@ -203,7 +202,7 @@ def extract_data_uri(data_uri: str) -> bytes:
203 202 data = base64.b64decode(data)
204 203 return data
205 204
206 def process_image(image: Image, new_width: int = 800, new_height: int = 400, save: str = None) -> Image:
205 def process_image(image: Image.Image, new_width: int = 800, new_height: int = 400, save: str = None) -> Image.Image:
207 206 """
208 207 Processes the given image by adjusting its orientation and resizing it.
209 208
@@ -220,7 +219,7 @@ def process_image(image: Image, new_width: int = 800, new_height: int = 400, sav
220 219 # Remove transparency
221 220 if image.mode == "RGBA":
222 221 image.load()
223 white = open_image('RGB', image.size, (255, 255, 255))
222 white = Image.open('RGB', image.size, (255, 255, 255))
224 223 white.paste(image, mask=image.split()[-1])
225 224 return white
226 225 # Convert to RGB for jpg format