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

XFEstudio/gpt4free

Refactor PollinationsAI endpoints and clean up ClientFactory documentation

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

代码差异

2 个文件 +8 -16
Modified g4f/Provider/PollinationsAI.py +5 -6
@@ -30,7 +30,6 @@ DEFAULT_HEADERS = {
30 30 "accept": "*/*",
31 31 'accept-language': 'en-US,en;q=0.9',
32 32 "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
33 "referer": "https://pollinations.ai/",
34 33 "origin": "https://pollinations.ai",
35 34 }
36 35
@@ -48,8 +47,8 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
48 47 image_api_endpoint = "https://g4f.dev/prompt/{}"
49 48 gen_image_api_endpoint = "https://gen.pollinations.ai/image/{}"
50 49 gen_text_api_endpoint = "https://gen.pollinations.ai/v1/chat/completions"
51 gen_image_models_endpoint = "https://gen.pollinations.ai/image/models"
52 gen_text_models_endpoint = "https://gen.pollinations.ai/text/models"
50 image_models_endpoint = "https://gen.pollinations.ai/image/models"
51 text_models_endpoint = "https://gen.pollinations.ai/text/models"
53 52
54 53 # Models configuration
55 54 default_model = "openai"
@@ -107,7 +106,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
107 106 debug.error(f"Failed to load cached models from {path}: {e}")
108 107 try:
109 108 # Update of image models
110 image_response = requests.get(cls.gen_image_models_endpoint, timeout=timeout)
109 image_response = requests.get(cls.image_models_endpoint, timeout=timeout)
111 110 if image_response.ok:
112 111 new_image_models = image_response.json()
113 112 else:
@@ -128,9 +127,9 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
128 127 cls.image_models = image_models
129 128 cls.video_models = [get_alias(model) for model in new_image_models if isinstance(model, dict) and "video" in model.get("output_modalities", [])]
130 129
131 text_response = requests.get(cls.gen_text_models_endpoint, timeout=timeout)
130 text_response = requests.get(cls.text_models_endpoint, timeout=timeout)
132 131 if not text_response.ok:
133 text_response = requests.get(cls.gen_text_models_endpoint, timeout=timeout)
132 text_response = requests.get(cls.text_models_endpoint, timeout=timeout)
134 133 text_response.raise_for_status()
135 134 models = text_response.json()
136 135
Modified g4f/client/__init__.py +3 -10
@@ -802,17 +802,13 @@ class ClientFactory:
802 802
803 803 Supports:
804 804 - Named providers (e.g., "PollinationsAI", "DeepInfra")
805 - Multiple providers (space-separated string or list)
806 805 - Custom providers with custom API base URLs
807 806 - Live providers (dynamically loaded providers)
808 807
809 808 Example usage:
810 809 # Create client with a named provider
811 810 client = ClientFactory.create_client("PollinationsAI")
812
813 # Create client with multiple providers (fallback)
814 client = ClientFactory.create_client(["PollinationsAI", "DeepInfra"])
815
811
816 812 # Create client with custom provider
817 813 client = ClientFactory.create_client(
818 814 base_url="https://api.example.com/v1",
@@ -911,10 +907,7 @@ class ClientFactory:
911 907 Example:
912 908 # Named provider
913 909 client = ClientFactory.create_client("PollinationsAI")
914
915 # Multiple providers (fallback)
916 client = ClientFactory.create_client(["PollinationsAI", "DeepInfra"])
917
910
918 911 # Custom provider
919 912 client = ClientFactory.create_client(
920 913 base_url="https://api.openai.com/v1",
@@ -965,7 +958,7 @@ class ClientFactory:
965 958 )
966 959 """
967 960 return AsyncClient(
968 provider=cls.createProvider(provider, base_url, api_key, **kwargs),
961 provider=cls.create_provider(provider, base_url, api_key, **kwargs),
969 962 media_provider=media_provider,
970 963 api_key=api_key,
971 964 base_url=base_url,