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

XFEstudio/gpt4free

feat: add new providers and update models (#3075)

* feat: add agent CLI, new providers, and update models - Add a new `agent` mode to the CLI, a feature-rich AI coding assistant with capabilities for file system operations, code execution, git integration, and interactive chat. - Add new provider `OperaAria` with support for vision, streaming, and conversation history. - Add new provider `Startnest` with support for `gpt-4o-mini`, vision, and streaming. - Move providers `FreeGpt` and `Websim` to the `not_working` directory. - Delete the `OIVSCodeSer2` provider. - Rename the CLI `client` mode to `chat` and refactor its argument parsing. - In `g4f/Provider/DeepInfraChat.py`: - Add a new `api_endpoint` attribute. - Extensively update and reorganize the `models` list and `model_aliases` dictionary with numerous new models. - In `g4f/Provider/LambdaChat.py`: - Change the `default_model` to `deepseek-v3-0324`. - In `g4f/Provider/Together.py`: - Update aliases for `llama-3.1-405b`, `deepseek-r1`, and `flux`. - Add new models including `gemma-3-27b`, `gemma-3n-e4b`, and `qwen-3-32b`. - In `g4f/models.py`: - Add new model definitions for `aria`, `deepseek_v3_0324_turbo`, `deepseek_r1_0528_turbo`, and several `gemma` variants. - Remove the `mixtral_8x22b` model definition. - Update the `best_provider` lists for `default`, `default_vision`, `gpt_4o_mini`, `gemini-1.5-pro`, `gemini-1.5-flash`, and others to reflect provider changes. - In `g4f/Provider/__init__.py`: - Add `OperaAria` and `Startnest` to the list of imported providers. - Remove `FreeGpt`, `OIVSCodeSer2`, and `Websim` from imports. - In `requirements.txt`: - Add `rich` as a new dependency for the agent CLI. * feat: add gemma-3-4b alias to DeepInfraChat In g4f/Provider/DeepInfraChat.py, add the gemma-3-4b alias to the model_aliases dictionary. The new alias points to the google/gemma-3-4b-it model. * feat: add OIVSCodeSer2 provider - Create the new provider file . - The provider supports the model and includes a custom method to generate a . - Import and include in . - Add to the for in . - Add to in . * feat: add OIVSCodeSer2 provider - Create the new provider file . - The provider supports the model and includes a custom method to generate a . - Import and include in . - Add to the for in . - Add to in . * refactor: Migrate from duckduckgo-search to ddgs library * Replaced the dependency with the new library. * In , updated imports from to and to . * Modified the function in to use an context manager instead of a global instance. * Updated the function to catch the new exception. * In , updated the web search import and installation instructions to use . * Removed unnecessary comments and simplified f-string formatting in and . * Added and to . * Added , , and to the extras in . * test: Update web search tests for ddgs library and cleanup code * In `etc/unittest/web_search.py`, updated imports from `duckduckgo_search` to `ddgs` and `DDGSError`. * Added an import for `MissingRequirementsError` in `etc/unittest/web_search.py`. * Modified exception handling in web search tests to catch both `DDGSError` and `MissingRequirementsError`. * Removed temporary modification comments in `g4f/cli/agent/agent.py` and `g4f/tools/web_search.py`. * fix: remove unstable CLI feature due to critical errors - Remove the experimental CLI coding assistant feature due to multiple stability issues and critical errors in production environments - Delete the entire `g4f/cli/agent/` directory and all related functionality - Remove `rich` dependency from `requirements.txt` as it was only used by the removed feature - Remove `rich` from the `all` extras in `setup.py` - Revert CLI mode naming from `chat` back to `client` for consistency - Clean up argument parsing in CLI to remove references to the removed functionality - Remove installation instructions and imports related to the unstable feature from documentation This removal is necessary due to: - Unpredictable behavior causing data loss risks - Incompatibility with certain system configurations - Security concerns with unrestricted file system access - Excessive resource consumption in production environments Note: This feature may be reintroduced in the future with a more stable and secure implementation that addresses the current limitations and safety concerns. --------- Co-authored-by: kqlio67 <kqlio67@users.noreply.github.com>

79654878
kqlio67 <166700875+kqlio67@users.noreply.github.com>
提交于

代码差异

16 个文件 +813 -219
Modified etc/unittest/web_search.py +8 -8
@@ -4,14 +4,14 @@ import json
4 4 import unittest
5 5
6 6 try:
7 from duckduckgo_search import DDGS
8 from duckduckgo_search.exceptions import DuckDuckGoSearchException
7 from ddgs import DDGS, DDGSError
9 8 from bs4 import BeautifulSoup
10 9 has_requirements = True
11 10 except ImportError:
12 11 has_requirements = False
13 12
14 13 from g4f.client import AsyncClient
14 from g4f.errors import MissingRequirementsError
15 15 from .mocks import YieldProviderMock
16 16
17 17 DEFAULT_MESSAGES = [{'role': 'user', 'content': 'Hello'}]
@@ -45,8 +45,8 @@ class TestIterListProvider(unittest.IsolatedAsyncioTestCase):
45 45 try:
46 46 response = await client.chat.completions.create([{"content": "", "role": "user"}], "", tool_calls=tool_calls)
47 47 self.assertIn("Using the provided web search results", response.choices[0].message.content)
48 except DuckDuckGoSearchException as e:
49 self.skipTest(f'DuckDuckGoSearchException: {e}')
48 except (DDGSError, MissingRequirementsError) as e:
49 self.skipTest(f'Search error: {e}')
50 50
51 51 async def test_search2(self):
52 52 client = AsyncClient(provider=YieldProviderMock)
@@ -64,8 +64,8 @@ class TestIterListProvider(unittest.IsolatedAsyncioTestCase):
64 64 try:
65 65 response = await client.chat.completions.create([{"content": "", "role": "user"}], "", tool_calls=tool_calls)
66 66 self.assertIn("Using the provided web search results", response.choices[0].message.content)
67 except DuckDuckGoSearchException as e:
68 self.skipTest(f'DuckDuckGoSearchException: {e}')
67 except (DDGSError, MissingRequirementsError) as e:
68 self.skipTest(f'Search error: {e}')
69 69
70 70 async def test_search3(self):
71 71 client = AsyncClient(provider=YieldProviderMock)
@@ -85,5 +85,5 @@ class TestIterListProvider(unittest.IsolatedAsyncioTestCase):
85 85 try:
86 86 response = await client.chat.completions.create([{"content": "", "role": "user"}], "", tool_calls=tool_calls)
87 87 self.assertIn("Using the provided web search results", response.choices[0].message.content)
88 except DuckDuckGoSearchException as e:
89 self.skipTest(f'DuckDuckGoSearchException: {e}')
88 except (DDGSError, MissingRequirementsError) as e:
89 self.skipTest(f'Search error: {e}')
Modified g4f/Provider/DeepInfraChat.py +103 -49
@@ -11,80 +11,134 @@ class DeepInfraChat(OpenaiTemplate):
11 11 url = "https://deepinfra.com/chat"
12 12 login_url = "https://deepinfra.com/dash/api_keys"
13 13 api_base = "https://api.deepinfra.com/v1/openai"
14 api_endpoint = "https://api.deepinfra.com/v1/openai/chat/completions"
14 15 working = True
15 16
16 17 default_model = 'deepseek-ai/DeepSeek-V3-0324'
17 18 default_vision_model = 'microsoft/Phi-4-multimodal-instruct'
18 vision_models = [default_vision_model, 'meta-llama/Llama-3.2-90B-Vision-Instruct']
19 vision_models = [
20 default_vision_model,
21 'meta-llama/Llama-3.2-90B-Vision-Instruct'
22 ]
19 23 models = [
24 # cognitivecomputations
25 'cognitivecomputations/dolphin-2.6-mixtral-8x7b',
26 'cognitivecomputations/dolphin-2.9.1-llama-3-70b',
27
28 # deepinfra
29 'deepinfra/airoboros-70b',
30
31 # deepseek-ai
32 default_model,
33 'deepseek-ai/DeepSeek-V3-0324-Turbo',
34
35 'deepseek-ai/DeepSeek-R1-0528-Turbo',
20 36 'deepseek-ai/DeepSeek-R1-0528',
37
21 38 'deepseek-ai/DeepSeek-Prover-V2-671B',
22 'Qwen/Qwen3-235B-A22B',
23 'Qwen/Qwen3-30B-A3B',
24 'Qwen/Qwen3-32B',
25 'Qwen/Qwen3-14B',
26 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8',
27 'meta-llama/Llama-4-Scout-17B-16E-Instruct',
28 'microsoft/phi-4-reasoning-plus',
29 'microsoft/meta-llama/Llama-Guard-4-12B',
30 'Qwen/QwQ-32B',
31 default_model,
32 'google/gemma-3-27b-it',
33 'google/gemma-3-12b-it',
34 'meta-llama/Meta-Llama-3.1-8B-Instruct',
35 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
39
36 40 'deepseek-ai/DeepSeek-V3',
37 'mistralai/Mistral-Small-24B-Instruct-2501',
41
38 42 'deepseek-ai/DeepSeek-R1',
39 43 'deepseek-ai/DeepSeek-R1-Turbo',
40 44 'deepseek-ai/DeepSeek-R1-Distill-Llama-70B',
41 45 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',
42 'microsoft/phi-4',
43 'microsoft/WizardLM-2-8x22B',
44 'Qwen/Qwen2.5-72B-Instruct',
45 'Qwen/Qwen2-72B-Instruct',
46 'cognitivecomputations/dolphin-2.6-mixtral-8x7b',
47 'cognitivecomputations/dolphin-2.9.1-llama-3-70b',
48 'deepinfra/airoboros-70b',
46
47 # google (gemma)
48 'google/gemma-1.1-7b-it',
49 'google/gemma-2-9b-it',
50 'google/gemma-2-27b-it',
51 'google/gemma-3-4b-it',
52 'google/gemma-3-12b-it',
53 'google/gemma-3-27b-it',
54
55 # google (codegemma)
56 'google/codegemma-7b-it',
57
58 # lizpreciatior
49 59 'lizpreciatior/lzlv_70b_fp16_hf',
60
61 # meta-llama
62 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8',
63 'meta-llama/Llama-4-Scout-17B-16E-Instruct',
64 'meta-llama/Meta-Llama-3.1-8B-Instruct',
65 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
66 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',
67
68 # microsoft
69 'microsoft/phi-4-reasoning-plus',
70 'microsoft/phi-4',
71
72 'microsoft/WizardLM-2-8x22B',
50 73 'microsoft/WizardLM-2-7B',
51 'mistralai/Mixtral-8x22B-Instruct-v0.1',
74
75 # mistralai
76 'mistralai/Mistral-Small-3.1-24B-Instruct-2503',
77
78 # Qwen
79 'Qwen/Qwen3-235B-A22B',
80 'Qwen/Qwen3-30B-A3B',
81 'Qwen/Qwen3-32B',
82 'Qwen/Qwen3-14B',
83 'Qwen/QwQ-32B',
52 84 ] + vision_models
85
53 86 model_aliases = {
54 "deepseek-r1-0528": "deepseek-ai/DeepSeek-R1-0528",
55 "deepseek-prover-v2-671b": "deepseek-ai/DeepSeek-Prover-V2-671B",
87 # cognitivecomputations
88 "dolphin-2.6": "cognitivecomputations/dolphin-2.6-mixtral-8x7b",
89 "dolphin-2.9": "cognitivecomputations/dolphin-2.9.1-llama-3-70b",
90
91 # deepinfra
92 "airoboros-70b": "deepinfra/airoboros-70b",
93
94 # deepseek-ai
56 95 "deepseek-prover-v2": "deepseek-ai/DeepSeek-Prover-V2-671B",
57 "qwen-3-235b": "Qwen/Qwen3-235B-A22B",
58 "qwen-3-30b": "Qwen/Qwen3-30B-A3B",
59 "qwen-3-32b": "Qwen/Qwen3-32B",
60 "qwen-3-14b": "Qwen/Qwen3-14B",
61 "llama-4-maverick": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
62 "llama-4-scout": "meta-llama/Llama-4-Scout-17B-16E-Instruct",
63 "phi-4-reasoning-plus": "microsoft/phi-4-reasoning-plus",
64 #"": "meta-llama/Llama-Guard-4-12B",
65 "qwq-32b": "Qwen/QwQ-32B",
96 "deepseek-prover-v2-671b": "deepseek-ai/DeepSeek-Prover-V2-671B",
97 "deepseek-r1": ["deepseek-ai/DeepSeek-R1", "deepseek-ai/DeepSeek-R1-0528"],
98 "deepseek-r1-0528": "deepseek-ai/DeepSeek-R1-0528",
99 "deepseek-r1-0528-turbo": "deepseek-ai/DeepSeek-R1-0528-Turbo",
100 "deepseek-r1-distill-llama-70b": "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
101 "deepseek-r1-distill-qwen-32b": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
102 "deepseek-r1-turbo": "deepseek-ai/DeepSeek-R1-Turbo",
66 103 "deepseek-v3": ["deepseek-ai/DeepSeek-V3", "deepseek-ai/DeepSeek-V3-0324"],
67 104 "deepseek-v3-0324": "deepseek-ai/DeepSeek-V3-0324",
68 "gemma-3-27b": "google/gemma-3-27b-it",
105 "deepseek-v3-0324-turbo": "deepseek-ai/DeepSeek-V3-0324-Turbo",
106
107 # google
108 "codegemma-7b": "google/codegemma-7b-it",
109 "gemma-1.1-7b": "google/gemma-1.1-7b-it",
110 "gemma-2-27b": "google/gemma-2-27b-it",
111 "gemma-2-9b": "google/gemma-2-9b-it",
112 "gemma-3-4b": "google/gemma-3-4b-it",
69 113 "gemma-3-12b": "google/gemma-3-12b-it",
70 "phi-4-multimodal": "microsoft/Phi-4-multimodal-instruct",
114 "gemma-3-27b": "google/gemma-3-27b-it",
115
116 # lizpreciatior
117 "lzlv-70b": "lizpreciatior/lzlv_70b_fp16_hf",
118
119 # meta-llama
71 120 "llama-3.1-8b": "meta-llama/Meta-Llama-3.1-8B-Instruct",
72 121 "llama-3.2-90b": "meta-llama/Llama-3.2-90B-Vision-Instruct",
73 122 "llama-3.3-70b": "meta-llama/Llama-3.3-70B-Instruct",
74 "mistral-small-24b": "mistralai/Mistral-Small-24B-Instruct-2501",
75 "deepseek-r1-turbo": "deepseek-ai/DeepSeek-R1-Turbo",
76 "deepseek-r1": ["deepseek-ai/DeepSeek-R1", "deepseek-ai/DeepSeek-R1-0528"],
77 "deepseek-r1-distill-llama-70b": "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
78 "deepseek-r1-distill-qwen-32b": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
123 "llama-4-maverick": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
124 "llama-4-scout": "meta-llama/Llama-4-Scout-17B-16E-Instruct",
125
126 # microsoft
79 127 "phi-4": "microsoft/phi-4",
80 "wizardlm-2-8x22b": "microsoft/WizardLM-2-8x22B",
81 "qwen-2-72b": "Qwen/Qwen2-72B-Instruct",
82 "dolphin-2.6": "cognitivecomputations/dolphin-2.6-mixtral-8x7b",
83 "dolphin-2.9": "cognitivecomputations/dolphin-2.9.1-llama-3-70b",
84 "airoboros-70b": "deepinfra/airoboros-70b",
85 "lzlv-70b": "lizpreciatior/lzlv_70b_fp16_hf",
128 "phi-4-multimodal": default_vision_model,
129 "phi-4-reasoning-plus": "microsoft/phi-4-reasoning-plus",
86 130 "wizardlm-2-7b": "microsoft/WizardLM-2-7B",
87 "mixtral-8x22b": "mistralai/Mixtral-8x22B-Instruct-v0.1"
131 "wizardlm-2-8x22b": "microsoft/WizardLM-2-8x22B",
132
133 # mistralai
134 "mistral-small-3.1-24b": "mistralai/Mistral-Small-3.1-24B-Instruct-2503",
135
136 # Qwen
137 "qwen-3-14b": "Qwen/Qwen3-14B",
138 "qwen-3-30b": "Qwen/Qwen3-30B-A3B",
139 "qwen-3-32b": "Qwen/Qwen3-32B",
140 "qwen-3-235b": "Qwen/Qwen3-235B-A22B",
141 "qwq-32b": "Qwen/QwQ-32B",
88 142 }
89 143
90 144 @classmethod
Modified g4f/Provider/LambdaChat.py +2 -1
@@ -22,7 +22,7 @@ class LambdaChat(AsyncGeneratorProvider, ProviderModelMixin):
22 22
23 23 working = True
24 24
25 default_model = "deepseek-r1"
25 default_model = "deepseek-v3-0324"
26 26 models = [
27 27 "deepseek-llama3.3-70b",
28 28 "deepseek-r1",
@@ -35,6 +35,7 @@ class LambdaChat(AsyncGeneratorProvider, ProviderModelMixin):
35 35 "llama3.3-70b-instruct-fp8",
36 36 "qwen25-coder-32b-instruct",
37 37 "deepseek-v3",
38 default_model,
38 39 "llama-4-maverick-17b-128e-instruct-fp8",
39 40 "llama-4-scout-17b-16e-instruct",
40 41 "llama3.3-70b-instruct-fp8",
Added g4f/Provider/OperaAria.py +330 -0
@@ -0,0 +1,330 @@
1 from __future__ import annotations
2
3 import json
4 import time
5 import random
6 import re
7 import os
8 import base64
9 import asyncio
10 from aiohttp import ClientSession, FormData
11
12 from ..typing import AsyncResult, Messages, MediaListType
13 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
14 from .helper import format_prompt
15 from ..providers.response import JsonConversation, FinishReason, ImageResponse
16 from ..image import to_data_uri, is_data_an_media
17 from ..tools.media import merge_media
18
19
20 class Conversation(JsonConversation):
21 """Manages all session-specific state for Opera Aria."""
22 access_token: str = None
23 refresh_token: str = None
24 encryption_key: str = None
25 expires_at: float = 0
26 conversation_id: str = None
27 is_first_request: bool = True
28
29 def __init__(self, refresh_token: str = None):
30 """Initializes a new session, generating a unique encryption key."""
31 self.refresh_token = refresh_token
32 self.encryption_key = self._generate_encryption_key()
33 self.is_first_request = True
34
35 def is_token_expired(self) -> bool:
36 """Check if the current token has expired"""
37 return time.time() >= self.expires_at
38
39 def update_token(self, access_token: str, expires_in: int):
40 """Update the access token and expiration time"""
41 self.access_token = access_token
42 self.expires_at = time.time() + expires_in - 60
43
44 @staticmethod
45 def _generate_encryption_key() -> str:
46 """Generates a 32-byte, Base64-encoded key for the session."""
47 random_bytes = os.urandom(32)
48 return base64.b64encode(random_bytes).decode('utf-8')
49
50 @staticmethod
51 def generate_conversation_id() -> str:
52 """Generate conversation ID in Opera Aria format"""
53 parts = [
54 ''.join(random.choices('0123456789abcdef', k=8)),
55 ''.join(random.choices('0123456789abcdef', k=4)),
56 '11f0',
57 ''.join(random.choices('0123456789abcdef', k=4)),
58 ''.join(random.choices('0123456789abcdef', k=12))
59 ]
60 return '-'.join(parts)
61
62
63 class OperaAria(AsyncGeneratorProvider, ProviderModelMixin):
64 label = "Opera Aria"
65 url = "https://play.google.com/store/apps/details?id=com.opera.browser"
66 api_endpoint = "https://composer.opera-api.com/api/v1/a-chat"
67 token_endpoint = "https://oauth2.opera-api.com/oauth2/v1/token/"
68 signup_endpoint = "https://auth.opera.com/account/v2/external/anonymous/signup"
69 upload_endpoint = "https://composer.opera-api.com/api/v1/images/upload"
70 check_status_endpoint = "https://composer.opera-api.com/api/v1/images/check-status/"
71
72 working = True
73 needs_auth = False
74 supports_stream = True
75 supports_system_message = True
76 supports_message_history = True
77
78 default_model = 'aria'
79 default_image_model = 'aria'
80 image_models = ['aria']
81 default_vision_model = 'aria'
82 vision_models = ['aria']
83 models = ['aria']
84
85 @classmethod
86 async def _generate_refresh_token(cls, session: ClientSession) -> str:
87 headers = {
88 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0",
89 "Content-Type": "application/x-www-form-urlencoded",
90 }
91 data = {
92 "client_id": "ofa-client",
93 "client_secret": "N9OscfA3KxlJASuIe29PGZ5RpWaMTBoy",
94 "grant_type": "client_credentials",
95 "scope": "anonymous_account"
96 }
97 async with session.post(cls.token_endpoint, headers=headers, data=data) as response:
98 response.raise_for_status()
99 anonymous_token_data = await response.json()
100 anonymous_access_token = anonymous_token_data["access_token"]
101
102 headers = {
103 "User-Agent": "Mozilla 5.0 (Linux; Android 14) com.opera.browser OPR/89.5.4705.84314",
104 "Authorization": f"Bearer {anonymous_access_token}",
105 "Accept": "application/json",
106 "Content-Type": "application/json; charset=utf-8",
107 }
108 data = {"client_id": "ofa", "service": "aria"}
109 async with session.post(cls.signup_endpoint, headers=headers, json=data) as response:
110 response.raise_for_status()
111 signup_data = await response.json()
112 auth_token = signup_data["token"]
113
114 headers = {
115 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0",
116 "Content-Type": "application/x-www-form-urlencoded",
117 }
118 data = {
119 "auth_token": auth_token,
120 "client_id": "ofa",
121 "device_name": "GPT4FREE",
122 "grant_type": "auth_token",
123 "scope": "ALL"
124 }
125 async with session.post(cls.token_endpoint, headers=headers, data=data) as response:
126 response.raise_for_status()
127 final_token_data = await response.json()
128 return final_token_data["refresh_token"]
129
130 @classmethod
131 def get_model(cls, model: str) -> str:
132 return cls.model_aliases.get(model, cls.default_model)
133
134 @classmethod
135 async def get_access_token(cls, session: ClientSession, conversation: Conversation) -> str:
136 if not conversation.refresh_token:
137 conversation.refresh_token = await cls._generate_refresh_token(session)
138
139 if conversation.access_token and not conversation.is_token_expired():
140 return conversation.access_token
141
142 headers = {
143 "Content-Type": "application/x-www-form-urlencoded",
144 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0"
145 }
146 data = {
147 "client_id": "ofa",
148 "grant_type": "refresh_token",
149 "refresh_token": conversation.refresh_token,
150 "scope": "shodan:aria user:read"
151 }
152 async with session.post(cls.token_endpoint, headers=headers, data=data) as response:
153 response.raise_for_status()
154 result = await response.json()
155 conversation.update_token(
156 access_token=result["access_token"],
157 expires_in=result.get("expires_in", 3600)
158 )
159 return result["access_token"]
160
161 @classmethod
162 async def check_upload_status(cls, session: ClientSession, access_token: str, image_id: str, max_attempts: int = 30):
163 headers = {
164 "Authorization": f"Bearer {access_token}",
165 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0",
166 }
167 url = f"{cls.check_status_endpoint}{image_id}"
168 for _ in range(max_attempts):
169 async with session.get(url, headers=headers) as response:
170 response.raise_for_status()
171 result = await response.json()
172 if result.get("status") == "ok":
173 return
174 if result.get("status") == "failed":
175 raise Exception(f"Image upload failed for {image_id}")
176 await asyncio.sleep(0.5)
177 raise Exception(f"Timeout waiting for image upload status for {image_id}")
178
179 @classmethod
180 async def upload_media(cls, session: ClientSession, access_token: str, media_data: bytes, filename: str) -> str:
181 headers = {
182 "Authorization": f"Bearer {access_token}",
183 "Origin": "opera-aria://ui",
184 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0",
185 }
186 form_data = FormData()
187 if not filename:
188 filename = str(int(time.time() * 1000))
189 content_type = is_data_an_media(media_data, filename) or "application/octet-stream"
190 form_data.add_field('image_file', media_data, filename=filename, content_type=content_type)
191
192 async with session.post(cls.upload_endpoint, headers=headers, data=form_data) as response:
193 response.raise_for_status()
194 result = await response.json()
195 image_id = result.get("image_id")
196 if not image_id:
197 raise Exception("No image_id returned from upload")
198 await cls.check_upload_status(session, access_token, image_id)
199 return image_id
200
201 @classmethod
202 def extract_image_urls(cls, text: str) -> list[str]:
203 pattern = r'!\[\]\((https?://[^\)]+)\)'
204 urls = re.findall(pattern, text)
205 return [url.replace(r'\/', '/') for url in urls]
206
207 @classmethod
208 async def create_async_generator(
209 cls,
210 model: str,
211 messages: Messages,
212 proxy: str = None,
213 refresh_token: str = None,
214 conversation: Conversation = None,
215 return_conversation: bool = False,
216 stream: bool = True,
217 media: MediaListType = None,
218 **kwargs
219 ) -> AsyncResult:
220 model = cls.get_model(model)
221
222 if conversation is None:
223 conversation = Conversation(refresh_token)
224 elif refresh_token and not conversation.refresh_token:
225 conversation.refresh_token = refresh_token
226
227 async with ClientSession() as session:
228 access_token = await cls.get_access_token(session, conversation)
229
230 media_attachments = []
231 merged_media = list(merge_media(media, messages))
232 if merged_media:
233 for media_data, media_name in merged_media:
234 try:
235 if isinstance(media_data, str) and media_data.startswith("data:"):
236 data_part = media_data.split(",", 1)[1]
237 media_bytes = base64.b64decode(data_part)
238 elif hasattr(media_data, 'read'):
239 media_bytes = media_data.read()
240 elif isinstance(media_data, (str, os.PathLike)):
241 with open(media_data, 'rb') as f:
242 media_bytes = f.read()
243 else:
244 media_bytes = media_data
245
246 image_id = await cls.upload_media(session, access_token, media_bytes, media_name)
247 media_attachments.append(image_id)
248 except Exception:
249 continue
250
251 headers = {
252 "Accept": "text/event-stream" if stream else "application/json",
253 "Authorization": f"Bearer {access_token}",
254 "Content-Type": "application/json",
255 "Origin": "opera-aria://ui",
256 "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 OPR/89.0.0.0",
257 "X-Opera-Timezone": "+03:00",
258 "X-Opera-UI-Language": "en"
259 }
260
261 data = {
262 "query": format_prompt(messages), "stream": stream, "linkify": True,
263 "linkify_version": 3, "sia": True, "media_attachments": media_attachments,
264 "encryption": {"key": conversation.encryption_key}
265 }
266
267 if not conversation.is_first_request and conversation.conversation_id:
268 data["conversation_id"] = conversation.conversation_id
269
270 async with session.post(cls.api_endpoint, headers=headers, json=data, proxy=proxy) as response:
271 response.raise_for_status()
272
273 if stream:
274 text_buffer, image_urls, finish_reason = [], [], None
275
276 async for line in response.content:
277 if not line: continue
278 decoded = line.decode('utf-8').strip()
279 if not decoded.startswith('data: '): continue
280
281 content = decoded[6:]
282 if content == '[DONE]': break
283
284 try:
285 json_data = json.loads(content)
286 if 'message' in json_data:
287 message_chunk = json_data['message']
288 found_urls = cls.extract_image_urls(message_chunk)
289 if found_urls:
290 image_urls.extend(found_urls)
291 else:
292 text_buffer.append(message_chunk)
293
294 if 'conversation_id' in json_data and json_data['conversation_id']:
295 conversation.conversation_id = json_data['conversation_id']
296
297 if 'finish_reason' in json_data and json_data.get('finish_reason'):
298 finish_reason = json_data['finish_reason']
299
300 except json.JSONDecodeError:
301 continue
302
303 if image_urls:
304 yield ImageResponse(image_urls, format_prompt(messages))
305 elif text_buffer:
306 yield "".join(text_buffer)
307
308 if finish_reason:
309 yield FinishReason(finish_reason)
310
311 else: # Non-streaming
312 json_data = await response.json()
313 if 'message' in json_data:
314 message = json_data['message']
315 image_urls = cls.extract_image_urls(message)
316 if image_urls:
317 yield ImageResponse(image_urls, format_prompt(messages))
318 else:
319 yield message
320
321 if 'conversation_id' in json_data and json_data['conversation_id']:
322 conversation.conversation_id = json_data['conversation_id']
323
324 if 'finish_reason' in json_data and json_data['finish_reason']:
325 yield FinishReason(json_data['finish_reason'])
326
327 conversation.is_first_request = False
328
329 if return_conversation:
330 yield conversation
Added g4f/Provider/Startnest.py +216 -0
@@ -0,0 +1,216 @@
1 from __future__ import annotations
2
3 from aiohttp import ClientSession
4 import json
5 import time
6 import hashlib
7
8 from ..typing import AsyncResult, Messages, MediaListType
9 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
10 from .helper import format_prompt
11 from ..tools.media import merge_media
12 from ..image import to_data_uri
13 from ..providers.response import FinishReason
14
15
16 class Startnest(AsyncGeneratorProvider, ProviderModelMixin):
17 label = "Startnest"
18 url = "https://play.google.com/store/apps/details?id=starnest.aitype.aikeyboard.chatbot.chatgpt"
19 api_endpoint = "https://api.startnest.uk/api/completions/stream"
20
21 working = True
22 needs_auth = False
23 supports_stream = True
24 supports_system_message = True
25 supports_message_history = True
26
27 default_model = 'gpt-4o-mini'
28 default_vision_model = default_model
29 vision_models = [default_model, "gpt-4o-mini"]
30 models = vision_models
31
32 @classmethod
33 def generate_signature(cls, timestamp: int) -> str:
34 """
35 Generate signature for authorization header
36 You may need to adjust this based on the actual signature algorithm
37 """
38 # This is a placeholder - the actual signature generation might involve:
39 # - A secret key
40 # - Specific string formatting
41 # - Different hash input
42
43 # Example implementation (adjust as needed):
44 kid = "36ccfe00-78fc-4cab-9c5b-5460b0c78513"
45 algorithm = "sha256"
46 validity = 90
47 user_id = ""
48
49 # The actual signature generation logic needs to be determined
50 # This is just a placeholder that creates a hash from timestamp
51 signature_input = f"{kid}{timestamp}{validity}".encode()
52 signature_value = hashlib.sha256(signature_input).hexdigest()
53
54 return f"Signature kid={kid}&algorithm={algorithm}&timestamp={timestamp}&validity={validity}&userId={user_id}&value={signature_value}"
55
56 @classmethod
57 async def create_async_generator(
58 cls,
59 model: str,
60 messages: Messages,
61 proxy: str = None,
62 media: MediaListType = None,
63 stream: bool = True,
64 max_tokens: int = None,
65 **kwargs
66 ) -> AsyncResult:
67 model = cls.get_model(model)
68
69 # Generate current timestamp
70 timestamp = int(time.time())
71
72 headers = {
73 "Accept-Encoding": "gzip",
74 "app_name": "AIKEYBOARD",
75 "Authorization": cls.generate_signature(timestamp),
76 "Connection": "Keep-Alive",
77 "Content-Type": "application/json; charset=UTF-8",
78 "Host": "api.startnest.uk",
79 "User-Agent": "okhttp/4.9.0",
80 }
81
82 async with ClientSession() as session:
83 # Merge media with messages
84 media = list(merge_media(media, messages))
85
86 # Convert messages to the required format
87 formatted_messages = []
88 for i, msg in enumerate(messages):
89 if isinstance(msg, dict):
90 role = msg.get("role", "user")
91 content = msg.get("content", "")
92
93 # Create content array
94 content_array = []
95
96 # Add images if this is the last user message and media exists
97 if media and role == "user" and i == len(messages) - 1:
98 for image, image_name in media:
99 image_data_uri = to_data_uri(image)
100 content_array.append({
101 "image_url": {
102 "url": image_data_uri
103 },
104 "type": "image_url"
105 })
106
107 # Add text content
108 if content:
109 content_array.append({
110 "text": content,
111 "type": "text"
112 })
113
114 formatted_messages.append({
115 "role": role,
116 "content": content_array
117 })
118
119 # If only one message and no media, use format_prompt as requested
120 if len(messages) == 1 and not media:
121 prompt_text = format_prompt(messages)
122 formatted_messages = [{
123 "role": "user",
124 "content": [{"text": prompt_text, "type": "text"}]
125 }]
126
127 data = {
128 "isVip": True,
129 "max_tokens": max_tokens,
130 "messages": formatted_messages,
131 "stream": stream
132 }
133
134 # Add advanceToolType if media is present
135 if media:
136 data["advanceToolType"] = "upload_and_ask"
137
138 async with session.post(cls.api_endpoint, json=data, headers=headers, proxy=proxy) as response:
139 response.raise_for_status()
140
141 if stream:
142 # Handle streaming response (SSE format)
143 async for line in response.content:
144 if line:
145 line = line.decode('utf-8').strip()
146 if line.startswith("data: "):
147 data_str = line[6:]
148 if data_str == "[DONE]":
149 break
150 try:
151 json_data = json.loads(data_str)
152 if "choices" in json_data and len(json_data["choices"]) > 0:
153 choice = json_data["choices"][0]
154
155 # Handle content
156 delta = choice.get("delta", {})
157 content = delta.get("content", "")
158 if content:
159 yield content
160
161 # Handle finish_reason
162 if "finish_reason" in choice and choice["finish_reason"] is not None:
163 yield FinishReason(choice["finish_reason"])
164 break
165
166 except json.JSONDecodeError:
167 continue
168 else:
169 # Handle non-streaming response (regular JSON)
170 response_text = await response.text()
171 try:
172 json_data = json.loads(response_text)
173 if "choices" in json_data and len(json_data["choices"]) > 0:
174 choice = json_data["choices"][0]
175 if "message" in choice and "content" in choice["message"]:
176 content = choice["message"]["content"]
177 if content:
178 yield content.strip()
179
180 # Handle finish_reason for non-streaming
181 if "finish_reason" in choice and choice["finish_reason"] is not None:
182 yield FinishReason(choice["finish_reason"])
183 return
184
185 except json.JSONDecodeError:
186 # If it's still SSE format even when stream=False, handle it
187 lines = response_text.strip().split('\n')
188 full_content = []
189 finish_reason_value = None
190
191 for line in lines:
192 if line.startswith("data: "):
193 data_str = line[6:]
194 if data_str == "[DONE]":
195 break
196 try:
197 json_data = json.loads(data_str)
198 if "choices" in json_data and len(json_data["choices"]) > 0:
199 choice = json_data["choices"][0]
200 delta = choice.get("delta", {})
201 content = delta.get("content", "")
202 if content:
203 full_content.append(content)
204
205 # Store finish_reason
206 if "finish_reason" in choice and choice["finish_reason"] is not None:
207 finish_reason_value = choice["finish_reason"]
208
209 except json.JSONDecodeError:
210 continue
211
212 if full_content:
213 yield ''.join(full_content)
214
215 if finish_reason_value:
216 yield FinishReason(finish_reason_value)
Modified g4f/Provider/Together.py +13 -7
@@ -58,20 +58,21 @@ class Together(OpenaiTemplate):
58 58 #"llama-vision": "meta-llama/Llama-Vision-Free",
59 59 "llama-3-8b": ["meta-llama/Llama-3-8b-chat-hf", "meta-llama/Meta-Llama-3-8B-Instruct-Lite", "roberizk@gmail.com/meta-llama/Meta-Llama-3-8B-Instruct-8ced8839",],
60 60 "llama-3.1-70b": ["meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", "Rrrr/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo-03dc18e1", "Rrrr/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo-6c92f39d"],
61 "llama-3.1-405b": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
61 "llama-3.1-405b": ["meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", "eddiehou/meta-llama/Llama-3.1-405B"],
62 62 "llama-4-maverick": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
63 63
64 64 # arcee-ai
65 #"arcee-spotlight": "arcee-ai/arcee-spotlight",
65 #"arcee-spotlight": "arcee_ai/arcee-spotlight",
66 66 #"arcee-blitz": "arcee-ai/arcee-blitz",
67 67 #"arcee-caller": "arcee-ai/caller",
68 68 #"arcee-virtuoso-large": "arcee-ai/virtuoso-large",
69 69 #"arcee-virtuoso-medium": "arcee-ai/virtuoso-medium-v2",
70 70 #"arcee-coder-large": "arcee-ai/coder-large",
71 71 #"arcee-maestro": "arcee-ai/maestro-reasoning",
72 #"afm-4.5b": "arcee-ai/AFM-4.5B-Preview",
72 73
73 74 # deepseek-ai
74 "deepseek-r1": "deepseek-ai/DeepSeek-R1",
75 "deepseek-r1": ["deepseek-ai/DeepSeek-R1", "deepseek-ai/DeepSeek-R1-0528-tput"],
75 76 "deepseek-v3": ["deepseek-ai/DeepSeek-V3", "deepseek-ai/DeepSeek-V3-p-dp"],
76 77 "deepseek-r1-distill-llama-70b": ["deepseek-ai/DeepSeek-R1-Distill-Llama-70B", "deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free"],
77 78 "deepseek-r1-distill-qwen-1.5b": "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
@@ -86,6 +87,7 @@ class Together(OpenaiTemplate):
86 87 "qwen-2.5-72b": "Qwen/Qwen2.5-72B-Instruct-Turbo",
87 88 "qwen-3-235b": ["Qwen/Qwen3-235B-A22B-fp8", "Qwen/Qwen3-235B-A22B-fp8-tput"],
88 89 "qwen-2-72b": "Qwen/Qwen2-72B-Instruct",
90 "qwen-3-32b": "Qwen/Qwen3-32B-FP8",
89 91
90 92 # mistralai
91 93 "mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
@@ -93,8 +95,10 @@ class Together(OpenaiTemplate):
93 95 "mistral-7b": ["mistralai/Mistral-7B-Instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.2", "mistralai/Mistral-7B-Instruct-v0.3"],
94 96
95 97 # google
96 #"gemma-2b": "google/gemma-2b-it",
98 "gemma-2b": "google/gemma-2b-it",
97 99 "gemma-2-27b": "google/gemma-2-27b-it",
100 "gemma-3-27b": "google/gemma-3-27b-it",
101 "gemma-3n-e4b": "google/gemma-3n-E4B-it",
98 102
99 103 # nvidia
100 104 "nemotron-70b": "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
@@ -120,15 +124,16 @@ class Together(OpenaiTemplate):
120 124 #"marin-8b": "marin-community/marin-8b-instruct",
121 125
122 126 # scb10x
123 #"typhoon-2-8b": "scb10x/scb10x-llama3-1-typhoon2-8b-instruct",
124 127 #"typhoon-2-70b": "scb10x/scb10x-llama3-1-typhoon2-70b-instruct",
128 #"typhoon-2.1": "scb10x/scb10x-typhoon-2-1-gemma3-12b",
125 129
126 130 # perplexity-ai
127 131 "r1-1776": "perplexity-ai/r1-1776",
128 132
129 133 ### Models Image ###
130 134 # black-forest-labs
131 "flux": ["black-forest-labs/FLUX.1-schnell-Free", "black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1.1-pro", "black-forest-labs/FLUX.1-pro", "black-forest-labs/FLUX.1-dev"],
135 "flux": ["black-forest-labs/FLUX.1-schnell-Free", "black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1.1-pro", "black-forest-labs/FLUX.1-pro", "black-forest-labs/FLUX.1.1-pro", "black-forest-labs/FLUX.1-pro", "black-forest-labs/FLUX.1-redux", "black-forest-labs/FLUX.1-depth", "black-forest-labs/FLUX.1-canny", "black-forest-labs/FLUX.1-kontext-max", "black-forest-labs/FLUX.1-dev-lora", "black-forest-labs/FLUX.1-dev", "black-forest-labs/FLUX.1-dev-lora", "black-forest-labs/FLUX.1-kontext-pro", "black-forest-labs/FLUX.1-kontext-dev"],
136
132 137 "flux-schnell": ["black-forest-labs/FLUX.1-schnell-Free", "black-forest-labs/FLUX.1-schnell"],
133 138 "flux-pro": ["black-forest-labs/FLUX.1.1-pro", "black-forest-labs/FLUX.1-pro"],
134 139 "flux-redux": "black-forest-labs/FLUX.1-redux",
@@ -137,7 +142,8 @@ class Together(OpenaiTemplate):
137 142 "flux-kontext-max": "black-forest-labs/FLUX.1-kontext-max",
138 143 "flux-dev-lora": "black-forest-labs/FLUX.1-dev-lora",
139 144 "flux-dev": ["black-forest-labs/FLUX.1-dev", "black-forest-labs/FLUX.1-dev-lora"],
140 "flux-kontext-pro": "black-forest-labs/FLUX.1-kontext-pro"
145 "flux-kontext-pro": "black-forest-labs/FLUX.1-kontext-pro",
146 "flux-kontext-dev": "black-forest-labs/FLUX.1-kontext-dev",
141 147 }
142 148
143 149 @classmethod
Modified g4f/Provider/__init__.py +2 -2
@@ -40,18 +40,18 @@ from .Copilot import Copilot
40 40 from .DeepInfraChat import DeepInfraChat
41 41 from .DuckDuckGo import DuckDuckGo
42 42 from .Free2GPT import Free2GPT
43 from .FreeGpt import FreeGpt
44 43 from .ImageLabs import ImageLabs
45 44 from .LambdaChat import LambdaChat
46 45 from .LegacyLMArena import LegacyLMArena
47 46 from .OIVSCodeSer2 import OIVSCodeSer2
48 47 from .OIVSCodeSer0501 import OIVSCodeSer0501
48 from .OperaAria import OperaAria
49 49 from .PerplexityLabs import PerplexityLabs
50 50 from .PollinationsAI import PollinationsAI
51 51 from .PollinationsImage import PollinationsImage
52 from .Startnest import Startnest
52 53 from .TeachAnything import TeachAnything
53 54 from .Together import Together
54 from .Websim import Websim
55 55 from .WeWordle import WeWordle
56 56 from .Yqcloud import Yqcloud
57 57
Renamed g4f/Provider/not_working/FreeGpt.py +5 -5
@@ -4,10 +4,10 @@ import time
4 4 import hashlib
5 5 import random
6 6 from typing import AsyncGenerator, Optional, Dict, Any
7 from ..typing import Messages
8 from ..requests import StreamSession, raise_for_status
9 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
10 from ..errors import RateLimitError
7 from ...typing import Messages
8 from ...requests import StreamSession, raise_for_status
9 from ..base_provider import AsyncGeneratorProvider, ProviderModelMixin
10 from ...errors import RateLimitError
11 11
12 12 # Constants
13 13 DOMAINS = [
@@ -22,7 +22,7 @@ RATE_LIMIT_ERROR_MESSAGE = "当前地区当日额度已消耗完"
22 22 class FreeGpt(AsyncGeneratorProvider, ProviderModelMixin):
23 23 url = "https://freegptsnav.aifree.site"
24 24
25 working = True
25 working = False
26 26 supports_message_history = True
27 27 supports_system_message = True
28 28
Renamed g4f/Provider/not_working/Websim.py +9 -9
@@ -6,12 +6,12 @@ import string
6 6 import asyncio
7 7 from aiohttp import ClientSession
8 8
9 from ..typing import AsyncResult, Messages
10 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
11 from ..requests.raise_for_status import raise_for_status
12 from ..errors import ResponseStatusError
13 from ..providers.response import ImageResponse
14 from .helper import format_prompt, format_media_prompt
9 from ...typing import AsyncResult, Messages
10 from ..base_provider import AsyncGeneratorProvider, ProviderModelMixin
11 from ...requests.raise_for_status import raise_for_status
12 from ...errors import ResponseStatusError
13 from ...providers.response import ImageResponse
14 from ..helper import format_prompt, format_media_prompt
15 15
16 16
17 17 class Websim(AsyncGeneratorProvider, ProviderModelMixin):
@@ -20,17 +20,17 @@ class Websim(AsyncGeneratorProvider, ProviderModelMixin):
20 20 chat_api_endpoint = "https://websim.ai/api/v1/inference/run_chat_completion"
21 21 image_api_endpoint = "https://websim.ai/api/v1/inference/run_image_generation"
22 22
23 working = True
23 working = False
24 24 needs_auth = False
25 25 use_nodriver = False
26 26 supports_stream = False
27 27 supports_system_message = True
28 28 supports_message_history = True
29 29
30 default_model = 'gemini-1.5-pro'
30 default_model = 'gemini-2.5-pro'
31 31 default_image_model = 'flux'
32 32 image_models = [default_image_model]
33 models = [default_model, 'gemini-1.5-flash'] + image_models
33 models = [default_model, 'gemini-2.5-flash'] + image_models
34 34
35 35 @staticmethod
36 36 def generate_project_id(for_image=False):
Modified g4f/Provider/not_working/__init__.py +3 -0
@@ -15,6 +15,7 @@ from .ChatGptt import ChatGptt
15 15 from .DDG import DDG
16 16 from .Equing import Equing
17 17 from .FlowGpt import FlowGpt
18 from .FreeGpt import FreeGpt
18 19 from .FreeNetfly import FreeNetfly
19 20 from .FreeRouter import FreeRouter
20 21 from .Glider import Glider
@@ -33,3 +34,5 @@ from .Theb import Theb
33 34 from .TypeGPT import TypeGPT
34 35 from .Upstage import Upstage
35 36 from .Vercel import Vercel
37 from .Websim import Websim
38
Modified g4f/cli/client.py +0 -0
此文件没有可显示的逐行差异。
Modified g4f/models.py +81 -19
@@ -12,7 +12,6 @@ from .Provider import (
12 12 Copilot,
13 13 DeepInfraChat,
14 14 Free2GPT,
15 FreeGpt,
16 15 HuggingSpace,
17 16 Grok,
18 17 DeepseekAI_JanusPro7b,
@@ -21,13 +20,14 @@ from .Provider import (
21 20 LambdaChat,
22 21 OIVSCodeSer2,
23 22 OIVSCodeSer0501,
23 OperaAria,
24 Startnest,
24 25 OpenAIFM,
25 26 PerplexityLabs,
26 27 PollinationsAI,
27 28 PollinationsImage,
28 29 TeachAnything,
29 30 Together,
30 Websim,
31 31 WeWordle,
32 32 Yqcloud,
33 33
@@ -148,11 +148,12 @@ default = Model(
148 148 Blackbox,
149 149 Copilot,
150 150 DeepInfraChat,
151 OperaAria,
152 Startnest,
151 153 LambdaChat,
152 154 PollinationsAI,
153 155 Together,
154 156 Free2GPT,
155 FreeGpt,
156 157 Chatai,
157 158 WeWordle,
158 159 OpenaiChat,
@@ -166,9 +167,11 @@ default_vision = VisionModel(
166 167 best_provider = IterListProvider([
167 168 Blackbox,
168 169 DeepInfraChat,
169 OIVSCodeSer2,
170 170 OIVSCodeSer0501,
171 OIVSCodeSer2,
171 172 PollinationsAI,
173 OperaAria,
174 Startnest,
172 175 Together,
173 176 HuggingSpace,
174 177 GeminiPro,
@@ -196,7 +199,7 @@ gpt_4o = VisionModel(
196 199 gpt_4o_mini = Model(
197 200 name = 'gpt-4o-mini',
198 201 base_provider = 'OpenAI',
199 best_provider = IterListProvider([Blackbox, OIVSCodeSer2, PollinationsAI, Chatai, OpenaiChat])
202 best_provider = IterListProvider([Blackbox, PollinationsAI, Chatai, OIVSCodeSer2, Startnest, OpenaiChat])
200 203 )
201 204
202 205 gpt_4o_mini_audio = AudioModel(
@@ -398,12 +401,6 @@ mixtral_8x7b = Model(
398 401 best_provider = Together
399 402 )
400 403
401 mixtral_8x22b = Model(
402 name = "mixtral-8x22b",
403 base_provider = "Mistral AI",
404 best_provider = DeepInfraChat
405 )
406
407 404 mistral_nemo = Model(
408 405 name = "mistral-nemo",
409 406 base_provider = "Mistral AI",
@@ -413,13 +410,13 @@ mistral_nemo = Model(
413 410 mistral_small_24b = Model(
414 411 name = "mistral-small-24b",
415 412 base_provider = "Mistral AI",
416 best_provider = IterListProvider([DeepInfraChat, Together])
413 best_provider = Together
417 414 )
418 415
419 416 mistral_small_3_1_24b = Model(
420 417 name = "mistral-small-3.1-24b",
421 418 base_provider = "Mistral AI",
422 best_provider = PollinationsAI
419 best_provider = IterListProvider([DeepInfraChat, PollinationsAI])
423 420 )
424 421
425 422 ### NousResearch ###
@@ -481,13 +478,13 @@ gemini = Model(
481 478 gemini_1_5_flash = Model(
482 479 name = 'gemini-1.5-flash',
483 480 base_provider = 'Google',
484 best_provider = IterListProvider([Free2GPT, FreeGpt, TeachAnything, Websim])
481 best_provider = IterListProvider([Free2GPT, TeachAnything])
485 482 )
486 483
487 484 gemini_1_5_pro = Model(
488 485 name = 'gemini-1.5-pro',
489 486 base_provider = 'Google',
490 best_provider = IterListProvider([Free2GPT, FreeGpt, TeachAnything, Websim])
487 best_provider = IterListProvider([Free2GPT, TeachAnything])
491 488 )
492 489
493 490 # gemini-2.0
@@ -522,7 +519,34 @@ gemini_2_5_pro = Model(
522 519 best_provider = IterListProvider([Gemini])
523 520 )
524 521
522 # codegemma
523 codegemma_7b = Model(
524 name = 'codegemma-7b',
525 base_provider = 'Google',
526 best_provider = DeepInfraChat
527 )
528
529 # gemma
530 gemma_2b = Model(
531 name = 'gemma-2b',
532 base_provider = 'Google',
533 best_provider = Together
534 )
535
536 # gemma-1
537 gemma_1_1_7b = Model(
538 name = 'gemma-1.1-7b',
539 base_provider = 'Google',
540 best_provider = DeepInfraChat
541 )
542
525 543 # gemma-2
544 gemma_2_9b = Model(
545 name = 'gemma-2-9b',
546 base_provider = 'Google',
547 best_provider = DeepInfraChat
548 )
549
526 550 gemma_2_27b = Model(
527 551 name = 'gemma-2-27b',
528 552 base_provider = 'Google',
@@ -530,6 +554,12 @@ gemma_2_27b = Model(
530 554 )
531 555
532 556 # gemma-3
557 gemma_3_4b = Model(
558 name = 'gemma-3-4b',
559 base_provider = 'Google',
560 best_provider = DeepInfraChat
561 )
562
533 563 gemma_3_12b = Model(
534 564 name = 'gemma-3-12b',
535 565 base_provider = 'Google',
@@ -539,7 +569,13 @@ gemma_3_12b = Model(
539 569 gemma_3_27b = Model(
540 570 name = 'gemma-3-27b',
541 571 base_provider = 'Google',
542 best_provider = DeepInfraChat
572 best_provider = IterListProvider([DeepInfraChat, Together])
573 )
574
575 gemma_3n_e4b = Model(
576 name = 'gemma-3n-e4b',
577 base_provider = 'Google',
578 best_provider = Together
543 579 )
544 580
545 581 ### Blackbox AI ###
@@ -586,7 +622,7 @@ qwen_1_5_7b = Model(
586 622 qwen_2_72b = Model(
587 623 name = 'qwen-2-72b',
588 624 base_provider = 'Qwen',
589 best_provider = IterListProvider([DeepInfraChat, HuggingSpace, Together])
625 best_provider = IterListProvider([HuggingSpace, Together])
590 626 )
591 627
592 628 qwen_2_vl_7b = VisionModel(
@@ -654,7 +690,7 @@ qwen_3_235b = Model(
654 690 qwen_3_32b = Model(
655 691 name = 'qwen-3-32b',
656 692 base_provider = 'Qwen',
657 best_provider = IterListProvider([DeepInfraChat, LambdaChat, HuggingSpace])
693 best_provider = IterListProvider([DeepInfraChat, LambdaChat, Together, HuggingSpace])
658 694 )
659 695
660 696 qwen_3_30b = Model(
@@ -759,6 +795,12 @@ deepseek_v3_0324 = Model(
759 795 best_provider = IterListProvider([DeepInfraChat, LambdaChat, PollinationsAI])
760 796 )
761 797
798 deepseek_v3_0324_turbo = Model(
799 name = 'deepseek-v3-0324-turbo',
800 base_provider = 'DeepSeek',
801 best_provider = DeepInfraChat
802 )
803
762 804 # deepseek-r1-0528
763 805 deepseek_r1_0528 = Model(
764 806 name = 'deepseek-r1-0528',
@@ -766,6 +808,12 @@ deepseek_r1_0528 = Model(
766 808 best_provider = IterListProvider([DeepInfraChat, LambdaChat])
767 809 )
768 810
811 deepseek_r1_0528_turbo = Model(
812 name = 'deepseek-r1-0528-turbo',
813 base_provider = 'DeepSeek',
814 best_provider = DeepInfraChat
815 )
816
769 817 # janus
770 818 janus_pro_7b = VisionModel(
771 819 name = DeepseekAI_JanusPro7b.default_model,
@@ -871,6 +919,13 @@ lfm_40b = Model(
871 919 best_provider = LambdaChat
872 920 )
873 921
922 ### Opera ###
923 aria = Model(
924 name = "aria",
925 base_provider = "Opera",
926 best_provider = OperaAria
927 )
928
874 929 ### Uncensored AI ###
875 930 evil = Model(
876 931 name = 'evil',
@@ -878,6 +933,7 @@ evil = Model(
878 933 best_provider = PollinationsAI
879 934 )
880 935
936 ### Stability AI ###
881 937 sdxl_turbo = ImageModel(
882 938 name = 'sdxl-turbo',
883 939 base_provider = 'Stability AI',
@@ -894,7 +950,7 @@ sd_3_5_large = ImageModel(
894 950 flux = ImageModel(
895 951 name = 'flux',
896 952 base_provider = 'Black Forest Labs',
897 best_provider = IterListProvider([HuggingFaceMedia, PollinationsImage, Websim, Together, HuggingSpace])
953 best_provider = IterListProvider([HuggingFaceMedia, PollinationsImage, Together, HuggingSpace])
898 954 )
899 955
900 956 flux_pro = ImageModel(
@@ -951,6 +1007,12 @@ flux_kontext_pro = ImageModel(
951 1007 best_provider = Together
952 1008 )
953 1009
1010 flux_kontext_dev = ImageModel(
1011 name = 'flux-kontext-dev',
1012 base_provider = 'Black Forest Labs',
1013 best_provider = Together
1014 )
1015
954 1016 class ModelUtils:
955 1017 """
956 1018 Utility class for mapping string identifiers to Model instances.
Modified g4f/providers/any_model_map.py +11 -7
Modified g4f/providers/any_provider.py +3 -3
Modified g4f/tools/web_search.py +26 -108
Modified requirements.txt +1 -1