Skip to content

Commit 674104f

Browse files
Copilotmegamanics
andauthored
Fix Azure OpenAI API version for o4-mini model compatibility (#24)
* Initial plan for issue * Fix Azure OpenAI API version for o4-mini model compatibility Co-authored-by: megamanics <10250297+megamanics@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: megamanics <10250297+megamanics@users.noreply.github.com>
1 parent f06a222 commit 674104f

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

util.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai"
7+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
78
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
89
"github.com/cli/go-gh/v2/pkg/api"
910
"github.com/joho/godotenv"
@@ -118,7 +119,12 @@ func getChatCompletionResponse(messages []azopenai.ChatMessage) (string, error)
118119
var client *azopenai.Client
119120

120121
if strings.Contains(url, "azure") {
121-
client, err = azopenai.NewClientWithKeyCredential(url, keyCredential, nil)
122+
clientOptions := &azopenai.ClientOptions{
123+
ClientOptions: policy.ClientOptions{
124+
APIVersion: "2024-12-01-preview",
125+
},
126+
}
127+
client, err = azopenai.NewClientWithKeyCredential(url, keyCredential, clientOptions)
122128
if err != nil {
123129
return "", fmt.Errorf("error creating Azure OpenAI client: %v", err)
124130
}

util_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"reflect"
55
"testing"
66
"github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai"
7+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
78
)
89

910
func Test_getGitDiff(t *testing.T) {
@@ -188,3 +189,18 @@ func Test_formatResponse(t *testing.T) {
188189
})
189190
}
190191
}
192+
193+
func Test_azureClientOptionsSetAPIVersion(t *testing.T) {
194+
// Test that Azure client creation includes proper API version
195+
// This test verifies the fix for o4-mini model compatibility
196+
clientOptions := &azopenai.ClientOptions{
197+
ClientOptions: policy.ClientOptions{
198+
APIVersion: "2024-12-01-preview",
199+
},
200+
}
201+
202+
// Verify the API version is set correctly
203+
if clientOptions.ClientOptions.APIVersion != "2024-12-01-preview" {
204+
t.Errorf("Expected API version to be '2024-12-01-preview', got '%s'", clientOptions.ClientOptions.APIVersion)
205+
}
206+
}

0 commit comments

Comments
 (0)