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

XFEstudio/gpt4free

Update OpenaiChat.py

5dbc0f74
Ammar <ammar.alkotb@gmail.com>
提交于

代码差异

1 个文件 +4 -4
Modified g4f/Provider/needs_auth/OpenaiChat.py +4 -4
@@ -283,7 +283,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
283 283 return messages
284 284
285 285 @classmethod
286 async def get_generated_image(cls, session: StreamSession, auth_result: AuthResult, element: Union[dict, str], prompt: str = None, conversation_id: str = None, status:str="loading") -> ImagePreview|ImageResponse|None:
286 async def get_generated_image(cls, session: StreamSession, auth_result: AuthResult, element: Union[dict, str], prompt: str = None, conversation_id: str = None, status: Optional[str]=None) -> ImagePreview|ImageResponse|None:
287 287 download_urls = []
288 288 is_sediment = False
289 289 if prompt is None:
@@ -319,8 +319,8 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
319 319 debug.error("OpenaiChat: Download image failed")
320 320 debug.error(e)
321 321 if download_urls:
322 # status = loading, finished_successfully
323 if is_sediment and status == "loading":
322 # status = None, finished_successfully
323 if is_sediment and status is None:
324 324 return ImagePreview(download_urls, prompt, {"status": status, "headers": auth_result.headers})
325 325 else:
326 326 return ImageResponse(download_urls, prompt, {"status": status, "headers": auth_result.headers})
@@ -710,7 +710,7 @@ class OpenaiChat(AsyncAuthedProvider, ProviderModelMixin):
710 710 elif m.get("p") == "/message/metadata/image_gen_title":
711 711 fields.prompt = m.get("v")
712 712 elif m.get("p") == "/message/content/parts/0/asset_pointer":
713 status = next(filter(lambda x:x.get("p") == '/message/status' ,v), {}).get('v', "loading")
713 status = next(filter(lambda x:x.get("p") == '/message/status' ,v), {}).get('v', None)
714 714 generated_images = fields.generated_images = await cls.get_generated_image(session, auth_result, m.get("v"), fields.prompt, fields.conversation_id, status)
715 715 if generated_images is not None:
716 716 if buffer: