返回提交历史
Modified
docs/providers-and-models.md
+17
-15
Modified
g4f/Provider/Blackbox.py
+53
-36
Added
g4f/Provider/BlackboxAPI.py
+103
-0
Modified
g4f/Provider/CablyAI.py
+152
-23
Modified
g4f/Provider/__init__.py
+1
-0
Modified
g4f/models.py
+26
-18
XFEstudio/gpt4free
Updated some providers, added new providers and added new models
ec8caec5
代码差异
6 个文件
+352
-92
@@ -39,8 +39,9 @@ This document provides an overview of various AI providers and models, including
39
39
|----------|-------------|--------------|---------------|--------|--------|------|------|
40
40
|[aichatfree.info](https://aichatfree.info)|No auth required|`g4f.Provider.AIChatFree`|`gemini-1.5-pro` _**(1+)**_|❌|❌|✔||
41
41
|[autonomous.ai](https://www.autonomous.ai/anon/)|No auth required|`g4f.Provider.AutonomousAI`|`llama-3.3-70b, qwen-2.5-coder-32b, hermes-3, llama-3.2-90b, llama-3.3-70b, llama-3-2-70b`|✔|❌|✔||
42
|[blackbox.ai](https://www.blackbox.ai)|No auth required|`g4f.Provider.Blackbox`|`blackboxai, gpt-4, gpt-4o, gemini-1.5-flash, gemini-1.5-pro, claude-3.5-sonnet, blackboxai-pro, llama-3.1-8b, llama-3.1-70b, llama-3-1-405b, llama-3.3-70b, mixtral-7b, deepseek-chat, dbrx-instruct, qwq-32b, hermes-2-dpo, deepseek-r1` _**(+31)**_|`flux`|`blackboxai, gpt-4o, gemini-1.5-pro, gemini-1.5-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b`|✔||
43
|[cablyai.com](https://cablyai.com)|No auth required|`g4f.Provider.CablyAI`|`cably-80b`|❌|❌|✔||
42
|[blackbox.ai](https://www.blackbox.ai)|No auth required|`g4f.Provider.Blackbox`|`blackboxai, gemini-1.5-flash, gemini-1.5-pro, blackboxai-pro, llama-3.1-8b, llama-3.1-70b, llama-3-1-405b, llama-3.3-70b, mixtral-small-28b, deepseek-chat, dbrx-instruct, qwq-32b, hermes-2-dpo, deepseek-r1` _**(+34)**_|`flux`|`blackboxai, gpt-4o, gemini-1.5-pro, gemini-1.5-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b`|✔||
43
|[api.blackbox.ai](https://api.blackbox.ai)|No auth required|`g4f.Provider.BlackboxAPI`|`deepseek-v3, deepseek-r1, deepseek-chat, mixtral-small-28b, dbrx-instruct, qwq-32b, hermes-2-dpo`|❌|❌|✔||
44
|[cablyai.com](https://cablyai.com)|Optional API key|`g4f.Provider.CablyAI`|`gpt-4o-mini, llama-3.1-8b, deepseek-v3, deepseek-r1, o3-mini-low` _**(2+)**_|❌|❌|✔||
44
45
|[chatglm.cn](https://chatglm.cn)|No auth required|`g4f.Provider.ChatGLM`|`glm-4`|❌|❌|✔||
45
46
|[chatgpt.com](https://chatgpt.com)|No auth required|`g4f.Provider.ChatGpt`|✔ _**(+7)**_|❌|❌|✔||
46
47
|[chatgpt.es](https://chatgpt.es)|No auth required|`g4f.Provider.ChatGptEs`|`gpt-4, gpt-4o, gpt-4o-mini`|❌|❌|✔||
@@ -126,18 +127,19 @@ This document provides an overview of various AI providers and models, including
126
127
|-------|---------------|-----------|---------|
127
128
|gpt-3|OpenAI|1+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
128
129
|gpt-3.5-turbo|OpenAI|1+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
129
|gpt-4|OpenAI|11+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
130
|gpt-4o|OpenAI|9+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)|
131
|gpt-4o-mini|OpenAI|8+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)|
130
|gpt-4|OpenAI|10+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
131
|gpt-4o|OpenAI|8+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)|
132
|gpt-4o-mini|OpenAI|9+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)|
132
133
|o1|OpenAI|1+ Providers|[openai.com](https://openai.com/index/introducing-openai-o1-preview/)|
133
134
|o1-preview|OpenAI|1+ Providers|[openai.com](https://openai.com/index/introducing-openai-o1-preview/)|
134
135
|o1-mini|OpenAI|1+ Providers|[openai.com](https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning/)|
136
|o3-mini-low|OpenAI|1+ Providers|[openai.com](https://openai.com/index/openai-o3-mini/)|
135
137
|gigachat|GigaChat|1+ Providers|[developers.sber.ru/gigachat](https://developers.sber.ru/gigachat)|
136
138
|meta-ai|Meta|1+ Providers|[ai.meta.com](https://ai.meta.com/)|
137
139
|llama-2-7b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-2-7b)|
138
140
|llama-3-8b|Meta Llama|2+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)|
139
141
|llama-3-70b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Meta-Llama-3-70B)|
140
|llama-3.1-8b|Meta Llama|6+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
142
|llama-3.1-8b|Meta Llama|7+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
141
143
|llama-3.1-70b|Meta Llama|6+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
142
144
|llama-3.1-405b|Meta Llama|2+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.1-405B)|
143
145
|llama-3.2-1b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.2-1B)|
@@ -145,10 +147,10 @@ This document provides an overview of various AI providers and models, including
145
147
|llama-3.2-11b|Meta Llama|3+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)|
146
148
|llama-3.2-90b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.2-90B-Vision)|
147
149
|llama-3.3-70b|Meta Llama|6+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-3/)|
148
|mixtral-7b|Mistral|1+|[mistral.ai](https://mistral.ai/news/mixtral-of-experts/)|
149
150
|mixtral-8x7b|Mistral|2+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-of-experts/)|
150
151
|mistral-nemo|Mistral|3+ Providers|[huggingface.co](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407)|
151
|hermes-2-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)|
152
|mixtral-small-28b|Mistral|2+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-small-28b/)|
153
|hermes-2-dpo|NousResearch|2+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)|
152
154
|phi-3.5-mini|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3.5-mini-instruct)|
153
155
|wizardlm-2-7b|Microsoft|1+ Providers|[wizardlm.github.io](https://wizardlm.github.io/WizardLM2/)|
154
156
|wizardlm-2-8x22b|Microsoft|2+ Providers|[wizardlm.github.io](https://wizardlm.github.io/WizardLM2/)|
@@ -161,7 +163,7 @@ This document provides an overview of various AI providers and models, including
161
163
|claude-3-haiku|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-haiku)|
162
164
|claude-3-sonnet|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
163
165
|claude-3-opus|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
164
|claude-3.5-sonnet|Anthropic|3+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)|
166
|claude-3.5-sonnet|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)|
165
167
|reka-core|Reka AI|1+ Providers|[reka.ai](https://www.reka.ai/ourmodels)|
166
168
|blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
167
169
|blackboxai-pro|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
@@ -174,18 +176,18 @@ This document provides an overview of various AI providers and models, including
174
176
|qwen-2.5-72b|Qwen|3+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2.5-72B-Instruct)|
175
177
|qwen-2.5-coder-32b|Qwen|4+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2.5-Coder-32B)|
176
178
|qwen-2.5-1m-demo|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2.5-1M-Demo)|
177
|qwq-32b|Qwen|4+ Providers|[huggingface.co](https://huggingface.co/Qwen/QwQ-32B-Preview)|
179
|qwq-32b|Qwen|5+ Providers|[huggingface.co](https://huggingface.co/Qwen/QwQ-32B-Preview)|
178
180
|qvq-72b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/QVQ-72B-Preview)|
179
181
|pi|Inflection|1+ Providers|[inflection.ai](https://inflection.ai/blog/inflection-2-5)|
180
|deepseek-chat|DeepSeek|3+ Providers|[huggingface.co](https://huggingface.co/deepseek-ai/deepseek-llm-67b-chat)|
181
|deepseek-v3|DeepSeek|2+ Providers|[api-docs.deepseek.com](https://api-docs.deepseek.com/news/news250120)|
182
|deepseek-r1|DeepSeek|6+ Providers|[api-docs.deepseek.com](https://api-docs.deepseek.com/news/news250120)|
182
|deepseek-chat|DeepSeek|4+ Providers|[huggingface.co](https://huggingface.co/deepseek-ai/deepseek-llm-67b-chat)|
183
|deepseek-v3|DeepSeek|4+ Providers|[api-docs.deepseek.com](https://api-docs.deepseek.com/news/news250120)|
184
|deepseek-r1|DeepSeek|8+ Providers|[api-docs.deepseek.com](https://api-docs.deepseek.com/news/news250120)|
183
185
|grok-2|x.ai|1+|[x.ai](https://x.ai/blog/grok-2)|
184
186
|sonar|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
185
187
|sonar-pro|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
186
188
|sonar-reasoning|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
187
189
|nemotron-70b|Nvidia|3+ Providers|[build.nvidia.com](https://build.nvidia.com/nvidia/llama-3_1-nemotron-70b-instruct)|
188
|dbrx-instruct|Databricks|1+ Providers|[huggingface.co](https://huggingface.co/databricks/dbrx-instruct)|
190
|dbrx-instruct|Databricks|2+ Providers|[huggingface.co](https://huggingface.co/databricks/dbrx-instruct)|
189
191
|p1|PollinationsAI|1+ Providers|[pollinations.ai](https://pollinations.ai/)|
190
192
|cably-80b|CablyAI|1+ Providers|[cablyai.com](https://cablyai.com)|
191
193
|glm-4|THUDM|1+ Providers|[github.com/THUDM](https://github.com/THUDM/GLM-4)|
@@ -193,7 +195,6 @@ This document provides an overview of various AI providers and models, including
193
195
|evil|Evil Mode - Experimental|1+ Providers||
194
196
195
197
---
196
197
198
### Image Models
198
199
| Model | Base Provider | Providers | Website |
199
200
|-------|---------------|-----------|---------|
@@ -207,6 +208,7 @@ This document provides an overview of various AI providers and models, including
207
208
|midjourney|Midjourney|1+ Providers|[docs.midjourney.com](https://docs.midjourney.com/docs/model-versions)|
208
209
209
210
211
210
212
## Conclusion and Usage Tips
211
213
This document provides a comprehensive overview of various AI providers and models available for text generation, image generation, and vision tasks. **When choosing a provider or model, consider the following factors:**
212
214
1. **Availability**: Check the status of the provider to ensure it's currently active and accessible.
@@ -38,16 +38,17 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
38
38
default_model = "blackboxai"
39
39
default_vision_model = default_model
40
40
default_image_model = 'ImageGeneration'
41
image_models = [default_image_model, "ImageGeneration2"]
42
vision_models = [default_vision_model, 'gpt-4o', 'gemini-pro', 'deepseek-v3', 'gemini-1.5-flash', 'llama-3.1-8b', 'llama-3.1-70b', 'llama-3.1-405b']
43
reasoning_models = ['deepseek-r1']
44
45
userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'deepseek-r1', 'deepseek-v3', 'blackboxai-pro']
41
image_models = [default_image_model]
42
vision_models = [default_vision_model, 'gpt-4o', 'o3-mini', 'gemini-pro', 'DeepSeek-V3', 'gemini-1.5-flash', 'llama-3.1-8b', 'llama-3.1-70b', 'llama-3.1-405b']
43
reasoning_models = ['DeepSeek-R1']
44
45
userSelectedModel = ['gpt-4o', 'o3-mini', 'claude-sonnet-3.5', 'gemini-pro', 'blackboxai-pro']
46
46
47
47
agentMode = {
48
'ImageGeneration': {'mode': True, 'id': "ImageGenerationLV45LJp", 'name': "Image Generation"},
48
'DeepSeek-V3': {'mode': True, 'id': "deepseek-chat", 'name': "DeepSeek-V3"},
49
'DeepSeek-R1': {'mode': True, 'id': "deepseek-reasoner", 'name': "DeepSeek-R1"},
49
50
'Meta-Llama-3.3-70B-Instruct-Turbo': {'mode': True, 'id': "meta-llama/Llama-3.3-70B-Instruct-Turbo", 'name': "Meta-Llama-3.3-70B-Instruct-Turbo"},
50
'Mistral-(7B)-Instruct-v0.2': {'mode': True, 'id': "mistralai/Mistral-7B-Instruct-v0.2", 'name': "Mistral-(7B)-Instruct-v0.2"},
51
'Mistral-Small-24B-Instruct-2501': {'mode': True, 'id': "mistralai/Mistral-Small-24B-Instruct-2501", 'name': "Mistral-Small-24B-Instruct-2501"},
51
52
'DeepSeek-LLM-Chat-(67B)': {'mode': True, 'id': "deepseek-ai/deepseek-llm-67b-chat", 'name': "DeepSeek-LLM-Chat-(67B)"},
52
53
'DBRX-Instruct': {'mode': True, 'id': "databricks/dbrx-instruct", 'name': "DBRX-Instruct"},
53
54
'Qwen-QwQ-32B-Preview': {'mode': True, 'id': "Qwen/QwQ-32B-Preview", 'name': "Qwen-QwQ-32B-Preview"},
@@ -96,12 +97,12 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
96
97
models = list(dict.fromkeys([default_model, *userSelectedModel, *reasoning_models, *image_models, *list(agentMode.keys()), *list(trendingAgentMode.keys())]))
97
98
98
99
model_aliases = {
99
"gpt-4": "gpt-4o",
100
100
"gemini-1.5-flash": "gemini-1.5-flash",
101
101
"gemini-1.5-pro": "gemini-pro",
102
"claude-3.5-sonnet": "claude-sonnet-3.5",
102
"deepseek-v3": "DeepSeek-V3",
103
"deepseek-r1": "DeepSeek-R1",
103
104
"llama-3.3-70b": "Meta-Llama-3.3-70B-Instruct-Turbo",
104
"mixtral-7b": "Mistral-(7B)-Instruct-v0.2",
105
"mixtral-small-28b": "Mistral-Small-24B-Instruct-2501",
105
106
"deepseek-chat": "DeepSeek-LLM-Chat-(67B)",
106
107
"dbrx-instruct": "DBRX-Instruct",
107
108
"qwq-32b": "Qwen-QwQ-32B-Preview",
@@ -196,7 +197,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
196
197
}
197
198
198
199
async with ClientSession(headers=headers) as session:
199
if model == "ImageGeneration2":
200
if model in "ImageGeneration":
200
201
prompt = format_image_prompt(messages, prompt)
201
202
data = {
202
203
"query": format_image_prompt(messages, prompt),
@@ -294,32 +295,48 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
294
295
if not text_to_yield or text_to_yield.isspace():
295
296
return
296
297
297
if model in cls.image_models:
298
image_url_match = re.search(r'!\[.*?\]\((.*?)\)', text_to_yield)
299
if image_url_match:
300
image_url = image_url_match.group(1)
301
prompt = format_image_prompt(messages, prompt)
302
yield ImageResponse(images=[image_url], alt=prompt)
303
else:
304
if "Generated by BLACKBOX.AI" in text_to_yield:
305
conversation.validated_value = await cls.fetch_validated(force_refresh=True)
306
if conversation.validated_value:
307
data["validated"] = conversation.validated_value
308
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as new_response:
309
await raise_for_status(new_response)
310
new_response_text = await new_response.text()
311
new_parts = new_response_text.split('$~~~$')
312
new_text = new_parts[2] if len(new_parts) >= 3 else new_response_text
313
314
if new_text and not new_text.isspace():
315
yield new_text
316
else:
317
if text_to_yield and not text_to_yield.isspace():
318
yield text_to_yield
298
if model in cls.reasoning_models and "\n\n\n" in text_to_yield:
299
think_split = text_to_yield.split("\n\n\n", 1)
300
if len(think_split) > 1:
301
think_content, answer = think_split[0].strip(), think_split[1].strip()
302
yield Reasoning(status=think_content)
303
yield answer
304
else:
305
yield text_to_yield
306
elif "<think>" in text_to_yield:
307
pre_think, rest = text_to_yield.split('<think>', 1)
308
think_content, post_think = rest.split('</think>', 1)
309
310
pre_think = pre_think.strip()
311
think_content = think_content.strip()
312
post_think = post_think.strip()
313
314
if pre_think:
315
yield pre_think
316
if think_content:
317
yield Reasoning(status=think_content)
318
if post_think:
319
yield post_think
320
321
elif "Generated by BLACKBOX.AI" in text_to_yield:
322
conversation.validated_value = await cls.fetch_validated(force_refresh=True)
323
if conversation.validated_value:
324
data["validated"] = conversation.validated_value
325
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as new_response:
326
await raise_for_status(new_response)
327
new_response_text = await new_response.text()
328
new_parts = new_response_text.split('$~~~$')
329
new_text = new_parts[2] if len(new_parts) >= 3 else new_response_text
330
331
if new_text and not new_text.isspace():
332
yield new_text
319
333
else:
320
334
if text_to_yield and not text_to_yield.isspace():
321
335
yield text_to_yield
336
else:
337
if text_to_yield and not text_to_yield.isspace():
338
yield text_to_yield
322
339
323
if return_conversation:
324
conversation.message_history.append({"role": "assistant", "content": text_to_yield})
325
yield conversation
340
if return_conversation:
341
conversation.message_history.append({"role": "assistant", "content": text_to_yield})
342
yield conversation
@@ -0,0 +1,103 @@
1
from __future__ import annotations
2
import json
3
from aiohttp import ClientSession
4
5
from ..typing import AsyncResult, Messages
6
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
7
from ..requests.raise_for_status import raise_for_status
8
from ..providers.response import Reasoning
9
from .helper import format_prompt
10
11
class BlackboxAPI(AsyncGeneratorProvider, ProviderModelMixin):
12
label = "Blackbox AI API"
13
url = "https://api.blackbox.ai"
14
api_endpoint = "https://api.blackbox.ai/api/chat"
15
16
working = True
17
needs_auth = False
18
supports_stream = False
19
supports_system_message = True
20
supports_message_history = True
21
22
default_model = 'deepseek-ai/DeepSeek-V3'
23
reasoning_models = ['deepseek-ai/DeepSeek-R1']
24
models = [
25
default_model,
26
'mistralai/Mistral-Small-24B-Instruct-2501',
27
'deepseek-ai/deepseek-llm-67b-chat',
28
'databricks/dbrx-instruct',
29
'Qwen/QwQ-32B-Preview',
30
'NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO'
31
] + reasoning_models
32
33
model_aliases = {
34
"deepseek-v3": "deepseek-ai/DeepSeek-V3",
35
"deepseek-r1": "deepseek-ai/DeepSeek-R1",
36
"deepseek-chat": "deepseek-ai/deepseek-llm-67b-chat",
37
"mixtral-small-28b": "mistralai/Mistral-Small-24B-Instruct-2501",
38
"dbrx-instruct": "databricks/dbrx-instruct",
39
"qwq-32b": "Qwen/QwQ-32B-Preview",
40
"hermes-2-dpo": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
41
}
42
43
@classmethod
44
async def create_async_generator(
45
cls,
46
model: str,
47
messages: Messages,
48
proxy: str = None,
49
max_tokens: str = None,
50
**kwargs
51
) -> AsyncResult:
52
model = cls.get_model(model)
53
54
headers = {
55
"Content-Type": "application/json",
56
}
57
58
async with ClientSession(headers=headers) as session:
59
data = {
60
"messages": messages,
61
"model": model,
62
"max_tokens": max_tokens
63
}
64
65
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
66
await raise_for_status(response)
67
68
is_reasoning = False
69
current_reasoning = ""
70
71
async for chunk in response.content:
72
if not chunk:
73
continue
74
75
text = chunk.decode(errors='ignore')
76
77
if model in cls.reasoning_models:
78
if "<think>" in text:
79
text = text.replace("<think>", "")
80
is_reasoning = True
81
current_reasoning = text
82
continue
83
84
if "</think>" in text:
85
text = text.replace("</think>", "")
86
is_reasoning = False
87
current_reasoning += text
88
yield Reasoning(status=current_reasoning.strip())
89
current_reasoning = ""
90
continue
91
92
if is_reasoning:
93
current_reasoning += text
94
continue
95
96
try:
97
if text:
98
yield text
99
except Exception as e:
100
return
101
102
if is_reasoning and current_reasoning:
103
yield Reasoning(status=current_reasoning.strip())
@@ -1,37 +1,166 @@
1
1
from __future__ import annotations
2
2
3
import json
4
from typing import AsyncGenerator
5
from aiohttp import ClientSession
6
3
7
from ..typing import AsyncResult, Messages
4
from .template import OpenaiTemplate
8
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
9
from ..requests.raise_for_status import raise_for_status
10
from ..providers.response import FinishReason, Reasoning
11
5
12
6
class CablyAI(OpenaiTemplate):
13
class CablyAI(AsyncGeneratorProvider, ProviderModelMixin):
14
label = "CablyAI"
7
15
url = "https://cablyai.com"
8
login_url = None
9
needs_auth = False
10
api_base = "https://cablyai.com/v1"
16
api_endpoint = "https://cablyai.com/v1/chat/completions"
17
api_key = "sk-your-openai-api-key"
18
11
19
working = True
12
13
default_model = "Cably-80B"
14
models = [default_model]
15
model_aliases = {"cably-80b": default_model}
20
needs_auth = False
21
supports_stream = True
22
supports_system_message = True
23
supports_message_history = True
24
25
default_model = 'gpt-4o-mini'
26
reasoning_models = ['deepseek-r1-uncensored']
27
models = [
28
default_model,
29
'searchgpt',
30
'llama-3.1-8b-instruct',
31
'deepseek-v3',
32
'tinyswallow1.5b',
33
'andy-3.5',
34
'o3-mini-low',
35
] + reasoning_models
36
37
model_aliases = {
38
"gpt-4o-mini": "searchgpt",
39
"llama-3.1-8b": "llama-3.1-8b-instruct",
40
"deepseek-r1": "deepseek-r1-uncensored",
41
}
16
42
17
43
@classmethod
18
def create_async_generator(
44
async def create_async_generator(
19
45
cls,
20
46
model: str,
21
47
messages: Messages,
48
api_key: str = None,
49
stream: bool = True,
50
proxy: str = None,
22
51
**kwargs
23
) -> AsyncResult:
52
) -> AsyncResult:
53
model = cls.get_model(model)
54
api_key = api_key or cls.api_key
55
24
56
headers = {
25
'Accept': '*/*',
26
'Accept-Language': 'en-US,en;q=0.9',
27
'Content-Type': 'application/json',
28
'Origin': 'https://cablyai.com',
29
'Referer': 'https://cablyai.com/chat',
30
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
57
"Accept": "*/*",
58
"Accept-Language": "en-US,en;q=0.9",
59
"Authorization": f"Bearer {api_key}",
60
"Content-Type": "application/json",
61
"Origin": cls.url,
62
"Referer": f"{cls.url}/chat",
63
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
31
64
}
32
return super().create_async_generator(
33
model=model,
34
messages=messages,
35
headers=headers,
36
**kwargs
37
)
65
66
async with ClientSession(headers=headers) as session:
67
data = {
68
"model": model,
69
"messages": messages,
70
"stream": stream
71
}
72
73
async with session.post(
74
cls.api_endpoint,
75
json=data,
76
proxy=proxy
77
) as response:
78
await raise_for_status(response)
79
80
if stream:
81
reasoning_buffer = []
82
in_reasoning = False
83
84
async for line in response.content:
85
if not line:
86
continue
87
88
line = line.decode('utf-8').strip()
89
print(line)
90
91
if not line.startswith("data: "):
92
continue
93
94
if line == "data: [DONE]":
95
if in_reasoning and reasoning_buffer:
96
yield Reasoning(status="".join(reasoning_buffer).strip())
97
yield FinishReason("stop")
98
return
99
100
try:
101
json_data = json.loads(line[6:])
102
delta = json_data["choices"][0].get("delta", {})
103
content = delta.get("content", "")
104
finish_reason = json_data["choices"][0].get("finish_reason")
105
106
if finish_reason:
107
if in_reasoning and reasoning_buffer:
108
yield Reasoning(status="".join(reasoning_buffer).strip())
109
yield FinishReason(finish_reason)
110
return
111
112
if model in cls.reasoning_models:
113
# Processing the beginning of a tag
114
if "<think>" in content:
115
pre, _, post = content.partition("<think>")
116
if pre:
117
yield pre
118
in_reasoning = True
119
content = post
120
121
# Tag end processing
122
if "</think>" in content:
123
in_reasoning = False
124
thought, _, post = content.partition("</think>")
125
if thought:
126
reasoning_buffer.append(thought)
127
if reasoning_buffer:
128
yield Reasoning(status="".join(reasoning_buffer).strip())
129
reasoning_buffer.clear()
130
if post:
131
yield post
132
continue
133
134
# Buffering content inside tags
135
if in_reasoning:
136
reasoning_buffer.append(content)
137
else:
138
if content:
139
yield content
140
else:
141
if content:
142
yield content
143
144
except json.JSONDecodeError:
145
continue
146
except Exception:
147
yield FinishReason("error")
148
return
149
else:
150
try:
151
response_data = await response.json()
152
message = response_data["choices"][0]["message"]
153
content = message["content"]
154
155
if model in cls.reasoning_models and "<think>" in content:
156
think_start = content.find("<think>") + 7
157
think_end = content.find("</think>")
158
if think_start > 6 and think_end > 0:
159
reasoning = content[think_start:think_end].strip()
160
yield Reasoning(status=reasoning)
161
content = content[think_end + 8:].strip()
162
163
yield content
164
yield FinishReason("stop")
165
except Exception:
166
yield FinishReason("error")
@@ -15,6 +15,7 @@ from .mini_max import HailuoAI, MiniMax
15
15
from .template import OpenaiTemplate, BackendApi
16
16
17
17
from .Blackbox import Blackbox
18
from .BlackboxAPI import BlackboxAPI
18
19
from .CablyAI import CablyAI
19
20
from .ChatGLM import ChatGLM
20
21
from .ChatGpt import ChatGpt
@@ -6,6 +6,7 @@ from .Provider import IterListProvider, ProviderType
6
6
from .Provider import (
7
7
### no auth required ###
8
8
Blackbox,
9
BlackboxAPI,
9
10
CablyAI,
10
11
ChatGLM,
11
12
ChatGptEs,
@@ -123,20 +124,20 @@ gpt_35_turbo = Model(
123
124
gpt_4 = Model(
124
125
name = 'gpt-4',
125
126
base_provider = 'OpenAI',
126
best_provider = IterListProvider([DDG, Blackbox, Jmuz, ChatGptEs, ChatGptt, PollinationsAI, Yqcloud, Copilot, OpenaiChat, Liaobots, Mhystical])
127
best_provider = IterListProvider([DDG, Jmuz, ChatGptEs, ChatGptt, PollinationsAI, Yqcloud, Copilot, OpenaiChat, Liaobots, Mhystical])
127
128
)
128
129
129
130
# gpt-4o
130
131
gpt_4o = VisionModel(
131
132
name = 'gpt-4o',
132
133
base_provider = 'OpenAI',
133
best_provider = IterListProvider([Blackbox, ChatGptt, Jmuz, ChatGptEs, PollinationsAI, DarkAI, Copilot, Liaobots, OpenaiChat])
134
best_provider = IterListProvider([ChatGptt, Jmuz, ChatGptEs, PollinationsAI, DarkAI, Copilot, Liaobots, OpenaiChat])
134
135
)
135
136
136
137
gpt_4o_mini = Model(
137
138
name = 'gpt-4o-mini',
138
139
base_provider = 'OpenAI',
139
best_provider = IterListProvider([DDG, ChatGptEs, ChatGptt, Jmuz, PollinationsAI, OIVSCode, Liaobots, OpenaiChat])
140
best_provider = IterListProvider([DDG, ChatGptEs, ChatGptt, Jmuz, PollinationsAI, OIVSCode, CablyAI, Liaobots, OpenaiChat])
140
141
)
141
142
142
143
# o1
@@ -158,6 +159,13 @@ o1_mini = Model(
158
159
best_provider = Liaobots
159
160
)
160
161
162
# o3
163
o3_mini_low = Model(
164
name = 'o3-mini-low',
165
base_provider = 'OpenAI',
166
best_provider = CablyAI
167
)
168
161
169
### GigaChat ###
162
170
gigachat = Model(
163
171
name = 'GigaChat:latest',
@@ -195,7 +203,7 @@ llama_3_70b = Model(
195
203
llama_3_1_8b = Model(
196
204
name = "llama-3.1-8b",
197
205
base_provider = "Meta Llama",
198
best_provider = IterListProvider([Blackbox, DeepInfraChat, Glider, Jmuz, PollinationsAI, Cloudflare])
206
best_provider = IterListProvider([Blackbox, DeepInfraChat, Glider, Jmuz, PollinationsAI, CablyAI, Cloudflare])
199
207
)
200
208
201
209
llama_3_1_70b = Model(
@@ -243,12 +251,6 @@ llama_3_3_70b = Model(
243
251
)
244
252
245
253
### Mistral ###
246
mixtral_7b = Model(
247
name = "mixtral-7b",
248
base_provider = "Mistral",
249
best_provider = Blackbox
250
)
251
252
254
mixtral_8x7b = Model(
253
255
name = "mixtral-8x7b",
254
256
base_provider = "Mistral",
@@ -261,11 +263,17 @@ mistral_nemo = Model(
261
263
best_provider = IterListProvider([PollinationsAI, HuggingChat, HuggingFace])
262
264
)
263
265
266
mixtral_small_28b = Model(
267
name = "mixtral-small-28b",
268
base_provider = "Mistral",
269
best_provider = IterListProvider([Blackbox, BlackboxAPI])
270
)
271
264
272
### NousResearch ###
265
273
hermes_2_dpo = Model(
266
274
name = "hermes-2-dpo",
267
275
base_provider = "NousResearch",
268
best_provider = Blackbox
276
best_provider = IterListProvider([Blackbox, BlackboxAPI])
269
277
)
270
278
271
279
@@ -356,7 +364,7 @@ claude_3_opus = Model(
356
364
claude_3_5_sonnet = Model(
357
365
name = 'claude-3.5-sonnet',
358
366
base_provider = 'Anthropic',
359
best_provider = IterListProvider([Blackbox, Jmuz, Liaobots])
367
best_provider = IterListProvider([Jmuz, Liaobots])
360
368
)
361
369
362
370
### Reka AI ###
@@ -434,7 +442,7 @@ qwen_2_5_1m = Model(
434
442
qwq_32b = Model(
435
443
name = 'qwq-32b',
436
444
base_provider = 'Qwen',
437
best_provider = IterListProvider([Blackbox, DeepInfraChat, Jmuz, HuggingChat])
445
best_provider = IterListProvider([Blackbox, BlackboxAPI, DeepInfraChat, Jmuz, HuggingChat])
438
446
)
439
447
qvq_72b = VisionModel(
440
448
name = 'qvq-72b',
@@ -453,19 +461,19 @@ pi = Model(
453
461
deepseek_chat = Model(
454
462
name = 'deepseek-chat',
455
463
base_provider = 'DeepSeek',
456
best_provider = IterListProvider([Blackbox, Jmuz, PollinationsAI])
464
best_provider = IterListProvider([Blackbox, BlackboxAPI, Jmuz, PollinationsAI])
457
465
)
458
466
459
467
deepseek_v3 = Model(
460
468
name = 'deepseek-v3',
461
469
base_provider = 'DeepSeek',
462
best_provider = IterListProvider([Blackbox, DeepInfraChat])
470
best_provider = IterListProvider([Blackbox, BlackboxAPI, DeepInfraChat, CablyAI])
463
471
)
464
472
465
473
deepseek_r1 = Model(
466
474
name = 'deepseek-r1',
467
475
base_provider = 'DeepSeek',
468
best_provider = IterListProvider([Blackbox, Glider, PollinationsAI, Jmuz, HuggingChat, HuggingFace])
476
best_provider = IterListProvider([Blackbox, BlackboxAPI, Glider, PollinationsAI, Jmuz, CablyAI, HuggingChat, HuggingFace])
469
477
)
470
478
471
479
### x.ai ###
@@ -505,7 +513,7 @@ nemotron_70b = Model(
505
513
dbrx_instruct = Model(
506
514
name = 'dbrx-instruct',
507
515
base_provider = 'Databricks',
508
best_provider = Blackbox
516
best_provider = IterListProvider([Blackbox, BlackboxAPI])
509
517
)
510
518
511
519
### PollinationsAI ###
@@ -657,9 +665,9 @@ class ModelUtils:
657
665
llama_3_3_70b.name: llama_3_3_70b,
658
666
659
667
### Mistral ###
660
mixtral_7b.name: mixtral_7b,
661
668
mixtral_8x7b.name: mixtral_8x7b,
662
669
mistral_nemo.name: mistral_nemo,
670
mixtral_small_28b.name: mixtral_small_28b,
663
671
664
672
### NousResearch ###
665
673
hermes_2_dpo.name: hermes_2_dpo,