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

XFEstudio/gpt4free

Update api module

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

代码差异

2 个文件 +9 -12
Modified g4f/Provider/EasyChat.py +7 -5
@@ -74,6 +74,7 @@ class EasyChat(OpenaiTemplate, AuthFileMixin):
74 74 else:
75 75 debug.error("No 'Agree' button found.")
76 76 for _ in range(3):
77 await asyncio.sleep(1)
77 78 for _ in range(300):
78 79 modal = await page.find("Verifying...")
79 80 if not modal:
@@ -84,11 +85,12 @@ class EasyChat(OpenaiTemplate, AuthFileMixin):
84 85 debug.log("EasyChat: Captcha token found, proceeding.")
85 86 break
86 87 textarea = await page.select("textarea", 180)
87 await textarea.send_keys("Hello")
88 await asyncio.sleep(1)
89 button = await page.select("button[class*='chat_chat-input-send']")
90 if button:
91 await button.click()
88 if textarea is not None:
89 await textarea.send_keys("Hello")
90 await asyncio.sleep(1)
91 button = await page.select("button[class*='chat_chat-input-send']")
92 if button:
93 await button.click()
92 94 for _ in range(300):
93 95 await asyncio.sleep(1)
94 96 if cls.captchaToken:
Modified g4f/api/__init__.py +2 -7
@@ -630,11 +630,12 @@ class Api:
630 630 }
631 631 @self.app.post("/v1/audio/transcriptions", responses=responses)
632 632 @self.app.post("/api/{path_provider}/audio/transcriptions", responses=responses)
633 @self.app.post("/api/markitdown", responses=responses)
633 634 async def convert(
634 635 file: UploadFile,
635 636 path_provider: str = None,
636 637 model: Annotated[Optional[str], Form()] = None,
637 provider: Annotated[Optional[str], Form()] = None,
638 provider: Annotated[Optional[str], Form()] = "MarkItDown",
638 639 prompt: Annotated[Optional[str], Form()] = "Transcribe this audio"
639 640 ):
640 641 provider = provider if path_provider is None else path_provider
@@ -662,12 +663,6 @@ class Api:
662 663 logger.exception(e)
663 664 return ErrorResponse.from_exception(e, None, HTTP_500_INTERNAL_SERVER_ERROR)
664 665
665 @self.app.post("/api/markitdown", responses=responses)
666 async def markitdown(
667 file: UploadFile
668 ):
669 return await convert(file, "MarkItDown")
670
671 666 responses = {
672 667 HTTP_200_OK: {"content": {"audio/*": {}}},
673 668 HTTP_401_UNAUTHORIZED: {"model": ErrorResponseModel},