fix: use max_completion_tokens instead of deprecated max_tokens

The OpenAI API deprecated `max_tokens` in favor of `max_completion_tokens`
for chat completion endpoints. Newer models (gpt-4o, o1, o3, gpt-5.x)
reject `max_tokens` with:

  "Unsupported parameter: 'max_tokens' is not supported with this model.
   Use 'max_completion_tokens' instead."

This updates both the OpenAI and Azure OpenAI text completion providers
to use the new parameter name.

Fixes both streaming and non-streaming code paths.
This commit is contained in:
Azizultra32 2026-03-24 16:24:55 -07:00
parent d30857b5c3
commit 2f23efc269
2 changed files with 4 additions and 4 deletions

View file

@ -90,7 +90,7 @@ class Processor(LlmService):
}
],
temperature=effective_temperature,
max_tokens=self.max_output,
max_completion_tokens=self.max_output,
top_p=1,
)
@ -159,7 +159,7 @@ class Processor(LlmService):
}
],
temperature=effective_temperature,
max_tokens=self.max_output,
max_completion_tokens=self.max_output,
top_p=1,
stream=True,
stream_options={"include_usage": True}

View file

@ -86,7 +86,7 @@ class Processor(LlmService):
}
],
temperature=effective_temperature,
max_tokens=self.max_output,
max_completion_tokens=self.max_output,
)
inputtokens = resp.usage.prompt_tokens
@ -152,7 +152,7 @@ class Processor(LlmService):
}
],
temperature=effective_temperature,
max_tokens=self.max_output,
max_completion_tokens=self.max_output,
stream=True,
stream_options={"include_usage": True}
)