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

XFEstudio/gpt4free

Fix conflicts

63c68c12
kqlio67 <>
提交于

代码差异

9 个文件 +262 -380
Modified docs/providers-and-models.md +23 -17
@@ -20,9 +20,9 @@ This document provides an overview of various AI providers and models, including
20 20 ### Providers Free
21 21 | Website | Provider | Text Models | Image Models | Vision Models | Stream | Status | Auth |
22 22 |----------|-------------|--------------|---------------|--------|--------|------|------|
23 |[api.airforce](https://api.airforce)|`g4f.Provider.Airforce`|`phi-2, gpt-4, gpt-4o-mini, gpt-4o, gpt-4-turbo, o1-mini, openchat-3.5, deepseek-coder, hermes-2-dpo, hermes-2-pro, openhermes-2.5, lfm-40b, german-7b, llama-2-7b, llama-3.1-8b, llama-3.1-70b, neural-7b, zephyr-7b, evil,`|`sdxl, flux-pro, flux, flux-realism, flux-anime, flux-3d, flux-disney, flux-pixel, flux-4o, any-dark, midjourney, dall-e-3`|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌+✔|
23 |[api.airforce](https://api.airforce)|`g4f.Provider.Airforce`|`phi-2, openchat-3.5, deepseek-coder, hermes-2-dpo, hermes-2-pro, openhermes-2.5, lfm-40b, german-7b, llama-2-7b, llama-3.1-8b, llama-3.1-70b, neural-7b, zephyr-7b, evil,`|`sdxl, flux-pro, flux, flux-realism, flux-anime, flux-3d, flux-disney, flux-pixel, flux-4o, any-dark, midjourney, dall-e-3`|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌+✔|
24 24 |[amigochat.io](https://amigochat.io/chat/)|`g4f.Provider.AmigoChat`|✔|✔|❌|✔|![Error](https://img.shields.io/badge/RateLimit-f48d37)|❌|
25 |[blackbox.ai](https://www.blackbox.ai)|`g4f.Provider.Blackbox`|`blackboxai, gpt-4, gpt-4o, gemini-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`|`flux`|`blackboxai, gpt-4o, gemini-pro, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b`|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌|
25 |[blackbox.ai](https://www.blackbox.ai)|`g4f.Provider.Blackbox`|`blackboxai, gpt-4, gpt-4o, gemini-pro, claude-3.5-sonnet, blackboxai-pro, llama-3.1-8b, llama-3.1-70b, llama-3.3-70b, mixtral-7b, deepseek-chat, dbrx-instruct, qwq-32b, hermes-2-dpo`|`flux`|`blackboxai, gpt-4o, gemini-pro, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b`|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌|
26 26 |[blackbox.ai](https://www.blackbox.ai)|`g4f.Provider.BlackboxCreateAgent`|`llama-3.1-70b`|`flux`|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌|
27 27 |[chatgpt.com](https://chatgpt.com)|`g4f.Provider.ChatGpt`|✔|❌|❌|✔|![Error](https://img.shields.io/badge/HTTPError-f48d37)|❌|
28 28 |[chatgpt.es](https://chatgpt.es)|`g4f.Provider.ChatGptEs`|`gpt-4, gpt-4o, gpt-4o-mini`|❌|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌|
@@ -58,6 +58,7 @@ This document provides an overview of various AI providers and models, including
58 58 ### Providers Needs Auth
59 59 | Provider | Text Models | Image Models | Vision Models | Stream | Status | Auth |
60 60 |----------|-------------|--------------|---------------|--------|--------|------|
61 |[bing.com/images/create](https://www.bing.com/images/create)|`g4f.Provider.Anthropic`|✔|❌|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|✔|
61 62 |[bing.com/images/create](https://www.bing.com/images/create)|`g4f.Provider.BingCreateImages`|❌|`dall-e-3`|❌|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
62 63 |[inference.cerebras.ai](https://inference.cerebras.ai/)|`g4f.Provider.Cerebras`|✔|❌|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌|
63 64 |[deepinfra.com](https://deepinfra.com)|`g4f.Provider.DeepInfra`|✔|❌|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|✔|
@@ -65,6 +66,7 @@ This document provides an overview of various AI providers and models, including
65 66 |[gemini.google.com](https://gemini.google.com)|`g4f.Provider.Gemini`|`gemini`|`gemini`|`gemini`|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
66 67 |[ai.google.dev](https://ai.google.dev)|`g4f.Provider.GeminiPro`|`gemini-pro`|❌|`gemini-pro`|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
67 68 |[github.com/copilot](https://github.com/copilot)|`g4f.Provider.GithubCopilot`|✔|❌|❌|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
69 |[glhf.chat](https://glhf.chat)|`g4f.Provider.GlhfChat`|✔|❌|❌|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
68 70 |[console.groq.com/playground](https://console.groq.com/playground)|`g4f.Provider.Groq`|✔|❌|✔|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
69 71 |[huggingface.co/chat](https://huggingface.co/chat)|`g4f.Provider.HuggingChat`|`qwen-2.5-72b, llama-3.3-70b, command-r-plus, qwq-32b, nemotron-70b, nemotron-70b, llama-3.2-11b, hermes-3, mistral-nemo, phi-3.5-mini`|`flux-dev`|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|✔|
70 72 |[huggingface.co/chat](https://huggingface.co/chat)|`g4f.Provider.HuggingFace`|✔|✔|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|✔|
@@ -89,19 +91,21 @@ This document provides an overview of various AI providers and models, including
89 91 ### Text Models
90 92 | Model | Base Provider | Providers | Website |
91 93 |-------|---------------|-----------|---------|
92 |gpt_35_turbo|OpenAI|2+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
94 |gpt-3|OpenAI|2+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
95 |gpt-3.5-turbo|OpenAI|2+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
93 96 |gpt-4|OpenAI|8+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
94 |gpt-4-turbo|OpenAI|1+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
95 |gpt-4o|OpenAI|8+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)|
96 |gpt-4o-mini|OpenAI|8+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)|
97 |gpt-4o|OpenAI|7+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)|
98 |gpt-4o-mini|OpenAI|7+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)|
99 |o1|OpenAI|1+ Providers|[platform.openai.com](https://openai.com/index/introducing-openai-o1-preview/)|
97 100 |o1-preview|OpenAI|1+ Providers|[platform.openai.com](https://openai.com/index/introducing-openai-o1-preview/)|
98 |o1-mini|OpenAI|2+ Providers|[platform.openai.com](https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning/)|
101 |o1-mini|OpenAI|1+ Providers|[platform.openai.com](https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning/)|
99 102 |gigachat||1+ Providers|[]( )|
103 |meta-ai|Meta|1+ Providers|[ai.meta.com](https://ai.meta.com/)|
100 104 |llama-2-7b|Meta Llama|2+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-2-7b)|
101 105 |llama-3-8b|Meta Llama|1+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)|
102 106 |llama-3.1-8b|Meta Llama|5+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
103 |llama-3.1-70b|Meta Llama|12+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
104 |llama-3.1-405b|Meta Llama|1+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
107 |llama-3.1-70b|Meta Llama|10+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
108 |llama-3.2-1b|Meta Llama|2+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.2-1B)|
105 109 |llama-3.2-11b|Meta Llama|2+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)|
106 110 |llama-3.3-70b|Meta Llama|4+ Providers|[llama.com/]()|
107 111 |mixtral-7b|Mistral AI|1+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-of-experts/)|
@@ -110,22 +114,23 @@ This document provides an overview of various AI providers and models, including
110 114 |mistral-large|Mistral AI|1+ Providers|[mistral.ai](https://mistral.ai/news/mistral-large-2407/)|
111 115 |hermes-2-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)|
112 116 |hermes-2-pro|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B)|
113 |hermes-3|NousResearch|1+ Providers|[nousresearch.com](https://nousresearch.com/hermes3/)|
117 |hermes-3|NousResearch|2+ Providers|[nousresearch.com](https://nousresearch.com/hermes3/)|
118 |phi-2|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/phi-2)|
119 |phi-3.5-mini|Microsoft|2+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3.5-mini-instruct)|
114 120 |gemini|Google DeepMind|1+ Providers|[deepmind.google](http://deepmind.google/technologies/gemini/)|
115 121 |gemini-flash|Google DeepMind|4+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/flash/)|
116 |gemini-pro|Google DeepMind|5+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/pro/)|
122 |gemini-pro|Google DeepMind|4+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/pro/)|
117 123 |gemma-2b|Google|1+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2b)|
118 124 |claude-3-haiku|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-haiku)|
119 125 |claude-3-sonnet|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
120 126 |claude-3-opus|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
121 |claude-3.5-sonnet|Anthropic|3+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)|
127 |claude-3.5-sonnet|Anthropic|4+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)|
122 128 |reka-core|Reka AI|1+ Providers|[reka.ai](https://www.reka.ai/ourmodels)|
123 129 |blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
124 130 |blackboxai-pro|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
125 131 |command-r-plus|CohereForAI|1+ Providers|[docs.cohere.com](https://docs.cohere.com/docs/command-r-plus)|
126 132 |command-r|CohereForAI|1+ Providers|[docs.cohere.com](https://docs.cohere.com/docs/command-r-plus)|
127 |qwen|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen)|
128 |qwen-1.5-7b|Qwen|2+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-7B)|
133 |qwen-1.5-7b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-7B)|
129 134 |qwen-2-72b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2-72B)|
130 135 |qwen-2.5-72b|Qwen|2+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2.5-72B-Instruct)|
131 136 |qwen-2.5-coder-32b|Qwen|4+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2.5-Coder-32B)|
@@ -136,7 +141,7 @@ This document provides an overview of various AI providers and models, including
136 141 |wizardlm-2-8x22b|WizardLM|1+ Providers|[huggingface.co](https://huggingface.co/alpindale/WizardLM-2-8x22B)|
137 142 |openchat-3.5|OpenChat|1+ Providers|[huggingface.co](https://huggingface.co/openchat/openchat_3.5)|
138 143 |grok-beta|x.ai|1+ Providers|[x.ai](https://x.ai/blog/grok-2)|
139 |sonar-online|Perplexity AI|2+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
144 |sonar-online|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
140 145 |sonar-chat|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
141 146 |nemotron-70b|Nvidia|3+ Providers|[build.nvidia.com](https://build.nvidia.com/nvidia/llama-3_1-nemotron-70b-instruct)|
142 147 |openhermes-2.5|Teknium|1+ Providers|[huggingface.co](https://huggingface.co/datasets/teknium/OpenHermes-2.5)|
@@ -146,6 +151,7 @@ This document provides an overview of various AI providers and models, including
146 151 |neural-7b|Inferless|1+ Providers|[huggingface.co](https://huggingface.co/Intel/neural-chat-7b-v3-1)|
147 152 |p1|PollinationsAI|1+ Providers|[]( )|
148 153 |dbrx-instruct|Databricks|1+ Providers|[huggingface.co](https://huggingface.co/databricks/dbrx-instruct)|
154 |p1|PollinationsAI|1+ Providers|[]()|
149 155 |evil|Evil Mode - Experimental|2+ Providers|[]( )|
150 156 |midijourney||1+ Providers|[]( )|
151 157 |turbo||1+ Providers|[]( )|
@@ -164,6 +170,7 @@ This document provides an overview of various AI providers and models, including
164 170 |flux|Black Forest Labs|4+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)|
165 171 |flux-pro|Black Forest Labs|2+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)|
166 172 |flux-dev|Black Forest Labs|3+ Providers|[huggingface.co](https://huggingface.co/black-forest-labs/FLUX.1-dev)|
173 |flux-schnell|Black Forest Labs|2+ Providers|[huggingface.co](https://huggingface.co/black-forest-labs/FLUX.1-schnell)|
167 174 |flux-realism|Flux AI|2+ Providers|[]( )|
168 175 |flux-cablyai|Flux AI|1+ Providers|[]( )|
169 176 |flux-anime|Flux AI|2+ Providers|[]( )|
@@ -171,8 +178,7 @@ This document provides an overview of various AI providers and models, including
171 178 |flux-disney|Flux AI|1+ Providers|[]( )|
172 179 |flux-pixel|Flux AI|1+ Providers|[]( )|
173 180 |flux-4o|Flux AI|1+ Providers|[]( )|
174 |flux-schnell|Black Forest Labs|1+ Providers|[huggingface.co](https://huggingface.co/black-forest-labs/FLUX.1-schnell)|
175 |dall-e-3|OpenAI|5+ Providers|[openai.com](https://openai.com/index/dall-e/)|
181 |dall-e-3|OpenAI|6+ Providers|[openai.com](https://openai.com/index/dall-e/)|
176 182 |midjourney|Midjourney|2+ Providers|[docs.midjourney.com](https://docs.midjourney.com/docs/model-versions)|
177 183 |any-dark||2+ Providers|[]( )|
178 184
Modified g4f/Provider/Airforce.py +0 -1
@@ -45,7 +45,6 @@ class Airforce(AsyncGeneratorProvider, ProviderModelMixin):
45 45 additional_models_imagine = ["flux-1.1-pro", "midjourney", "dall-e-3"]
46 46 model_aliases = {
47 47 # Alias mappings for models
48 "gpt-4": "gpt-4o",
49 48 "openchat-3.5": "openchat-3.5-0106",
50 49 "deepseek-coder": "deepseek-coder-6.7b-instruct",
51 50 "hermes-2-dpo": "Nous-Hermes-2-Mixtral-8x7B-DPO",
Modified g4f/Provider/Blackbox.py +187 -232
@@ -1,42 +1,95 @@
1 1 from __future__ import annotations
2 2
3 3 from aiohttp import ClientSession
4 import random
5 import string
6 4 import json
5 import uuid
7 6 import re
8 7 import aiohttp
9 import asyncio
10 8 from pathlib import Path
11 import concurrent.futures
9 from functools import wraps
10 from typing import Optional, Callable, Any
12 11
13 12 from ..typing import AsyncResult, Messages, ImagesType
14 13 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
14 from .helper import format_prompt
15 15 from ..image import ImageResponse, to_data_uri
16 16 from ..cookies import get_cookies_dir
17 from ..tools.web_search import get_search_message
18 from .helper import format_prompt
19
20 17 from .. import debug
21 18
19
20 def cached_value(filename: str, cache_key: str = 'validated_value'):
21 """Universal cache decorator for both memory and file caching"""
22 def decorator(fetch_func: Callable) -> Callable:
23 memory_cache: Optional[str] = None
24
25 @wraps(fetch_func)
26 async def wrapper(cls, *args, force_refresh=False, **kwargs) -> Any:
27 nonlocal memory_cache
28
29 # If force refresh, clear caches
30 if force_refresh:
31 memory_cache = None
32 try:
33 cache_file = Path(get_cookies_dir()) / filename
34 if cache_file.exists():
35 cache_file.unlink()
36 except Exception as e:
37 debug.log(f"Error clearing cache file: {e}")
38
39 # Check memory cache first
40 if memory_cache is not None:
41 return memory_cache
42
43 # Check file cache
44 cache_file = Path(get_cookies_dir()) / filename
45 try:
46 if cache_file.exists():
47 with open(cache_file, 'r') as f:
48 data = json.load(f)
49 if data.get(cache_key):
50 memory_cache = data[cache_key]
51 return memory_cache
52 except Exception as e:
53 debug.log(f"Error reading cache file: {e}")
54
55 # Fetch new value
56 try:
57 value = await fetch_func(cls, *args, **kwargs)
58 memory_cache = value
59
60 # Save to file
61 cache_file.parent.mkdir(exist_ok=True)
62 try:
63 with open(cache_file, 'w') as f:
64 json.dump({cache_key: value}, f)
65 except Exception as e:
66 debug.log(f"Error writing to cache file: {e}")
67
68 return value
69 except Exception as e:
70 debug.log(f"Error fetching value: {e}")
71 raise
72
73 return wrapper
74 return decorator
75
76
22 77 class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
23 78 label = "Blackbox AI"
24 79 url = "https://www.blackbox.ai"
25 80 api_endpoint = "https://www.blackbox.ai/api/chat"
26
81
27 82 working = True
28 83 supports_stream = True
29 84 supports_system_message = True
30 85 supports_message_history = True
31
86
32 87 default_model = 'blackboxai'
33 88 default_vision_model = default_model
34 default_image_model = 'flux'
35 image_models = ['ImageGeneration', 'repomap']
89 default_image_model = 'ImageGeneration'
90 image_models = [default_image_model]
36 91 vision_models = [default_vision_model, 'gpt-4o', 'gemini-pro', 'gemini-1.5-flash', 'llama-3.1-8b', 'llama-3.1-70b', 'llama-3.1-405b']
37 92
38 web_search_models = ['blackboxai', 'meta-llama/Llama-3.3-70B-Instruct-Turbo', 'meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro']
39
40 93 userSelectedModel = ['gpt-4o', 'gemini-pro', 'claude-sonnet-3.5', 'blackboxai-pro']
41 94
42 95 agentMode = {
@@ -46,7 +99,6 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
46 99 'mistralai/Mistral-7B-Instruct-v0.2': {'mode': True, 'id': "mistralai/Mistral-7B-Instruct-v0.2", 'name': "Mistral-(7B)-Instruct-v0.2"},
47 100 'deepseek-ai/deepseek-llm-67b-chat': {'mode': True, 'id': "deepseek-ai/deepseek-llm-67b-chat", 'name': "DeepSeek-LLM-Chat-(67B)"},
48 101 'databricks/dbrx-instruct': {'mode': True, 'id': "databricks/dbrx-instruct", 'name': "DBRX-Instruct"},
49 'meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro': {'mode': True, 'id': "meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro", 'name': "Meta-Llama-3.1-405B-Instruct-Turbo"}, #
50 102 'Qwen/QwQ-32B-Preview': {'mode': True, 'id': "Qwen/QwQ-32B-Preview", 'name': "Qwen-QwQ-32B-Preview"},
51 103 'NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO': {'mode': True, 'id': "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO", 'name': "Nous-Hermes-2-Mixtral-8x7B-DPO"}
52 104 }
@@ -105,249 +157,152 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
105 157 "mixtral-7b": "mistralai/Mistral-7B-Instruct-v0.2",
106 158 "deepseek-chat": "deepseek-ai/deepseek-llm-67b-chat",
107 159 "dbrx-instruct": "databricks/dbrx-instruct",
108 "llama-3.1-405b": "meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro",
109 160 "qwq-32b": "Qwen/QwQ-32B-Preview",
110 161 "hermes-2-dpo": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
111 162
112 163 ### image ###
113 164 "flux": "ImageGeneration",
114 165 }
115
116 @classmethod
117 def _get_cache_file(cls) -> Path:
118 dir = Path(get_cookies_dir())
119 dir.mkdir(exist_ok=True)
120 return dir / 'blackbox.json'
121
122 @classmethod
123 def _load_cached_value(cls) -> str | None:
124 cache_file = cls._get_cache_file()
125 if cache_file.exists():
126 try:
127 with open(cache_file, 'r') as f:
128 data = json.load(f)
129 return data.get('validated_value')
130 except Exception as e:
131 debug.log(f"Error reading cache file: {e}")
132 return None
133
134 @classmethod
135 def _save_cached_value(cls, value: str):
136 cache_file = cls._get_cache_file()
137 try:
138 with open(cache_file, 'w') as f:
139 json.dump({'validated_value': value}, f)
140 except Exception as e:
141 debug.log(f"Error writing to cache file: {e}")
142 166
143 167 @classmethod
144 async def fetch_validated(cls):
145 cached_value = cls._load_cached_value()
146
168 @cached_value(filename='blackbox.json')
169 async def get_validated(cls) -> str:
170 """Fetch validated value from website"""
147 171 async with aiohttp.ClientSession() as session:
148 # Let's try both URLs
149 urls_to_try = [
150 "https://www.blackbox.ai",
151 "https://api.blackbox.ai"
152 ]
153
154 for base_url in urls_to_try:
155 try:
156 async with session.get(base_url) as response:
157 if response.status != 200:
158 continue
159
160 page_content = await response.text()
161 js_files = re.findall(r'static/chunks/\d{4}-[a-fA-F0-9]+\.js', page_content)
172 async with session.get(cls.url) as response:
173 if response.status != 200:
174 raise RuntimeError("Failed to get validated value")
175
176 page_content = await response.text()
177 js_files = re.findall(r'static/chunks/\d{4}-[a-fA-F0-9]+\.js', page_content)
178
179 if not js_files:
180 js_files = re.findall(r'static/js/[a-zA-Z0-9-]+\.js', page_content)
181
182 uuid_format = r'["\']([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})["\']'
183
184 def is_valid_context(text_around):
185 return any(char + '=' in text_around for char in 'abcdefghijklmnopqrstuvwxyz')
186
187 for js_file in js_files:
188 js_url = f"{cls.url}/_next/{js_file}"
189 try:
190 async with session.get(js_url) as js_response:
191 if js_response.status == 200:
192 js_content = await js_response.text()
193 for match in re.finditer(uuid_format, js_content):
194 start = max(0, match.start() - 10)
195 end = min(len(js_content), match.end() + 10)
196 context = js_content[start:end]
197
198 if is_valid_context(context):
199 return match.group(1)
200 except Exception:
201 continue
162 202
163 if not js_files:
164 js_files = re.findall(r'static/js/[a-zA-Z0-9-]+\.js', page_content)
165
166 uuid_format = r'["\']([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})["\']'
167
168 def is_valid_context(text_around):
169 return any(char + '=' in text_around for char in 'abcdefghijklmnopqrstuvwxyz')
170
171 for js_file in js_files:
172 js_url = f"{base_url}/_next/{js_file}"
173 try:
174 async with session.get(js_url) as js_response:
175 if js_response.status == 200:
176 js_content = await js_response.text()
177 for match in re.finditer(uuid_format, js_content):
178 start = max(0, match.start() - 10)
179 end = min(len(js_content), match.end() + 10)
180 context = js_content[start:end]
181
182 if is_valid_context(context):
183 validated_value = match.group(1)
184 cls._save_cached_value(validated_value)
185 return validated_value
186 except Exception:
187 continue
188
189 except Exception as e:
190 debug.log(f"Error trying {base_url}: {e}")
191 continue
192
193 # If we failed to get a new validated_value, we return the cached one
194 if cached_value:
195 return cached_value
196
197 raise RuntimeError("Failed to get validated value from both URLs")
198
199 @staticmethod
200 def generate_id(length=7):
201 characters = string.ascii_letters + string.digits
202 return ''.join(random.choice(characters) for _ in range(length))
203 raise RuntimeError("Failed to get validated value")
203 204
204 205 @classmethod
205 206 async def create_async_generator(
206 207 cls,
207 208 model: str,
208 209 messages: Messages,
209 prompt: str = None,
210 210 proxy: str = None,
211 prompt: str = None,
211 212 web_search: bool = False,
212 213 images: ImagesType = None,
213 top_p: float = 0.9,
214 temperature: float = 0.5,
214 top_p: float = None,
215 temperature: float = None,
215 216 max_tokens: int = None,
216 max_retries: int = 3,
217 delay: int = 1,
218 217 **kwargs
219 ) -> AsyncResult:
220
221 use_internal_search = web_search and model in cls.web_search_models
218 ) -> AsyncResult:
219 headers = {
220 "accept": "*/*",
221 "accept-language": "en-US,en;q=0.9",
222 "content-type": "application/json",
223 "origin": "https://www.blackbox.ai",
224 "referer": "https://www.blackbox.ai/",
225 "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
226 }
222 227
223 if web_search and not use_internal_search:
224 try:
225 # Create a timeout for web search
226 async def run_search():
227 with concurrent.futures.ThreadPoolExecutor() as executor:
228 return await asyncio.get_event_loop().run_in_executor(
229 executor,
230 lambda: get_search_message(messages[-1]["content"])
231 )
232
233 # Set a timeout of 10 seconds for web search
234 search_result = await asyncio.wait_for(run_search(), timeout=10.0)
235 messages[-1]["content"] = search_result
236
237 except asyncio.TimeoutError:
238 debug.log("Web search timed out, proceeding with original message")
239 except Exception as e:
240 debug.log(f"Web search failed: {str(e)}, proceeding with original message")
241
242 web_search = False
228 model = cls.get_model(model)
243 229
244 async def process_request():
245 validated_value = await cls.fetch_validated()
246
247 if not validated_value:
248 raise RuntimeError("Failed to get validated value")
249
250 formatted_message = format_prompt(messages)
251 current_model = cls.get_model(model)
230 conversation_id = str(uuid.uuid4())[:7]
231 validated_value = await cls.get_validated()
232
233 formatted_message = format_prompt(messages)
252 234
253 first_message = next((msg for msg in messages if msg['role'] == 'user'), None)
254 chat_id = cls.generate_id()
255 current_messages = [{"id": chat_id, "content": formatted_message, "role": "user"}]
256
257 if images is not None:
258 current_messages[-1]['data'] = {
259 "imagesData": [
260 {
261 "filePath": f"/{image_name}",
262 "contents": to_data_uri(image)
263 }
264 for image, image_name in images
265 ],
266 "fileText": "",
267 "title": ""
268 }
269
270 headers = {
271 'accept': '*/*',
272 'accept-language': 'en-US,en;q=0.9',
273 'content-type': 'application/json',
274 'origin': 'https://www.blackbox.ai',
275 'referer': 'https://www.blackbox.ai/',
276 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
277 }
278
279 data = {
280 "agentMode": cls.agentMode.get(model, {}) if model in cls.agentMode else {},
281 "clickedAnswer2": False,
282 "clickedAnswer3": False,
283 "clickedForceWebSearch": False,
284 "codeModelMode": True,
285 "deepSearchMode": False,
286 "domains": None,
287 "githubToken": None,
288 "id": chat_id,
289 "imageGenerationMode": False,
290 "isChromeExt": False,
291 "isMicMode": False,
292 "maxTokens": max_tokens,
293 "messages": current_messages,
294 "mobileClient": False,
295 "playgroundTemperature": temperature,
296 "playgroundTopP": top_p,
297 "previewToken": None,
298 "trendingAgentMode": cls.trendingAgentMode.get(model, {}) if model in cls.trendingAgentMode else {},
299 "userId": None,
300 "userSelectedModel": model if model in cls.userSelectedModel else None,
301 "userSystemPrompt": None,
302 "validated": validated_value,
303 "visitFromDelta": False,
304 "webSearchModePrompt": False,
305 "webSearchMode": use_internal_search
235 first_message = next((msg for msg in messages if msg['role'] == 'user'), None)
236 current_messages = [{"id": conversation_id, "content": formatted_message, "role": "user"}]
237
238 if images is not None:
239 current_messages[-1]['data'] = {
240 "imagesData": [
241 {
242 "filePath": f"/{image_name}",
243 "contents": to_data_uri(image)
244 }
245 for image, image_name in images
246 ],
247 "fileText": "",
248 "title": ""
306 249 }
307
308 for attempt in range(max_retries):
250
251 while True:
252 async with ClientSession(headers=headers) as session:
253 data = {
254 "messages": current_messages,
255 "id": conversation_id,
256 "previewToken": None,
257 "userId": None,
258 "codeModelMode": True,
259 "agentMode": cls.agentMode.get(model, {}) if model in cls.agentMode else {},
260 "trendingAgentMode": cls.trendingAgentMode.get(model, {}) if model in cls.trendingAgentMode else {},
261 "isMicMode": False,
262 "userSystemPrompt": None,
263 "maxTokens": max_tokens,
264 "playgroundTopP": top_p,
265 "playgroundTemperature": temperature,
266 "isChromeExt": False,
267 "githubToken": "",
268 "clickedAnswer2": False,
269 "clickedAnswer3": False,
270 "clickedForceWebSearch": False,
271 "visitFromDelta": False,
272 "mobileClient": False,
273 "userSelectedModel": model if model in cls.userSelectedModel else None,
274 "validated": validated_value,
275 "imageGenerationMode": False,
276 "webSearchModePrompt": False,
277 "deepSearchMode": False,
278 "domains": None,
279 "webSearchMode": web_search
280 }
281
309 282 try:
310 async with ClientSession(headers=headers) as session:
311 async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
312 response.raise_for_status()
313 response_text = await response.text()
314
315 if current_model in cls.image_models:
316 image_matches = re.findall(r'!\[.*?\]\((https?://[^\)]+)\)', response_text)
317 if image_matches:
318 yield ImageResponse(image_matches[0], prompt)
319 return
320
321 response_text = re.sub(r'Generated by BLACKBOX.AI, try unlimited chat https://www.blackbox.ai', '', response_text, flags=re.DOTALL)
322 response_text = re.sub(r'and for API requests replace https://www.blackbox.ai with https://api.blackbox.ai', '', response_text, flags=re.DOTALL)
323
324 response_text = response_text.strip()
325
326 if not response_text:
327 raise ValueError("Empty response received")
328
329 json_match = re.search(r'\$~~~\$(.*?)\$~~~\$', response_text, re.DOTALL)
330 if json_match:
331 search_results = json.loads(json_match.group(1))
332 answer = response_text.split('$~~~$')[-1].strip()
333
334 formatted_response = f"{answer}\n\n**Source:**"
335 for i, result in enumerate(search_results, 1):
336 formatted_response += f"\n{i}. {result['title']}: {result['link']}"
337
338 yield formatted_response
339 else:
340 yield response_text
283 async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
284 response.raise_for_status()
285 first_chunk = True
286 content_received = False
287 async for chunk in response.content:
288 if chunk:
289 content_received = True
290 decoded = chunk.decode()
291 if first_chunk and "Generated by BLACKBOX.AI" in decoded:
292 validated_value = await cls.get_validated(force_refresh=True)
293 break
294 first_chunk = False
295 if model in cls.image_models and decoded.startswith("![]("):
296 image_url = decoded.strip("![]()")
297 prompt = messages[-1]["content"]
298 yield ImageResponse(images=image_url, alt=prompt)
299 else:
300 yield decoded
301 else:
302 if not content_received:
303 debug.log("Empty response received from Blackbox API, retrying...")
304 continue
341 305 return
342
343 306 except Exception as e:
344 debug.log(f"Error: {str(e)}")
345 if attempt == max_retries - 1:
346 raise RuntimeError("Failed after all retries")
347 else:
348 wait_time = delay * (2 ** attempt) + random.uniform(0, 1)
349 debug.log(f"Attempt {attempt + 1} failed. Retrying in {wait_time:.2f} seconds...")
350 await asyncio.sleep(wait_time)
351
352 async for chunk in process_request():
353 yield chunk
307 debug.log(f"Error in request: {e}")
308 raise
Modified g4f/Provider/ChatGptEs.py +3 -4
@@ -54,10 +54,8 @@ class ChatGptEs(AsyncGeneratorProvider, ProviderModelMixin):
54 54 post_id = re.findall(r'data-post-id="(.+?)"', await initial_response.text())[0]
55 55
56 56 formatted_prompt = format_prompt(messages)
57
58 conversation_history = [
59 "Human: You are a helpful AI assistant. Please respond in the same language that the user uses in their message. Provide accurate, relevant and helpful information while maintaining a friendly and professional tone. If you're not sure about something, please acknowledge that and provide the best information you can while noting any uncertainties. Focus on being helpful while respecting the user's choice of language."
60 ]
57
58 conversation_history = []
61 59
62 60 for message in messages[:-1]:
63 61 if message['role'] == "user":
@@ -66,6 +64,7 @@ class ChatGptEs(AsyncGeneratorProvider, ProviderModelMixin):
66 64 conversation_history.append(f"AI: {message['content']}")
67 65
68 66 payload = {
67 'wpaicg_user_agree': '1',
69 68 '_wpnonce': nonce_,
70 69 'post_id': post_id,
71 70 'url': cls.url,
Modified g4f/Provider/DDG.py +40 -100
@@ -1,132 +1,72 @@
1 1 from __future__ import annotations
2 2
3 from aiohttp import ClientSession, ClientTimeout
3 4 import json
4 import aiohttp
5 from aiohttp import ClientSession, BaseConnector
6 5
7 6 from ..typing import AsyncResult, Messages
8 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin, BaseConversation
9 from .helper import format_prompt
10 from ..requests.aiohttp import get_connector
11 from ..requests.raise_for_status import raise_for_status
7 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
12 8
13 MODELS = [
14 {"model":"gpt-4o","modelName":"GPT-4o","modelVariant":None,"modelStyleId":"gpt-4o-mini","createdBy":"OpenAI","moderationLevel":"HIGH","isAvailable":1,"inputCharLimit":16e3,"settingId":"4"},
15 {"model":"gpt-4o-mini","modelName":"GPT-4o","modelVariant":"mini","modelStyleId":"gpt-4o-mini","createdBy":"OpenAI","moderationLevel":"HIGH","isAvailable":0,"inputCharLimit":16e3,"settingId":"3"},
16 {"model":"claude-3-5-sonnet-20240620","modelName":"Claude 3.5","modelVariant":"Sonnet","modelStyleId":"claude-3-haiku","createdBy":"Anthropic","moderationLevel":"HIGH","isAvailable":1,"inputCharLimit":16e3,"settingId":"7"},
17 {"model":"claude-3-opus-20240229","modelName":"Claude 3","modelVariant":"Opus","modelStyleId":"claude-3-haiku","createdBy":"Anthropic","moderationLevel":"HIGH","isAvailable":1,"inputCharLimit":16e3,"settingId":"2"},
18 {"model":"claude-3-haiku-20240307","modelName":"Claude 3","modelVariant":"Haiku","modelStyleId":"claude-3-haiku","createdBy":"Anthropic","moderationLevel":"HIGH","isAvailable":0,"inputCharLimit":16e3,"settingId":"1"},
19 {"model":"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo","modelName":"Llama 3.1","modelVariant":"70B","modelStyleId":"llama-3","createdBy":"Meta","moderationLevel":"MEDIUM","isAvailable":0,"isOpenSource":0,"inputCharLimit":16e3,"settingId":"5"},
20 {"model":"mistralai/Mixtral-8x7B-Instruct-v0.1","modelName":"Mixtral","modelVariant":"8x7B","modelStyleId":"mixtral","createdBy":"Mistral AI","moderationLevel":"LOW","isAvailable":0,"isOpenSource":0,"inputCharLimit":16e3,"settingId":"6"},
21 {"model":"Qwen/Qwen2.5-Coder-32B-Instruct","modelName":"Qwen 2.5 Coder","modelVariant":"32B","modelStyleId":"qwen","createdBy":"Alibaba Cloud","moderationLevel":"LOW","isAvailable":0,"isOpenSource":1,"inputCharLimit":16e3,"settingId":"90"}
22 ]
23
24 class Conversation(BaseConversation):
25 vqd: str = None
26 message_history: Messages = []
27
28 def __init__(self, model: str):
29 self.model = model
30 9
31 10 class DDG(AsyncGeneratorProvider, ProviderModelMixin):
32 11 label = "DuckDuckGo AI Chat"
33 12 url = "https://duckduckgo.com/aichat"
13 url_status = "https://duckduckgo.com/duckchat/v1/status"
34 14 api_endpoint = "https://duckduckgo.com/duckchat/v1/chat"
15
35 16 working = True
36 17 supports_stream = True
37 18 supports_system_message = True
38 19 supports_message_history = True
39
40 default_model = "gpt-4o-mini"
41 models = [model.get("model") for model in MODELS]
20
21 default_model = 'gpt-4o-mini'
22 models = [default_model, 'claude-3-haiku-20240307', 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo', 'mistralai/Mixtral-8x7B-Instruct-v0.1']
23
24 model_aliases = {
25 "gpt-4": "gpt-4o-mini",
26 }
42 27 model_aliases = {
28 "gpt-4": default_model,
43 29 "claude-3-haiku": "claude-3-haiku-20240307",
44 30 "llama-3.1-70b": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
45 "mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
46 "gpt-4": "gpt-4o-mini",
31 "mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1"
47 32 }
48 33
49 @classmethod
50 async def get_vqd(cls, proxy: str, connector: BaseConnector = None):
51 status_url = "https://duckduckgo.com/duckchat/v1/status"
52 headers = {
53 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
54 'Accept': 'text/event-stream',
55 'x-vqd-accept': '1'
56 }
57 async with aiohttp.ClientSession(connector=get_connector(connector, proxy)) as session:
58 async with session.get(status_url, headers=headers) as response:
59 await raise_for_status(response)
60 return response.headers.get("x-vqd-4")
61
62 34 @classmethod
63 35 async def create_async_generator(
64 36 cls,
65 37 model: str,
66 38 messages: Messages,
67 conversation: Conversation = None,
68 return_conversation: bool = False,
69 39 proxy: str = None,
70 connector: BaseConnector = None,
71 40 **kwargs
72 41 ) -> AsyncResult:
73 model = cls.get_model(model)
74
75 is_new_conversation = False
76 if conversation is None:
77 conversation = Conversation(model)
78 is_new_conversation = True
79
80 if conversation.vqd is None:
81 conversation.vqd = await cls.get_vqd(proxy, connector)
82 if not conversation.vqd:
83 raise Exception("Failed to obtain VQD token")
84
85 headers = {
86 'accept': 'text/event-stream',
87 'content-type': 'application/json',
88 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
89 'x-vqd-4': conversation.vqd,
90 }
91
92 async with ClientSession(headers=headers, connector=get_connector(connector, proxy)) as session:
93 if is_new_conversation:
94 conversation.message_history = [{"role": "user", "content": format_prompt(messages)}]
95 else:
96 if len(messages) >= 2:
97 conversation.message_history = [
98 *conversation.message_history,
99 messages[-2],
100 messages[-1]
101 ]
102 elif len(messages) == 1:
103 conversation.message_history = [
104 *conversation.message_history,
105 messages[-1]
106 ]
107
108 if return_conversation:
109 yield conversation
110
111 data = {
112 "model": conversation.model,
113 "messages": conversation.message_history
42 async with ClientSession(timeout=ClientTimeout(total=30)) as session:
43 # Fetch VQD token
44 async with session.get(cls.url_status,
45 headers={"x-vqd-accept": "1"}) as response:
46 if response.status != 200:
47 raise Exception(f"Failed to fetch VQD token: {response.status}")
48 vqd = response.headers.get("x-vqd-4", "")
49 if not vqd:
50 raise Exception("Failed to fetch VQD token: Empty token.")
51
52 headers = {
53 "Content-Type": "application/json",
54 "x-vqd-4": vqd,
114 55 }
115 56
116 async with session.post(cls.api_endpoint, json=data) as response:
117 conversation.vqd = response.headers.get("x-vqd-4")
118 await raise_for_status(response)
57 payload = {
58 "model": model,
59 "messages": messages,
60 }
119 61
62 async with session.post(cls.api_endpoint, headers=headers, json=payload, proxy=proxy) as response:
63 response.raise_for_status()
120 64 async for line in response.content:
121 if line:
122 decoded_line = line.decode('utf-8')
123 if decoded_line.startswith('data: '):
124 json_str = decoded_line[6:]
125 if json_str == '[DONE]':
126 break
127 try:
128 json_data = json.loads(json_str)
129 if 'message' in json_data:
130 yield json_data['message']
131 except json.JSONDecodeError:
132 pass
65 line = line.decode("utf-8").strip()
66 if line.startswith("data:"):
67 try:
68 message = json.loads(line[5:].strip())
69 if "message" in message:
70 yield message["message"]
71 except json.JSONDecodeError:
72 continue
Renamed g4f/Provider/needs_auth/GlhfChat.py +3 -4
@@ -2,10 +2,9 @@ from __future__ import annotations
2 2
3 3 from .OpenaiAPI import OpenaiAPI
4 4
5 class glhfChat(OpenaiAPI):
6 label = "glhf.chat"
5 class GlhfChat(OpenaiAPI):
6 label = "GlhfChat"
7 7 url = "https://glhf.chat"
8 login_url = "https://glhf.chat/users/settings/api"
9 8 api_base = "https://glhf.chat/api/openai/v1"
10 9 working = True
11 10 model_aliases = {
@@ -27,4 +26,4 @@ class glhfChat(OpenaiAPI):
27 26 'Qwen2.5-7B-Instruct': 'hf:Qwen/Qwen2.5-7B-Instruct',
28 27 'SOLAR-10.7B-Instruct-v1.0': 'hf:upstage/SOLAR-10.7B-Instruct-v1.0',
29 28 'Llama-3.1-Nemotron-70B-Instruct-HF': 'hf:nvidia/Llama-3.1-Nemotron-70B-Instruct-HF'
30 }
29 }
Modified g4f/Provider/needs_auth/__init__.py +2 -3
@@ -1,6 +1,5 @@
1 1 from .gigachat import *
2 2
3 from .Anthropic import Anthropic
4 3 from .BingCreateImages import BingCreateImages
5 4 from .Cerebras import Cerebras
6 5 from .CopilotAccount import CopilotAccount
@@ -9,7 +8,7 @@ from .DeepInfraImage import DeepInfraImage
9 8 from .Gemini import Gemini
10 9 from .GeminiPro import GeminiPro
11 10 from .GithubCopilot import GithubCopilot
12 from .glhfChat import glhfChat
11 from .GlhfChat import GlhfChat
13 12 from .Groq import Groq
14 13 from .HuggingChat import HuggingChat
15 14 from .HuggingFace import HuggingFace
@@ -28,4 +27,4 @@ from .Replicate import Replicate
28 27 from .Theb import Theb
29 28 from .ThebApi import ThebApi
30 29 from .WhiteRabbitNeo import WhiteRabbitNeo
31 from .xAI import xAI
30 from .xAI import xAI
Modified g4f/gui/client/index.html +2 -2
@@ -174,8 +174,8 @@
174 174 <textarea id="Groq-api_key" name="Groq[api_key]" placeholder="api_key"></textarea>
175 175 </div>
176 176 <div class="field box hidden">
177 <label for="glhfChat-api_key" class="label" title="">glhf.chat:</label>
178 <textarea id="glhfChat-api_key" name="glhfChat[api_key]" placeholder="api_key"></textarea>
177 <label for="GlhfChat-api_key" class="label" title="">GlhfChat:</label>
178 <textarea id="GlhfChat-api_key" name="GlhfChat[api_key]" placeholder="api_key"></textarea>
179 179 </div>
180 180 <div class="field box hidden">
181 181 <label for="HuggingFace-api_key" class="label" title="">HuggingFace:</label>
Modified g4f/models.py +2 -17
@@ -68,7 +68,6 @@ default = Model(
68 68 best_provider = IterListProvider([
69 69 DDG,
70 70 Pizzagpt,
71 BlackboxCreateAgent,
72 71 Blackbox,
73 72 Copilot,
74 73 DeepInfraChat,
@@ -78,7 +77,7 @@ default = Model(
78 77 ChatGptEs,
79 78 OpenaiChat,
80 79 Mhystical,
81 RubiksAI,
80 ClaudeSon,
82 81 ])
83 82 )
84 83
@@ -101,12 +100,6 @@ gpt_4 = Model(
101 100 best_provider = IterListProvider([DDG, Blackbox, ChatGptEs, PollinationsAI, Copilot, OpenaiChat, Liaobots, Mhystical])
102 101 )
103 102
104 gpt_4_turbo = Model(
105 name = 'gpt-4-turbo',
106 base_provider = 'OpenAI',
107 best_provider = None
108 )
109
110 103 # gpt-4o
111 104 gpt_4o = Model(
112 105 name = 'gpt-4o',
@@ -136,7 +129,7 @@ o1_preview = Model(
136 129 o1_mini = Model(
137 130 name = 'o1-mini',
138 131 base_provider = 'OpenAI',
139 best_provider = IterListProvider([Liaobots])
132 best_provider = Liaobots
140 133 )
141 134
142 135 ### GigaChat ###
@@ -179,12 +172,6 @@ llama_3_1_70b = Model(
179 172 best_provider = IterListProvider([DDG, DeepInfraChat, Blackbox, BlackboxCreateAgent, TeachAnything, PollinationsAI, DarkAI, Airforce, RubiksAI, PerplexityLabs])
180 173 )
181 174
182 llama_3_1_405b = Model(
183 name = "llama-3.1-405b",
184 base_provider = "Meta Llama",
185 best_provider = Blackbox
186 )
187
188 175 # llama 3.2
189 176 llama_3_2_1b = Model(
190 177 name = "llama-3.2-1b",
@@ -661,7 +648,6 @@ class ModelUtils:
661 648
662 649 # gpt-4
663 650 gpt_4.name: gpt_4,
664 gpt_4_turbo.name: gpt_4_turbo,
665 651
666 652 # gpt-4o
667 653 gpt_4o.name: gpt_4o,
@@ -684,7 +670,6 @@ class ModelUtils:
684 670 # llama-3.1
685 671 llama_3_1_8b.name: llama_3_1_8b,
686 672 llama_3_1_70b.name: llama_3_1_70b,
687 llama_3_1_405b.name: llama_3_1_405b,
688 673
689 674 # llama-3.2
690 675 llama_3_2_1b.name: llama_3_2_1b,