Skip to content

Commit 9eb9a1f

Browse files
authored
Merge pull request #120852 from qt-luigi/patch-1
Update code to sdk 0.5.0
2 parents 453b142 + a4ac2ca commit 9eb9a1f

File tree

1 file changed

+6
-9
lines changed
  • articles/ai-services/openai/includes

1 file changed

+6
-9
lines changed

articles/ai-services/openai/includes/go.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"os"
3939

4040
"github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai"
41+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
4142
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
4243
)
4344

@@ -52,11 +53,7 @@ func main() {
5253
return
5354
}
5455

55-
keyCredential, err := azopenai.NewKeyCredential(azureOpenAIKey)
56-
57-
if err != nil {
58-
// TODO: handle error
59-
}
56+
keyCredential := azcore.NewKeyCredential(azureOpenAIKey)
6057

6158
client, err := azopenai.NewClientWithKeyCredential(azureOpenAIEndpoint, keyCredential, nil)
6259

@@ -65,10 +62,10 @@ func main() {
6562
}
6663

6764
resp, err := client.GetCompletions(context.TODO(), azopenai.CompletionsOptions{
68-
Prompt: []string{"What is Azure OpenAI, in 20 words or less"},
69-
MaxTokens: to.Ptr(int32(2048)),
70-
Temperature: to.Ptr(float32(0.0)),
71-
Deployment: modelDeploymentID,
65+
Prompt: []string{"What is Azure OpenAI, in 20 words or less"},
66+
MaxTokens: to.Ptr(int32(2048)),
67+
Temperature: to.Ptr(float32(0.0)),
68+
DeploymentName: &modelDeploymentID,
7269
}, nil)
7370

7471
if err != nil {

0 commit comments

Comments
 (0)