g4f 6.9.2__py3-none-any.whl → 6.9.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- g4f/Provider/PollinationsAI.py +62 -35
- g4f/Provider/Qwen.py +13 -11
- g4f/Provider/local/Ollama.py +0 -1
- g4f/Provider/needs_auth/Azure.py +0 -1
- g4f/Provider/needs_auth/Groq.py +0 -1
- g4f/Provider/needs_auth/Nvidia.py +0 -1
- g4f/Provider/needs_auth/OpenRouter.py +0 -1
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/METADATA +1 -1
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/RECORD +13 -13
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/WHEEL +1 -1
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/entry_points.txt +0 -0
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/licenses/LICENSE +0 -0
- {g4f-6.9.2.dist-info → g4f-6.9.4.dist-info}/top_level.txt +0 -0
g4f/Provider/PollinationsAI.py
CHANGED
|
@@ -31,18 +31,20 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
31
31
|
label = "Pollinations AI 🌸"
|
|
32
32
|
url = "https://pollinations.ai"
|
|
33
33
|
login_url = "https://enter.pollinations.ai"
|
|
34
|
+
api_key = "pk", "_B9YJX5SBohhm2ePq"
|
|
34
35
|
active_by_default = True
|
|
35
36
|
working = True
|
|
36
37
|
supports_system_message = True
|
|
37
38
|
supports_message_history = True
|
|
38
39
|
|
|
39
40
|
# API endpoints
|
|
40
|
-
text_api_endpoint = "https://
|
|
41
|
+
text_api_endpoint = "https://text.pollinations.ai/openai"
|
|
41
42
|
image_api_endpoint = "https://image.pollinations.ai/prompt/{}"
|
|
42
43
|
gen_image_api_endpoint = "https://gen.pollinations.ai/image/{}"
|
|
43
44
|
gen_text_api_endpoint = "https://gen.pollinations.ai/v1/chat/completions"
|
|
44
45
|
image_models_endpoint = "https://gen.pollinations.ai/image/models"
|
|
45
46
|
text_models_endpoint = "https://gen.pollinations.ai/text/models"
|
|
47
|
+
BALANCE_ENDPOINT = "https://gen.pollinations.ai/account/balance"
|
|
46
48
|
|
|
47
49
|
# Models configuration
|
|
48
50
|
default_model = "openai"
|
|
@@ -71,6 +73,21 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
71
73
|
"flux-kontext": "kontext",
|
|
72
74
|
}
|
|
73
75
|
swap_model_aliases = {v: k for k, v in model_aliases.items()}
|
|
76
|
+
balance: Optional[float] = None
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def get_balance(cls, api_key: str, timeout: Optional[float] = None) -> Optional[float]:
|
|
80
|
+
try:
|
|
81
|
+
headers = {"authorization": f"Bearer {api_key}"}
|
|
82
|
+
response = requests.get(cls.BALANCE_ENDPOINT, headers=headers, timeout=timeout)
|
|
83
|
+
response.raise_for_status()
|
|
84
|
+
data = response.json()
|
|
85
|
+
cls.balance = float(data.get("balance", 0.0))
|
|
86
|
+
debug.log(f"Pollinations AI balance: {cls.balance:.2f} Pollen")
|
|
87
|
+
return cls.balance
|
|
88
|
+
except Exception as e:
|
|
89
|
+
debug.error(f"Failed to get balance:", e)
|
|
90
|
+
return None
|
|
74
91
|
|
|
75
92
|
@classmethod
|
|
76
93
|
def get_models(cls, api_key: Optional[str] = None, timeout: Optional[float] = None, **kwargs):
|
|
@@ -86,6 +103,14 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
86
103
|
|
|
87
104
|
if not api_key:
|
|
88
105
|
api_key = AuthManager.load_api_key(cls)
|
|
106
|
+
if not api_key or api_key.startswith("g4f_") or api_key.startswith("gfs_"):
|
|
107
|
+
api_key = "".join(cls.api_key)
|
|
108
|
+
|
|
109
|
+
if cls.balance or cls.balance is None and cls.get_balance(api_key, timeout) and cls.balance > 0:
|
|
110
|
+
debug.log(f"Authenticated with Pollinations AI using API key.")
|
|
111
|
+
else:
|
|
112
|
+
debug.log(f"Using Pollinations AI without authentication.")
|
|
113
|
+
api_key = None
|
|
89
114
|
|
|
90
115
|
if not cls._free_models_loaded or api_key and not cls._gen_models_loaded:
|
|
91
116
|
path = Path(get_cookies_dir()) / "models" / datetime.today().strftime('%Y-%m-%d') / f"{cls.__name__}{'-auth' if api_key else ''}.json"
|
|
@@ -194,36 +219,36 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
194
219
|
|
|
195
220
|
@classmethod
|
|
196
221
|
async def create_async_generator(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
cls,
|
|
223
|
+
model: str,
|
|
224
|
+
messages: Messages,
|
|
225
|
+
stream: bool = True,
|
|
226
|
+
proxy: str = None,
|
|
227
|
+
cache: bool = None,
|
|
228
|
+
api_key: str = None,
|
|
229
|
+
extra_body: dict = None,
|
|
230
|
+
# Image generation parameters
|
|
231
|
+
prompt: str = None,
|
|
232
|
+
aspect_ratio: str = None,
|
|
233
|
+
width: int = None,
|
|
234
|
+
height: int = None,
|
|
235
|
+
seed: Optional[int] = None,
|
|
236
|
+
nologo: bool = True,
|
|
237
|
+
private: bool = False,
|
|
238
|
+
enhance: bool = None,
|
|
239
|
+
safe: bool = False,
|
|
240
|
+
transparent: bool = False,
|
|
241
|
+
n: int = 1,
|
|
242
|
+
# Text generation parameters
|
|
243
|
+
media: MediaListType = None,
|
|
244
|
+
temperature: float = None,
|
|
245
|
+
presence_penalty: float = None,
|
|
246
|
+
top_p: float = None,
|
|
247
|
+
frequency_penalty: float = None,
|
|
248
|
+
response_format: Optional[dict] = None,
|
|
249
|
+
extra_parameters: list[str] = ["tools", "parallel_tool_calls", "tool_choice", "reasoning_effort",
|
|
250
|
+
"logit_bias", "voice", "modalities", "audio"],
|
|
251
|
+
**kwargs
|
|
227
252
|
) -> AsyncResult:
|
|
228
253
|
if cache is None:
|
|
229
254
|
cache = kwargs.get("action") != "variant"
|
|
@@ -237,7 +262,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
237
262
|
has_audio = True
|
|
238
263
|
break
|
|
239
264
|
model = "openai-audio" if has_audio else cls.default_model
|
|
240
|
-
|
|
265
|
+
if cls.get_models(api_key=api_key, timeout=kwargs.get("timeout")):
|
|
241
266
|
if model in cls.model_aliases:
|
|
242
267
|
model = cls.model_aliases[model]
|
|
243
268
|
debug.log(f"Using model: {model}")
|
|
@@ -353,7 +378,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
353
378
|
return f"{url}&seed={seed}" if seed else url
|
|
354
379
|
|
|
355
380
|
headers = None
|
|
356
|
-
if api_key:
|
|
381
|
+
if api_key and api_key.startswith("g4f_") or api_key.startswith("gfs_"):
|
|
357
382
|
headers = {"authorization": f"Bearer {api_key}"}
|
|
358
383
|
async with ClientSession(
|
|
359
384
|
headers=DEFAULT_HEADERS,
|
|
@@ -456,10 +481,12 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
456
481
|
**extra_body
|
|
457
482
|
)
|
|
458
483
|
headers = None
|
|
459
|
-
if api_key:
|
|
484
|
+
if api_key and not api_key.startswith("g4f_") and not api_key.startswith("gfs_"):
|
|
460
485
|
headers = {"authorization": f"Bearer {api_key}"}
|
|
486
|
+
elif cls.balance > 0:
|
|
487
|
+
headers = {"authorization": f"Bearer {"".join(cls.api_key)}"}
|
|
461
488
|
yield JsonRequest.from_dict(data)
|
|
462
|
-
if
|
|
489
|
+
if headers:
|
|
463
490
|
url = cls.gen_text_api_endpoint
|
|
464
491
|
else:
|
|
465
492
|
url = cls.text_api_endpoint
|
g4f/Provider/Qwen.py
CHANGED
|
@@ -336,7 +336,7 @@ class Qwen(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
336
336
|
prompt = get_last_user_message(messages)
|
|
337
337
|
timeout = kwargs.get("timeout") or 5 * 60
|
|
338
338
|
# for _ in range(2):
|
|
339
|
-
|
|
339
|
+
data = generate_cookies()
|
|
340
340
|
# args,ua = await cls.get_args(proxy, **kwargs)
|
|
341
341
|
headers = {
|
|
342
342
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
|
|
@@ -349,10 +349,12 @@ class Qwen(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
349
349
|
'Sec-Fetch-Mode': 'cors',
|
|
350
350
|
'Sec-Fetch-Site': 'same-origin',
|
|
351
351
|
'Connection': 'keep-alive',
|
|
352
|
-
|
|
353
|
-
'
|
|
354
|
-
'Source': 'web'
|
|
352
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
353
|
+
'Cookie': f'ssxmod_itna={data["ssxmod_itna"]};ssxmod_itna2={data["ssxmod_itna2"]}',
|
|
354
|
+
'X-Source': 'web'
|
|
355
355
|
}
|
|
356
|
+
if token:
|
|
357
|
+
headers['Authorization'] = f'Bearer {token}'
|
|
356
358
|
|
|
357
359
|
# try:
|
|
358
360
|
async with StreamSession(headers=headers) as session:
|
|
@@ -435,16 +437,16 @@ class Qwen(AsyncGeneratorProvider, ProviderModelMixin):
|
|
|
435
437
|
"output_schema": "phase",
|
|
436
438
|
"thinking_budget": 81920
|
|
437
439
|
},
|
|
438
|
-
"
|
|
439
|
-
"meta": {
|
|
440
|
-
"subChatType": chat_type
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
"sub_chat_type": chat_type,
|
|
444
|
-
"parent_id": None
|
|
440
|
+
"sub_chat_type": chat_type
|
|
445
441
|
}
|
|
446
442
|
]
|
|
447
443
|
}
|
|
444
|
+
if enable_thinking:
|
|
445
|
+
msg_payload["messages"][0]["feature_config"] = {
|
|
446
|
+
"thinking_enabled": True,
|
|
447
|
+
"output_schema": "phase",
|
|
448
|
+
"thinking_budget": 81920
|
|
449
|
+
}
|
|
448
450
|
if aspect_ratio:
|
|
449
451
|
msg_payload["size"] = aspect_ratio
|
|
450
452
|
|
g4f/Provider/local/Ollama.py
CHANGED
g4f/Provider/needs_auth/Azure.py
CHANGED
|
@@ -15,7 +15,6 @@ class Azure(OpenaiTemplate):
|
|
|
15
15
|
label = "Azure ☁️"
|
|
16
16
|
url = "https://ai.azure.com"
|
|
17
17
|
base_url = "https://g4f.dev/api/azure"
|
|
18
|
-
backup_url = "https://g4f.dev/api/azure"
|
|
19
18
|
working = True
|
|
20
19
|
active_by_default = False
|
|
21
20
|
login_url = "https://discord.gg/qXA4Wf4Fsm"
|
g4f/Provider/needs_auth/Groq.py
CHANGED
|
@@ -7,7 +7,6 @@ class Groq(OpenaiTemplate):
|
|
|
7
7
|
url = "https://console.groq.com/playground"
|
|
8
8
|
login_url = "https://console.groq.com/keys"
|
|
9
9
|
base_url = "https://api.groq.com/openai/v1"
|
|
10
|
-
backup_url = "https://g4f.dev/api/groq"
|
|
11
10
|
working = True
|
|
12
11
|
active_by_default = True
|
|
13
12
|
default_model = DEFAULT_MODEL
|
|
@@ -6,7 +6,6 @@ from ...config import DEFAULT_MODEL
|
|
|
6
6
|
class Nvidia(OpenaiTemplate):
|
|
7
7
|
label = "Nvidia"
|
|
8
8
|
base_url = "https://integrate.api.nvidia.com/v1"
|
|
9
|
-
backup_url = "https://g4f.dev/api/nvidia"
|
|
10
9
|
login_url = "https://google.com"
|
|
11
10
|
url = "https://build.nvidia.com"
|
|
12
11
|
working = True
|
|
@@ -23,9 +23,9 @@ g4f/Provider/Mintlify.py,sha256=3Bvy1oh6scg4xs9pw5RY4mmi8XEvQDelnNp664TefbU,7937
|
|
|
23
23
|
g4f/Provider/OIVSCodeSer.py,sha256=clebON7Ssd9syewh3BWT59XOeB-WORXF6FPOwbzfRmo,1366
|
|
24
24
|
g4f/Provider/OperaAria.py,sha256=sLnTOKzbW9BxTxNmHXJ-YDnhPU6Dj6MBdDfqDh-Zz-c,14662
|
|
25
25
|
g4f/Provider/Perplexity.py,sha256=GUebbVin9hCg4FDei9RX2N6WboFcDDPm061WnnpPRaI,13236
|
|
26
|
-
g4f/Provider/PollinationsAI.py,sha256=
|
|
26
|
+
g4f/Provider/PollinationsAI.py,sha256=nsC2VntGavZJDiaAX0HhbWk6uWwYPTDCFGlnQCEyA4I,21458
|
|
27
27
|
g4f/Provider/PollinationsImage.py,sha256=wdGY9kbPGlqAkyeJcjXgWOG3HLVPU4QK-JENwg3gmwk,2297
|
|
28
|
-
g4f/Provider/Qwen.py,sha256=
|
|
28
|
+
g4f/Provider/Qwen.py,sha256=XPJHRlobijqjdDGVqA-aVyRx2SeM28zSWf-NmzxJtgE,23876
|
|
29
29
|
g4f/Provider/Startnest.py,sha256=OocXEAK3pKG-tC_D_chGE7GD22dZr67J1m7JBhLxniM,9526
|
|
30
30
|
g4f/Provider/StringableInference.py,sha256=ZohMZrVAn6G82zrYpLTvELkzfds4nxu09lx7wizFnbk,999
|
|
31
31
|
g4f/Provider/TeachAnything.py,sha256=ST87YdOdxtIc5JMaKzGdVy9J9wlhdhYIchRtXBljIBU,2843
|
|
@@ -55,11 +55,11 @@ g4f/Provider/hf_space/StabilityAI_SD35Large.py,sha256=-VT4qa_K6MshG2TX6y7k01NMGH
|
|
|
55
55
|
g4f/Provider/hf_space/__init__.py,sha256=licdlcuTs0yPwADmjBUA5uoN4ao-FnCUmlKiMWoHJ2g,3602
|
|
56
56
|
g4f/Provider/hf_space/raise_for_status.py,sha256=xoVwrZSwJUvqQkSfeUAMUst8SyobpSKPux1iYu4SNH0,935
|
|
57
57
|
g4f/Provider/local/Local.py,sha256=b6vSZcr5CfEXD5GMqNtwCfXNJtKyWKPg3jqBWJEZEwQ,1251
|
|
58
|
-
g4f/Provider/local/Ollama.py,sha256=
|
|
58
|
+
g4f/Provider/local/Ollama.py,sha256=ukgvoCSDiXEqhPc6i-awylqiuSnFLpau0uMX9YfsJuA,3770
|
|
59
59
|
g4f/Provider/local/__init__.py,sha256=cEFsdfkq0bgVAIM__Sxc6WfIoGa3_Ymol26kQb6x14k,73
|
|
60
60
|
g4f/Provider/needs_auth/AIBadgr.py,sha256=Oc05Cs-x40sF7tcrAyUqyoZ-TbtmV4wnMIm5aEjQ0xw,420
|
|
61
61
|
g4f/Provider/needs_auth/Anthropic.py,sha256=-8hRSpSGaC3-AzhkuIsf1K1w8ZVKKb_T6Pwy3N8JPak,10200
|
|
62
|
-
g4f/Provider/needs_auth/Azure.py,sha256=
|
|
62
|
+
g4f/Provider/needs_auth/Azure.py,sha256=XPgC4ffl8AitnzQB4K77v2eyXm_rLznz1VUiHIeRqaA,6107
|
|
63
63
|
g4f/Provider/needs_auth/BingCreateImages.py,sha256=_GrPx7KuttKrQ4IKX0fFwDPVsiCW9xTLycULNClZ6KQ,2066
|
|
64
64
|
g4f/Provider/needs_auth/BlackboxPro.py,sha256=BA-eiaVGczyB7BHQ47jehq6dTkEslithw1nN2whceZo,270382
|
|
65
65
|
g4f/Provider/needs_auth/CablyAI.py,sha256=113DsXPXAq3DO2QPHPJ0UJwMpXxomb7BM07RrcV6YQk,1253
|
|
@@ -79,13 +79,13 @@ g4f/Provider/needs_auth/GithubCopilot.py,sha256=AUoapqX6lwgC5WPIpKdKdhXcuXo4Stq7
|
|
|
79
79
|
g4f/Provider/needs_auth/GithubCopilotAPI.py,sha256=O-8Bq6eWrVZTYFS5QufMDJ9SiSFsd0Pz91yejb6spOI,353
|
|
80
80
|
g4f/Provider/needs_auth/GlhfChat.py,sha256=qSPKXnQ7igjF6_kiBnFhwq-YAqGmpZg_yu4OMRliSP4,1189
|
|
81
81
|
g4f/Provider/needs_auth/Grok.py,sha256=3uwt0vjsSNHLZKS2DcUHTztiNqPIemwW82E2x0AQRTw,12884
|
|
82
|
-
g4f/Provider/needs_auth/Groq.py,sha256=
|
|
82
|
+
g4f/Provider/needs_auth/Groq.py,sha256=30XyhPJYnZG-_t_gZx8vkLmJK-sYyvUE03edEJjbPbE,548
|
|
83
83
|
g4f/Provider/needs_auth/LMArena.py,sha256=Jchyimr78hUaHd9ntsdWX76_1uRGfNJJ4RFDcCBdlos,121389
|
|
84
84
|
g4f/Provider/needs_auth/MetaAI.py,sha256=Bz9pvJUVH7RtCAP1Huvay-EgO057fL362mhx3GtVAqM,10653
|
|
85
85
|
g4f/Provider/needs_auth/MetaAIAccount.py,sha256=D4LnhAt2MuKx1a4uSgX2lUbQrzAkeIYm8JCnZieZiak,672
|
|
86
86
|
g4f/Provider/needs_auth/MicrosoftDesigner.py,sha256=4sJdjBPgiW9TEh4CeplCTNPXv6ZtZtFh0SYAiVfnrqk,7178
|
|
87
|
-
g4f/Provider/needs_auth/Nvidia.py,sha256=
|
|
88
|
-
g4f/Provider/needs_auth/OpenRouter.py,sha256=
|
|
87
|
+
g4f/Provider/needs_auth/Nvidia.py,sha256=URMUSrLxUAA9YpI_DsdgQ3QlaOJ0JYRSClmYbTwXWM4,391
|
|
88
|
+
g4f/Provider/needs_auth/OpenRouter.py,sha256=KxALUf-mdoHHdYxEU53Rviyw7DRooFz39UMupDl-9V8,850
|
|
89
89
|
g4f/Provider/needs_auth/OpenaiAPI.py,sha256=KpJ6qvUlFsFqpQbcwikNYLVsFx6K9h393Pu-yf_uS3g,362
|
|
90
90
|
g4f/Provider/needs_auth/OpenaiAccount.py,sha256=vSe6Je-DoNbdGGEE-gNaW0Sa81rL8FPMaNyYr1U4PcI,209
|
|
91
91
|
g4f/Provider/needs_auth/OpenaiChat.py,sha256=dVSm-HAzlvb3KZqZNf0XYFxvIBTfXajKQfe8-JuO-vM,67285
|
|
@@ -210,9 +210,9 @@ g4f/tools/files.py,sha256=bUTbeNp8ujTZQiW3GLTtFcgl3-1AnH3cDyIKHfh6Mjc,23397
|
|
|
210
210
|
g4f/tools/media.py,sha256=AE9hGVRxQBVZzQ_Ylzeoo2TJUGXSBXO5RbLwj1I2ZTE,4701
|
|
211
211
|
g4f/tools/run_tools.py,sha256=Yb0osWdDt4wUnkvwln4R6qcLapdddC3n2giZMPXWkzM,16662
|
|
212
212
|
g4f/tools/web_search.py,sha256=vAZJD-qy15llsgAbkXzoEltqdFB6TlKLbqDJ1DS-6vs,2086
|
|
213
|
-
g4f-6.9.
|
|
214
|
-
g4f-6.9.
|
|
215
|
-
g4f-6.9.
|
|
216
|
-
g4f-6.9.
|
|
217
|
-
g4f-6.9.
|
|
218
|
-
g4f-6.9.
|
|
213
|
+
g4f-6.9.4.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
214
|
+
g4f-6.9.4.dist-info/METADATA,sha256=9L5vKFSberfEmFZECH8m8I9gB6t0Y2jpQvEbFg7qwK0,23255
|
|
215
|
+
g4f-6.9.4.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
216
|
+
g4f-6.9.4.dist-info/entry_points.txt,sha256=J7Usl6dNjXJlvuzGAUEm6cuDXWpVdGq7SfK-tPoiZSI,67
|
|
217
|
+
g4f-6.9.4.dist-info/top_level.txt,sha256=bMRlTupWYCcLWy80AnnKZkhpBsXsF8gI3BaMhSZSgRo,4
|
|
218
|
+
g4f-6.9.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|