Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
My tests were too heavily dependent on implementation details of the …
…models. Changing this out to check that things are working correctly without checking the exact contents of the response.

Also, rerecorded tests since we're doing multiple audio tests as well.
  • Loading branch information
Richard Park committed Jan 8, 2024
commit ce246e63715dc186ecd1c790323e6bc77b84d350
2 changes: 1 addition & 1 deletion sdk/ai/azopenai/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/ai/azopenai",
"Tag": "go/ai/azopenai_b42da78821"
"Tag": "go/ai/azopenai_85a01b7ac6"
}
40 changes: 15 additions & 25 deletions sdk/ai/azopenai/client_completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,23 @@ func testGetCompletions(t *testing.T, client *azopenai.Client, isAzure bool) {
skipNowIfThrottled(t, err)
require.NoError(t, err)

want := azopenai.GetCompletionsResponse{
Completions: azopenai.Completions{
Choices: []azopenai.Choice{
{
Text: to.Ptr("\n\nAzure OpenAI is a platform from Microsoft that provides access to OpenAI's artificial intelligence (AI) technologies. It enables developers to build, train, and deploy AI models in the cloud. Azure OpenAI provides access to OpenAI's powerful AI technologies, such as GPT-3, which can be used to create natural language processing (NLP) applications, computer vision models, and reinforcement learning models."),
Index: to.Ptr(int32(0)),
FinishReason: to.Ptr(azopenai.CompletionsFinishReason("stop")),
LogProbs: nil,
},
},
Usage: &azopenai.CompletionsUsage{
CompletionTokens: to.Ptr(int32(85)),
PromptTokens: to.Ptr(int32(6)),
TotalTokens: to.Ptr(int32(91)),
},
},
}
// we'll do a general check here - as models change the answers can also change, token usages are different,
// etc... So we'll just make sure data is coming back and is reasonable.
require.NotZero(t, *resp.Completions.Usage.PromptTokens)
require.NotZero(t, *resp.Completions.Usage.CompletionTokens)
require.NotZero(t, *resp.Completions.Usage.TotalTokens)
require.Equal(t, int32(0), *resp.Completions.Choices[0].Index)
require.Equal(t, azopenai.CompletionsFinishReasonStopped, *resp.Completions.Choices[0].FinishReason)

require.NotEmpty(t, *resp.Completions.Choices[0].Text)

if isAzure {
want.Choices[0].ContentFilterResults = (*azopenai.ContentFilterResultsForChoice)(safeContentFilter)
want.PromptFilterResults = []azopenai.ContentFilterResultsForPrompt{
{PromptIndex: to.Ptr[int32](0), ContentFilterResults: safeContentFilterResultDetailsForPrompt},
}
require.Equal(t, safeContentFilter, resp.Completions.Choices[0].ContentFilterResults)
require.Equal(t, []azopenai.ContentFilterResultsForPrompt{
{
PromptIndex: to.Ptr[int32](0),
ContentFilterResults: safeContentFilterResultDetailsForPrompt,
}}, resp.PromptFilterResults)
}

want.ID = resp.Completions.ID
want.Created = resp.Completions.Created

require.Equal(t, want, resp)
}
4 changes: 2 additions & 2 deletions sdk/ai/azopenai/client_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func initEnvVars() {

openAI.Vision = azureOpenAI.Vision

azureOpenAI.Completions = "text-davinci-003"
openAI.Completions = "text-davinci-003"
azureOpenAI.Completions = "gpt-35-turbo"
openAI.Completions = "gpt-35-turbo"

azureOpenAI.ChatCompletions = "gpt-35-turbo-0613"
azureOpenAI.ChatCompletionsLegacyFunctions = "gpt-4-0613"
Expand Down
3 changes: 1 addition & 2 deletions sdk/ai/azopenai/custom_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ func testGetCompletionsStream(t *testing.T, client *azopenai.Client, tv testVars
}
}
got := sb.String()
const want = "\n\nAzure OpenAI is a platform from Microsoft that provides access to OpenAI's artificial intelligence (AI) technologies. It enables developers to build, train, and deploy AI models in the cloud. Azure OpenAI provides access to OpenAI's powerful AI technologies, such as GPT-3, which can be used to create natural language processing (NLP) applications, computer vision models, and reinforcement learning models."

require.Equal(t, want, got)
require.NotEmpty(t, got)

// there's no strict requirement of how the response is streamed so just
// choosing something that's reasonable but will be lower than typical usage
Expand Down