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

XFEstudio/gpt4free

add mode, timeout (#3213)

* Update Yupp.py --------- Co-authored-by: H Lohaus <hlohaus@users.noreply.github.com>

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

代码差异

2 个文件 +12 -6
Deleted g4f.exe +0 -1
@@ -1 +0,0 @@
1 Subproject commit 5595da04099433411b1b81465b945adda35cc47e
Modified g4f/Provider/Yupp.py +12 -5
@@ -214,9 +214,9 @@ class Yupp(AbstractProvider, ProviderModelMixin):
214 214 login_url = "https://discord.gg/qXA4Wf4Fsm"
215 215 working = True
216 216 active_by_default = True
217
217 supports_stream = True
218 218 @classmethod
219 def get_models(cls, api_key: str = None, **kwargs) -> List[Dict[str, Any]]:
219 def get_models(cls, api_key: str = None, **kwargs) -> List[str]:
220 220 if not cls.models:
221 221 if not api_key:
222 222 api_key = AuthManager.load_api_key(cls)
@@ -229,6 +229,8 @@ class Yupp(AbstractProvider, ProviderModelMixin):
229 229 if models:
230 230 cls.models_tags = {model.get("name"): manager.processor.generate_tags(model) for model in models}
231 231 cls.models = [model.get("name") for model in models]
232 cls.image_models = [model.get("name") for model in models if model.get("isImageGeneration")]
233 cls.vision_models = [model.get("name") for model in models if "image/*" in model.get("supportedAttachmentMimeTypes", [])]
232 234 return cls.models
233 235
234 236 @classmethod
@@ -240,10 +242,15 @@ class Yupp(AbstractProvider, ProviderModelMixin):
240 242 api_key: Optional[str] = None,
241 243 prompt: Optional[str] = None,
242 244 conversation: JsonConversation = None,
245 mode:str = "text",
246 timeout:float = 60,
243 247 **kwargs,
244 248 ) -> Generator[str, Any, None]:
245 249 """
246 250 Create completion using Yupp.ai API with account rotation
251 :mode: Mode can be 'text' or 'image'
252
253
247 254 """
248 255 # Initialize Yupp accounts and models
249 256 if not api_key:
@@ -327,7 +334,7 @@ class Yupp(AbstractProvider, ProviderModelMixin):
327 334 files,
328 335 "$undefined",
329 336 [{"modelName": model, "promptModifierId": "$undefined"}] if model else "none",
330 "text",
337 mode,
331 338 True,
332 339 "$undefined",
333 340 ]
@@ -344,7 +351,7 @@ class Yupp(AbstractProvider, ProviderModelMixin):
344 351 False,
345 352 [],
346 353 [{"modelName": model, "promptModifierId": "$undefined"}] if model else [],
347 "text",
354 mode,
348 355 files
349 356 ]
350 357 url = f"https://yupp.ai/chat/{url_uuid}?stream=true"
@@ -361,7 +368,7 @@ class Yupp(AbstractProvider, ProviderModelMixin):
361 368 log_debug(f"Payload structure: {type(payload)}, length: {len(str(payload))}")
362 369
363 370 # Send request
364 response = session.post(url, data=json.dumps(payload), headers=headers, stream=True, timeout=60)
371 response = session.post(url, data=json.dumps(payload), headers=headers, stream=True, timeout=timeout)
365 372 response.raise_for_status()
366 373
367 374 # Attempt to make chat private