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

XFEstudio/gpt4free

Add timeout

24f7495f
ostix360 <vicrobin1001@gmail.com>
提交于

代码差异

1 个文件 +6 -1
Modified g4f/Provider/retry_provider.py +6 -1
@@ -1,5 +1,6 @@
1 1 from __future__ import annotations
2 2
3 import asyncio
3 4 import random
4 5 from typing import List, Type, Dict
5 6 from ..typing import CreateResult, Messages
@@ -68,7 +69,11 @@ class RetryProvider(AsyncProvider):
68 69 self.exceptions: Dict[str, Exception] = {}
69 70 for provider in providers:
70 71 try:
71 return await provider.create_async(model, messages, **kwargs)
72 return await asyncio.wait_for(provider.create_async(model, messages, **kwargs), timeout=60)
73 except asyncio.TimeoutError as e:
74 self.exceptions[provider.__name__] = e
75 if logging:
76 print(f"{provider.__name__}: TimeoutError: {e}")
72 77 except Exception as e:
73 78 self.exceptions[provider.__name__] = e
74 79 if logging: