fix: use MaxCompletionTokens instead of deprecated MaxTokens for OpenAI (#1604)
Some checks failed
Build container / Prepare CI Run (push) Has been cancelled
release / release-please (push) Has been cancelled
Run tests / build (push) Has been cancelled
Build container / Build and Push Multi-arch Image (push) Has been cancelled
release / goreleaser (push) Has been cancelled
release / build-container (push) Has been cancelled

The OpenAI API deprecated 'max_tokens' parameter in favor of
'max_completion_tokens' for newer models (o1, gpt-4o, etc.).

This change fixes the error:
'Unsupported parameter: max_tokens is not supported with this model.
Use max_completion_tokens instead.'

Refs: https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens

Signed-off-by: Evgenii Kuzakov <evgeniy.kuzakov@csssr.com>
Co-authored-by: Evgenii Kuzakov <evgeniy.kuzakov@csssr.com>
This commit is contained in:
kk573
2026-01-27 20:46:51 +03:00
committed by GitHub
parent 867bce1907
commit c80b2e2c34

View File

@@ -95,7 +95,7 @@ func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string) (string
},
},
Temperature: c.temperature,
MaxTokens: maxToken,
MaxCompletionTokens: maxToken,
PresencePenalty: presencePenalty,
FrequencyPenalty: frequencyPenalty,
TopP: c.topP,