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

XFEstudio/gpt4free

Some updates

1ef46f61
hlohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +11 -17
Modified g4f/Provider/Pollinations.py +6 -5
@@ -32,7 +32,7 @@ from ..tools.run_tools import AuthManager
32 32 from ..cookies import get_cookies_dir
33 33 from ..tools.files import secure_filename
34 34 from ..config import AppConfig
35 from .template.OpenaiTemplate import read_response
35 from .template.OpenaiTemplate import OpenaiTemplate, read_response
36 36 from .. import debug
37 37
38 38
@@ -40,10 +40,9 @@ class Pollinations(AsyncGeneratorProvider, ProviderModelMixin):
40 40 label = "Pollinations 🌸"
41 41 url = "https://pollinations.ai"
42 42 login_url = "https://enter.pollinations.ai"
43 backup_url = "https://g4f.space/api/pollinations"
43 44 active_by_default = True
44 45 working = True
45 supports_system_message = True
46 supports_message_history = True
47 46
48 47 # API endpoints
49 48 text_api_endpoint = "https://text.pollinations.ai/openai"
@@ -318,8 +317,10 @@ class Pollinations(AsyncGeneratorProvider, ProviderModelMixin):
318 317 has_audio = True
319 318 break
320 319 model = "openai-audio" if has_audio else cls.default_model
321 if not api_key:
322 api_key = AuthManager.load_api_key(cls)
320 if AppConfig.disable_custom_api_key:
321 api_key = None
322 if not api_key or api_key.startswith("g4f_") or api_key.startswith("gfs_"):
323 api_key = AuthManager.load_api_key(cls) or api_key
323 324 if cls.get_models(api_key=api_key, timeout=kwargs.get("timeout", 15)):
324 325 if model in cls.model_aliases:
325 326 model = cls.model_aliases[model]
Modified g4f/tools/auth.py +0 -1
@@ -12,7 +12,6 @@ class AuthManager:
12 12
13 13 aliases = {
14 14 "GeminiPro": "Gemini",
15 "PollinationsAI": "Pollinations",
16 15 "OpenaiAPI": "Openai",
17 16 "PuterJS": "Puter",
18 17 }
Modified g4f/tools/run_tools.py +5 -11
@@ -483,19 +483,13 @@ async def async_iter_run_tools(
483 483 usage_dir = Path(get_cookies_dir()) / ".usage"
484 484 usage_file = usage_dir / f"{datetime.date.today()}.jsonl"
485 485 usage_dir.mkdir(parents=True, exist_ok=True)
486 if has_aiofile:
487 async with async_open(usage_file, "a") as f:
488 try:
489 async def write_usage():
490 await f.write(f"{json.dumps(usage)}\n")
491
492 asyncio.create_task(write_usage())
493 except Exception as e:
494 debug.log(f"Failed to write usage asynchronously: {e}")
495 else:
486 try:
496 487 with usage_file.open("a") as f:
497 488 json.dump(usage, f)
498 f.write("\n")
489 f.write(f"{json.dumps(usage)}\n")
490 except Exception as e:
491 debug.log(f"Failed to write usage: {e}")
492
499 493 if completion_tokens > 0:
500 494 provider.live += 1
501 495 except Exception: