返回提交历史
Modified
g4f/Provider/PollinationsAI.py
+1
-1
Modified
g4f/cli/client.py
+3
-2
XFEstudio/gpt4free
fix: Simplify API key check and ensure conversation messages are added only for text responses
287d89a1
代码差异
2 个文件
+4
-3
@@ -381,7 +381,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
381
381
return f"{url}&seed={seed}" if seed else url
382
382
383
383
headers = None
384
if api_key and (api_key.startswith("g4f_") or api_key.startswith("gfs_")):
384
if api_key:
385
385
headers = {"authorization": f"Bearer {api_key}"}
386
386
async with ClientSession(
387
387
headers=DEFAULT_HEADERS,
@@ -152,14 +152,15 @@ async def stream_response(
152
152
print(f"\n→ Response saved to '{output_file}'")
153
153
154
154
if text_response:
155
conversation.add_message("assistant", text_response)
155
if not media_chunk:
156
conversation.add_message("assistant", text_response)
156
157
else:
157
158
raise RuntimeError("No response received")
158
159
159
160
160
161
def save_content(content, media: Optional[MediaResponse], filepath: str, allowed_types=None) -> bool:
161
162
if media:
162
for url in media.urls:
163
for url in media.get_list():
163
164
if url.startswith(("http://", "https://")):
164
165
try:
165
166
resp = requests.get(url, cookies=media.get("cookies"), headers=media.get("headers"))