返回提交历史
Modified
g4f/gui/client/static/js/chat.v1.js
+2
-1
Modified
g4f/gui/server/backend_api.py
+1
-1
Modified
g4f/providers/retry_provider.py
+2
-2
XFEstudio/gpt4free
Add Gemini provider to Demo
ee9e0c38
代码差异
3 个文件
+5
-4
@@ -1019,7 +1019,7 @@ const ask_gpt = async (message_id, message_index = -1, regenerate = false, provi
1019
1019
}
1020
1020
try {
1021
1021
let api_key;
1022
if (is_demo && ["OpenaiChat", "DeepSeekAPI", "PollinationsAI"].includes(provider)) {
1022
if (is_demo && ["OpenaiChat", "DeepSeekAPI", "PollinationsAI", "Gemini"].includes(provider)) {
1023
1023
api_key = localStorage.getItem("user");
1024
1024
} else if (["HuggingSpace", "G4F"].includes(provider)) {
1025
1025
api_key = localStorage.getItem("HuggingSpace-api_key");
@@ -2043,6 +2043,7 @@ async function on_api() {
2043
2043
<option value="OpenaiChat">OpenAI Provider</option>
2044
2044
<option value="PollinationsAI">Pollinations AI</option>
2045
2045
<option value="G4F">G4F framework</option>
2046
<option value="Gemini">Gemini Provider</option>
2046
2047
<option value="HuggingFace">HuggingFace</option>
2047
2048
<option value="HuggingSpace">HuggingSpace</option>
2048
2049
<option value="HuggingChat">HuggingChat</option>`;
@@ -118,7 +118,7 @@ class Backend_Api(Api):
118
118
else:
119
119
json_data = request.json
120
120
121
if app.demo and json_data.get("provider") not in ["DeepSeekAPI", "OpenaiChat", "HuggingFace", "HuggingSpace", "HuggingChat", "G4F", "PollinationsAI"]:
121
if app.demo and not json_data.get("provider"):
122
122
model = json_data.get("model")
123
123
if model != "default" and model in models.demo_models:
124
124
json_data["provider"] = random.choice(models.demo_models[model][1])
@@ -59,7 +59,7 @@ class IterListProvider(BaseRetryProvider):
59
59
for chunk in response:
60
60
if chunk:
61
61
yield chunk
62
if isinstance(chunk, str) or isinstance(chunk, ImageResponse):
62
if isinstance(chunk, (str, ImageResponse)):
63
63
started = True
64
64
if started:
65
65
return
@@ -94,7 +94,7 @@ class IterListProvider(BaseRetryProvider):
94
94
async for chunk in response:
95
95
if chunk:
96
96
yield chunk
97
if isinstance(chunk, str) or isinstance(chunk, ImageResponse):
97
if isinstance(chunk, (str, ImageResponse)):
98
98
started = True
99
99
elif response:
100
100
response = await response