Merge pull request #1548 from maharjun/use_openai_context_manager

Use Openai Client Context Manager
This commit is contained in:
Daniel.y
2025-05-09 14:33:48 +08:00
committed by GitHub

View File

@@ -177,6 +177,7 @@ async def openai_complete_if_cache(
logger.debug("===== Sending Query to LLM =====")
try:
async with openai_async_client:
if "response_format" in kwargs:
response = await openai_async_client.beta.chat.completions.parse(
model=model, messages=messages, **kwargs
@@ -421,6 +422,7 @@ async def openai_embed(
api_key=api_key, base_url=base_url, client_configs=client_configs
)
async with openai_async_client:
response = await openai_async_client.embeddings.create(
model=model, input=texts, encoding_format="float"
)