mirror of
https://github.com/xtekky/gpt4free.git
synced 2026-04-22 15:47:11 +08:00
fix: Simplify API key check and ensure conversation messages are added only for text responses
This commit is contained in:
@@ -381,7 +381,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
return f"{url}&seed={seed}" if seed else url
|
||||
|
||||
headers = None
|
||||
if api_key and (api_key.startswith("g4f_") or api_key.startswith("gfs_")):
|
||||
if api_key:
|
||||
headers = {"authorization": f"Bearer {api_key}"}
|
||||
async with ClientSession(
|
||||
headers=DEFAULT_HEADERS,
|
||||
|
||||
+3
-2
@@ -152,14 +152,15 @@ async def stream_response(
|
||||
print(f"\n→ Response saved to '{output_file}'")
|
||||
|
||||
if text_response:
|
||||
conversation.add_message("assistant", text_response)
|
||||
if not media_chunk:
|
||||
conversation.add_message("assistant", text_response)
|
||||
else:
|
||||
raise RuntimeError("No response received")
|
||||
|
||||
|
||||
def save_content(content, media: Optional[MediaResponse], filepath: str, allowed_types=None) -> bool:
|
||||
if media:
|
||||
for url in media.urls:
|
||||
for url in media.get_list():
|
||||
if url.startswith(("http://", "https://")):
|
||||
try:
|
||||
resp = requests.get(url, cookies=media.get("cookies"), headers=media.get("headers"))
|
||||
|
||||
Reference in New Issue
Block a user