mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Add flags
This commit is contained in:
parent
645b64af35
commit
3161f70c29
4 changed files with 9 additions and 4 deletions
|
|
@ -8,6 +8,9 @@
|
|||
</span>
|
||||
</p>
|
||||
<p align="center">
|
||||
🇷🇺 🇩🇪 🇫🇷 🇮🇹 🇬🇧 🇳🇬 🇪🇬 🇩🇿 🇿🇦 🇰🇪 🇺🇸 🇧🇷 🇨🇦 🇲🇽 🇦🇺
|
||||
</p>
|
||||
<p align="center">
|
||||
<span>Support the project on</span>
|
||||
<a href="https://github.com/sponsors/hlohaus" target="_blank" rel="noopener noreferrer">
|
||||
GitHub Sponsors
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ except ImportError:
|
|||
|
||||
from ... import debug
|
||||
from ...typing import Messages, Cookies, MediaListType, AsyncResult, AsyncIterator
|
||||
from ...providers.response import JsonConversation, Reasoning, RequestLogin, ImageResponse, YouTube, AudioResponse, TitleGeneration
|
||||
from ...providers.response import JsonConversation, Reasoning, RequestLogin, ImageResponse, YouTubeResponse, AudioResponse, TitleGeneration
|
||||
from ...requests.raise_for_status import raise_for_status
|
||||
from ...requests.aiohttp import get_connector
|
||||
from ...requests import get_nodriver
|
||||
|
|
@ -338,7 +338,7 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
pass
|
||||
youtube_ids = youtube_ids if youtube_ids else find_youtube_ids(content)
|
||||
if youtube_ids:
|
||||
yield YouTube(youtube_ids)
|
||||
yield YouTubeResponse(youtube_ids)
|
||||
|
||||
@classmethod
|
||||
async def synthesize(cls, params: dict, proxy: str = None) -> AsyncIterator[bytes]:
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ class Api:
|
|||
yield self._format_json("usage", chunk.get_dict())
|
||||
elif isinstance(chunk, Reasoning):
|
||||
yield self._format_json("reasoning", **chunk.get_dict())
|
||||
elif isinstance(chunk, YouTube):
|
||||
elif isinstance(chunk, YouTubeResponse):
|
||||
yield self._format_json("content", chunk.to_string())
|
||||
elif isinstance(chunk, AudioResponse):
|
||||
yield self._format_json("content", str(chunk), data=chunk.data)
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ class SourceLink(ResponseType):
|
|||
title = f"[{self.title}]"
|
||||
return f" {format_link(self.url, title)}"
|
||||
|
||||
class YouTube(HiddenResponse):
|
||||
class YouTubeResponse(HiddenResponse):
|
||||
def __init__(self, ids: List[str], add_links: bool = False) -> None:
|
||||
"""Initialize with a list of YouTube IDs."""
|
||||
self.ids = ids
|
||||
|
|
@ -295,6 +295,8 @@ class AudioResponse(ResponseType):
|
|||
|
||||
def to_uri(self) -> str:
|
||||
if isinstance(self.data, str):
|
||||
if self.data.startswith("/media/"):
|
||||
return quote(self.data, '/?&=')
|
||||
return self.data
|
||||
"""Return audio data as a base64-encoded data URI."""
|
||||
data_base64 = base64.b64encode(self.data).decode()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue