mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 10:40:43 -08:00
Fix using ImageResponse
This commit is contained in:
parent
7a75782af3
commit
6a4dc74b9e
10 changed files with 10 additions and 10 deletions
|
|
@ -187,7 +187,7 @@ class ARTA(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
image_urls = [image["url"] for image in status_data.get("response", [])]
|
||||
duration = time.time() - start_time
|
||||
yield Reasoning(label="Generated", status=f"{n} image(s) in {duration:.2f}s")
|
||||
yield ImageResponse(images=image_urls, alt=prompt)
|
||||
yield ImageResponse(urls=image_urls, alt=prompt)
|
||||
return
|
||||
elif status in ("IN_QUEUE", "IN_PROGRESS"):
|
||||
if last_status != status:
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
image_url_match = re.search(r'!\[.*?\]\((.*?)\)', full_response_text)
|
||||
if image_url_match:
|
||||
image_url = image_url_match.group(1)
|
||||
yield ImageResponse(images=[image_url], alt=format_image_prompt(messages, prompt))
|
||||
yield ImageResponse(urls=[image_url], alt=format_image_prompt(messages, prompt))
|
||||
return
|
||||
|
||||
# Handle conversation history once, in one place
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class ImageLabs(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
if progress_data.get('status') == 'Done' or progress_data.get('final_image_url'):
|
||||
# Yield ImageResponse with the final image URL
|
||||
yield ImageResponse(
|
||||
images=[progress_data.get('final_image_url')],
|
||||
urls=[progress_data.get('final_image_url')],
|
||||
alt=prompt
|
||||
)
|
||||
break
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class Websim(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
response_json = json.loads(response_text)
|
||||
image_url = response_json.get("url")
|
||||
if image_url:
|
||||
yield ImageResponse(images=[image_url], alt=used_prompt)
|
||||
yield ImageResponse(urls=[image_url], alt=used_prompt)
|
||||
|
||||
@classmethod
|
||||
async def _handle_chat_request(
|
||||
|
|
|
|||
|
|
@ -71,5 +71,5 @@ class Voodoohop_Flux1Schnell(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
elif event_type == b'complete':
|
||||
json_data = json.loads(data)
|
||||
image_url = json_data[0]['url']
|
||||
yield ImageResponse(images=[image_url], alt=prompt)
|
||||
yield ImageResponse(urls=[image_url], alt=prompt)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ class Grok(AsyncAuthedProvider, ProviderModelMixin):
|
|||
model: str,
|
||||
messages: Messages,
|
||||
auth_result: AuthResult,
|
||||
cookies: Cookies = None,
|
||||
return_conversation: bool = False,
|
||||
conversation: Conversation = None,
|
||||
**kwargs
|
||||
|
|
@ -130,7 +129,7 @@ class Grok(AsyncAuthedProvider, ProviderModelMixin):
|
|||
yield token
|
||||
generated_images = response_data.get("modelResponse", {}).get("generatedImageUrls", None)
|
||||
if generated_images:
|
||||
yield ImageResponse([f'{cls.assets_url}/{image}' for image in generated_images], "", {"cookies": cookies, "headers": headers})
|
||||
yield ImageResponse([f'{cls.assets_url}/{image}' for image in generated_images], "", {"cookies": auth_result.cookies, "headers": auth_result.headers})
|
||||
title = result.get("title", {}).get("newTitle", "")
|
||||
if title:
|
||||
yield TitleGeneration(title)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class AiChats(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
|
||||
base64_image = base64.b64encode(image_data).decode('utf-8')
|
||||
base64_url = f"data:image/png;base64,{base64_image}"
|
||||
yield ImageResponse(base64_url, prompt)
|
||||
yield ImageResponse(image_url, prompt)
|
||||
else:
|
||||
yield f"Error: No image URL found in the response. Full response: {response_json}"
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class Airforce(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
async with session.get(cls.api_endpoint_imagine2, params=params, proxy=proxy) as response:
|
||||
if response.status == 200:
|
||||
image_url = str(response.url)
|
||||
yield ImageResponse(images=image_url, alt=prompt)
|
||||
yield ImageResponse(urls=image_url, alt=prompt)
|
||||
else:
|
||||
error_text = await response.text()
|
||||
raise RuntimeError(f"Image generation failed: {response.status} - {error_text}")
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def get_cookies(domain_name: str, raise_requirements_error: bool = True, single_
|
|||
Returns:
|
||||
Dict[str, str]: A dictionary of cookie names and values.
|
||||
"""
|
||||
if cache_result and domain_name in CookiesConfig.cookies:
|
||||
if domain_name in CookiesConfig.cookies:
|
||||
return CookiesConfig.cookies[domain_name]
|
||||
|
||||
cookies = load_cookies_from_browsers(domain_name, raise_requirements_error, single_browser)
|
||||
|
|
|
|||
|
|
@ -1316,6 +1316,7 @@ form textarea {
|
|||
|
||||
.field a {
|
||||
text-wrap: nowrap;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.field .fa-xmark {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue