Check for exception in generate of G4F

This commit is contained in:
hlohaus
2025-02-05 19:30:47 +01:00
parent cbd663511c
commit fb58feae87
2 changed files with 7 additions and 8 deletions

View File

@@ -83,14 +83,11 @@ class G4F(Janus_Pro_7B):
"x-zerogpu-uuid": zerogpu_uuid,
}
async def generate():
try:
async with session.post(cls.url_flux, json=payload, proxy=proxy, headers=headers) as response:
await raise_for_status(response)
response_data = await response.json()
image_url = response_data["data"][0]['url']
return ImageResponse(images=[image_url], alt=prompt)
except Exception as e:
return Reasoning(status=f"Error: {e.__class__.__name__}: {e}")
background_tasks = set()
started = time.time()
task = asyncio.create_task(generate())

View File

@@ -147,6 +147,8 @@ class Backend_Api(Api):
limiter_check()
if "images" in json_data:
kwargs["images"] = json_data["images"]
if "zerogpu_token" in json_data:
kwargs["zerogpu_token"] = json_data["zerogpu_token"]
kwargs = self._prepare_conversation_kwargs(json_data, kwargs)
return self.app.response_class(
self._create_response_stream(