From 57acc2b68f2f9e40b53aa7e609fdd52a4b0d15c4 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 6 Sep 2026 23:23:59 -0400 Subject: [PATCH] refac --- backend/open_webui/routers/openai.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index 5e5c0c4bc4..7e25b30f70 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -1569,6 +1569,20 @@ async def generate_chat_completion( is_responses = api_config.get('api_type') == 'responses' + # Explicit continuation keeps llama.cpp from echoing the prefill in streamed replies. + if ( + api_config.get('provider') == 'llama.cpp' + # These flags apply to Chat Completions, not the Responses API. + and not is_responses + # The frontend sends this ID when the user clicks Continue. + and (metadata or {}).get('assistant_message_id') + # Tool follow-ups retain the metadata but must start a new assistant turn. + and payload.get('messages') + and payload['messages'][-1].get('role') == 'assistant' + ): + payload['continue_final_message'] = True + payload['add_generation_prompt'] = False + if api_config.get('azure') or api_config.get('provider') == 'azure': # Only set api-key header if not using Azure Entra ID authentication auth_type = api_config.get('auth_type', 'bearer')