From 3bbf08a1becd365fa8093f124af0a66647acc544 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:41:16 +0000 Subject: [PATCH 1/2] Initial plan for issue From a3b31625d7131c0bb9f06c34ffff5ec7b02a0990 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:47:43 +0000 Subject: [PATCH 2/2] Fix Azure OpenAI API version for o4-mini model compatibility Co-authored-by: megamanics <10250297+megamanics@users.noreply.github.com> --- util.go | 8 +++++++- util_test.go | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/util.go b/util.go index d634868..05cee9a 100644 --- a/util.go +++ b/util.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/cli/go-gh/v2/pkg/api" "github.com/joho/godotenv" @@ -118,7 +119,12 @@ func getChatCompletionResponse(messages []azopenai.ChatMessage) (string, error) var client *azopenai.Client if strings.Contains(url, "azure") { - client, err = azopenai.NewClientWithKeyCredential(url, keyCredential, nil) + clientOptions := &azopenai.ClientOptions{ + ClientOptions: policy.ClientOptions{ + APIVersion: "2024-12-01-preview", + }, + } + client, err = azopenai.NewClientWithKeyCredential(url, keyCredential, clientOptions) if err != nil { return "", fmt.Errorf("error creating Azure OpenAI client: %v", err) } diff --git a/util_test.go b/util_test.go index ad38973..df2ecc8 100644 --- a/util_test.go +++ b/util_test.go @@ -4,6 +4,7 @@ import ( "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" ) func Test_getGitDiff(t *testing.T) { @@ -188,3 +189,18 @@ func Test_formatResponse(t *testing.T) { }) } } + +func Test_azureClientOptionsSetAPIVersion(t *testing.T) { + // Test that Azure client creation includes proper API version + // This test verifies the fix for o4-mini model compatibility + clientOptions := &azopenai.ClientOptions{ + ClientOptions: policy.ClientOptions{ + APIVersion: "2024-12-01-preview", + }, + } + + // Verify the API version is set correctly + if clientOptions.ClientOptions.APIVersion != "2024-12-01-preview" { + t.Errorf("Expected API version to be '2024-12-01-preview', got '%s'", clientOptions.ClientOptions.APIVersion) + } +}