Skip to content

Commit a4ac2ca

Browse files
authored
Update code to sdk 0.5.0
Update code to azure-sdk-for-go/sdk/ai/azopenai 0.5.0
1 parent 8c9c03e commit a4ac2ca

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
@@ -40,6 +40,7 @@ import (
4040
"os"
4141

4242
"github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai"
43+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
4344
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
4445
)
4546

@@ -54,11 +55,7 @@ func main() {
5455
return
5556
}
5657

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

6360
client, err := azopenai.NewClientWithKeyCredential(azureOpenAIEndpoint, keyCredential, nil)
6461

@@ -67,10 +64,10 @@ func main() {
6764
}
6865

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

7673
if err != nil {

0 commit comments

Comments
 (0)