Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

close OpenAI client

Abi Rajaa98b9d83f017
diff --git a/backend/image_generation.py b/backend/image_generation.py
index ad217720..bb272f8d 100644
--- a/backend/image_generation.py
+++ b/backend/image_generation.py
@@ -31,6 +31,7 @@ async def generate_image(prompt, api_key, base_url):
"prompt": prompt,
}
res = await client.images.generate(**image_params)
+ await client.close()
return res.data[0].url
diff --git a/backend/llm.py b/backend/llm.py
index fdb1ba07..e2b41c4f 100644
--- a/backend/llm.py
+++ b/backend/llm.py
@@ -30,4 +30,6 @@ async def stream_openai_response(
full_response += content
await callback(content)
+ await client.close()
+
return full_response