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