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

XFEstudio/gpt4free

Show Audio, hide YouTube response

2799bf72
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

4 个文件 +9 -7
Modified g4f/Provider/PollinationsAI.py +1 -1
@@ -274,7 +274,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
274 274 data.pop("seed")
275 275 if model in cls.audio_models:
276 276 data["voice"] = random.choice(cls.audio_models[model])
277 url = f"{cls.text_api_endpoint}"
277 url = cls.text_api_endpoint
278 278 else:
279 279 url = cls.openai_endpoint
280 280 async with session.post(url, json=data) as response:
Modified g4f/gui/client/static/js/chat.v1.js +1 -1
@@ -440,7 +440,7 @@ const handle_ask = async (do_ask_gpt = true) => {
440 440 <i class="fa-solid fa-xmark"></i>
441 441 <i class="fa-regular fa-phone-arrow-up-right"></i>
442 442 </div>
443 <div class="content" id="user_${message_id}">
443 <div class="content">
444 444 <div class="content_inner">
445 445 ${markdown_render(message)}
446 446 </div>
Modified g4f/gui/server/api.py +3 -1
@@ -216,8 +216,10 @@ class Api:
216 216 yield self._format_json("usage", chunk.get_dict())
217 217 elif isinstance(chunk, Reasoning):
218 218 yield self._format_json("reasoning", **chunk.get_dict())
219 elif isinstance(chunk, YouTube):
220 yield self._format_json("content", chunk.to_string)
219 221 elif isinstance(chunk, Audio):
220 yield self._format_json("audio", chunk.to_string())
222 yield self._format_json("audio", str(chunk))
221 223 elif isinstance(chunk, DebugResponse):
222 224 yield self._format_json("log", chunk.log)
223 225 elif isinstance(chunk, RawResponse):
Modified g4f/providers/response.py +4 -4
@@ -229,12 +229,12 @@ class Sources(ResponseType):
229 229 for idx, link in enumerate(self.list)
230 230 ]))
231 231
232 class YouTube(ResponseType):
232 class YouTube(HiddenResponse):
233 233 def __init__(self, ids: List[str]) -> None:
234 234 """Initialize with a list of YouTube IDs."""
235 235 self.ids = ids
236 236
237 def __str__(self) -> str:
237 def to_string(self) -> str:
238 238 """Return YouTube embeds as a string."""
239 239 if not self.ids:
240 240 return ""
@@ -243,12 +243,12 @@ class YouTube(ResponseType):
243 243 for id in self.ids
244 244 ]))
245 245
246 class Audio(HiddenResponse):
246 class Audio(ResponseType):
247 247 def __init__(self, data: bytes) -> None:
248 248 """Initialize with audio data bytes."""
249 249 self.data = data
250 250
251 def to_string(self) -> str:
251 def __str__(self) -> str:
252 252 """Return audio data as a base64-encoded data URI."""
253 253 data_base64 = base64.b64encode(self.data).decode()
254 254 return f"data:audio/mpeg;base64,{data_base64}"