From a98b9d83f017fe890d280e7a783037e97adebaa7 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Sun, 3 Dec 2023 14:45:39 -0500 Subject: [PATCH] close OpenAI client --- backend/image_generation.py | 1 + backend/llm.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/backend/image_generation.py b/backend/image_generation.py index ad21772..bb272f8 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 fdb1ba0..e2b41c4 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