Merge pull request #69 from presenton/fix/issues

fix(fastapi): makes google image gen async
This commit is contained in:
Saurav Niraula 2025-07-10 20:31:57 +05:45 committed by GitHub
commit b4e082eef9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -149,7 +149,12 @@ class PresentationGenerateStreamHandler(FetchAssetsOnPresentationGenerationMixin
)
):
chunk = event.choices[0].delta.content
if chunk is None:
continue
presentation_text += chunk
yield SSEResponse(
event="response",
data=json.dumps({"type": "chunk", "chunk": chunk}),

View file

@ -52,8 +52,7 @@ async def generate_image(
async def generate_image_openai(prompt: str, output_directory: str) -> str:
client = get_llm_client()
result = await asyncio.to_thread(
client.images.generate,
result = await client.images.generate(
model="dall-e-3",
prompt=prompt,
n=1,
@ -72,7 +71,8 @@ async def generate_image_openai(prompt: str, output_directory: str) -> str:
async def generate_image_google(prompt: str, output_directory: str) -> str:
client = genai.Client()
response = client.models.generate_content(
response = await asyncio.to_thread(
client.models.generate_content,
model="gemini-2.0-flash-preview-image-generation",
contents=[prompt],
config=GenerateContentConfig(response_modalities=["TEXT", "IMAGE"]),