fix: conditional to_thread for the image_transform to relieve threadpool pressure

This commit is contained in:
Alpha Nerd 2026-04-07 13:28:34 +02:00
parent 81013ec3b1
commit 2c87472483
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M

View file

@ -1059,7 +1059,8 @@ async def _make_chat_request(model: str, messages: list, tools=None, stream: boo
if ":latest" in model: if ":latest" in model:
model = model.split(":latest")[0] model = model.split(":latest")[0]
if messages: if messages:
messages = await asyncio.to_thread(transform_images_to_data_urls, messages) if any("images" in m for m in messages):
messages = await asyncio.to_thread(transform_images_to_data_urls, messages)
messages = transform_tool_calls_to_openai(messages) messages = transform_tool_calls_to_openai(messages)
messages = _strip_assistant_prefill(messages) messages = _strip_assistant_prefill(messages)
params = { params = {
@ -1965,7 +1966,8 @@ async def chat_proxy(request: Request):
model = model.split(":latest") model = model.split(":latest")
model = model[0] model = model[0]
if messages: if messages:
messages = await asyncio.to_thread(transform_images_to_data_urls, messages) if any("images" in m for m in messages):
messages = await asyncio.to_thread(transform_images_to_data_urls, messages)
messages = transform_tool_calls_to_openai(messages) messages = transform_tool_calls_to_openai(messages)
messages = _strip_assistant_prefill(messages) messages = _strip_assistant_prefill(messages)
params = { params = {