Fix OpenAI compatibility issues for newer models and Azure config (#727)

Use max_completion_tokens for OpenAI and Azure OpenAI providers:
The OpenAI API deprecated max_tokens in favor of
max_completion_tokens for chat completions. Newer models
(gpt-4o, o1, o3) reject the old parameter with a 400 error.

AZURE_API_VERSION env var now overrides the default API version:
(falls back to 2024-12-01-preview).

Update tests to test for expected structures
This commit is contained in:
cybermaggedon 2026-03-28 11:19:45 +00:00 committed by GitHub
parent a634520509
commit 20204d87c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 14 deletions

View file

@ -201,7 +201,7 @@ class TestTextCompletionStreaming:
call_args = mock_streaming_openai_client.chat.completions.create.call_args
assert call_args.kwargs['model'] == "gpt-4"
assert call_args.kwargs['temperature'] == 0.5
assert call_args.kwargs['max_tokens'] == 2048
assert call_args.kwargs['max_completion_tokens'] == 2048
assert call_args.kwargs['stream'] is True
# Verify chunks have correct model