fix(chat): exclude ChatTemplateKwargs for OpenAI API

ChatTemplateKwargs parameter is only supported by custom backends
like vLLM. OpenAI API does not support this parameter and returns
400 Bad Request error.

This change conditionally includes ChatTemplateKwargs only when
the provider is ProviderGeneric (custom deployment).

Fixes connection test failure for OpenAI models with error:
"Unrecognized request argument supplied: chat_template_kwargs"
main
JAESOL SHIN 2025-12-29 19:47:16 +09:00 committed by lyingbug
parent 002f1c40fa
commit ddf5ae4e65
1 changed files with 7 additions and 2 deletions

View File

@ -204,8 +204,13 @@ func (c *RemoteAPIChat) buildChatCompletionRequest(messages []Message,
}
}
req.ChatTemplateKwargs = map[string]interface{}{
"enable_thinking": thinking,
// ChatTemplateKwargs is only supported by custom backends like vLLM.
// Official APIs (OpenAI, Aliyun, Zhipu, etc.) do not support this parameter
// and will return 400 Bad Request if it's included.
if c.provider == provider.ProviderGeneric {
req.ChatTemplateKwargs = map[string]interface{}{
"enable_thinking": thinking,
}
}
// Log LLM request for debugging