返回提交历史
Modified
g4f/providers/base_provider.py
+9
-4
XFEstudio/gpt4free
Check quota
2ccdec26
代码差异
1 个文件
+9
-4
@@ -20,7 +20,7 @@ from .types import BaseProvider
20
20
from .asyncio import to_sync_generator, to_async_iterator
21
21
from .response import BaseConversation, AuthResult
22
22
from ..cookies import get_cookies_dir
23
from ..requests import raise_for_status, StreamSession
23
from ..requests import raise_for_status
24
24
from ..errors import (
25
25
ResponseError,
26
26
MissingAuthError,
@@ -326,9 +326,14 @@ class AsyncGeneratorProvider(AbstractProvider):
326
326
"""Get the quota information for the API key."""
327
327
if not api_key and cls.needs_auth:
328
328
raise MissingAuthError("API key is required.")
329
raise NotImplementedError(
330
f"{cls.__name__} does not implement get_quota method"
331
)
329
if not cls.quota_url:
330
raise NotImplementedError(
331
f"{cls.__name__} does not implement get_quota method"
332
)
333
async with ClientSession() as session:
334
async with session.get(cls.quota_url, headers={"Authorization": f"Bearer {api_key}"} if api_key else None) as response:
335
await raise_for_status(response)
336
return await response.json()
332
337
333
338
@staticmethod
334
339
@abstractmethod