返回提交历史
Modified
README.md
+3
-0
Modified
g4f/Provider/needs_auth/Gemini.py
+2
-2
Modified
g4f/gui/server/api.py
+1
-1
Modified
g4f/providers/response.py
+3
-1
XFEstudio/gpt4free
Add flags
3161f70c
代码差异
4 个文件
+9
-4
@@ -8,6 +8,9 @@
8
8
</span>
9
9
</p>
10
10
<p align="center">
11
🇷🇺 🇩🇪 🇫🇷 🇮🇹 🇬🇧 🇳🇬 🇪🇬 🇩🇿 🇿🇦 🇰🇪 🇺🇸 🇧🇷 🇨🇦 🇲🇽 🇦🇺
12
</p>
13
<p align="center">
11
14
<span>Support the project on</span>
12
15
<a href="https://github.com/sponsors/hlohaus" target="_blank" rel="noopener noreferrer">
13
16
GitHub Sponsors
@@ -20,7 +20,7 @@ except ImportError:
20
20
21
21
from ... import debug
22
22
from ...typing import Messages, Cookies, MediaListType, AsyncResult, AsyncIterator
23
from ...providers.response import JsonConversation, Reasoning, RequestLogin, ImageResponse, YouTube, AudioResponse, TitleGeneration
23
from ...providers.response import JsonConversation, Reasoning, RequestLogin, ImageResponse, YouTubeResponse, AudioResponse, TitleGeneration
24
24
from ...requests.raise_for_status import raise_for_status
25
25
from ...requests.aiohttp import get_connector
26
26
from ...requests import get_nodriver
@@ -338,7 +338,7 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
338
338
pass
339
339
youtube_ids = youtube_ids if youtube_ids else find_youtube_ids(content)
340
340
if youtube_ids:
341
yield YouTube(youtube_ids)
341
yield YouTubeResponse(youtube_ids)
342
342
343
343
@classmethod
344
344
async def synthesize(cls, params: dict, proxy: str = None) -> AsyncIterator[bytes]:
@@ -244,7 +244,7 @@ class Api:
244
244
yield self._format_json("usage", chunk.get_dict())
245
245
elif isinstance(chunk, Reasoning):
246
246
yield self._format_json("reasoning", **chunk.get_dict())
247
elif isinstance(chunk, YouTube):
247
elif isinstance(chunk, YouTubeResponse):
248
248
yield self._format_json("content", chunk.to_string())
249
249
elif isinstance(chunk, AudioResponse):
250
250
yield self._format_json("content", str(chunk), data=chunk.data)
@@ -268,7 +268,7 @@ class SourceLink(ResponseType):
268
268
title = f"[{self.title}]"
269
269
return f" {format_link(self.url, title)}"
270
270
271
class YouTube(HiddenResponse):
271
class YouTubeResponse(HiddenResponse):
272
272
def __init__(self, ids: List[str], add_links: bool = False) -> None:
273
273
"""Initialize with a list of YouTube IDs."""
274
274
self.ids = ids
@@ -295,6 +295,8 @@ class AudioResponse(ResponseType):
295
295
296
296
def to_uri(self) -> str:
297
297
if isinstance(self.data, str):
298
if self.data.startswith("/media/"):
299
return quote(self.data, '/?&=')
298
300
return self.data
299
301
"""Return audio data as a base64-encoded data URI."""
300
302
data_base64 = base64.b64encode(self.data).decode()