Skip to content

Commit

Permalink
Update README.md with Azure OpenAI ChatGPT example (sashabaranov#239)
Browse files Browse the repository at this point in the history
Co-authored-by: coggsflod <richard.coggins@officedepot.com>
  • Loading branch information
coggsfl and coggsflod authored Apr 8, 2023
1 parent 33ca1da commit 334ee6d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,43 @@ func main() {
}
```
</details>

<details>
<summary>Azure OpenAI ChatGPT</summary>

```go
package main

import (
"context"
"fmt"

openai "github.com/sashabaranov/go-openai"
)

func main() {

config := openai.DefaultAzureConfig("your Azure OpenAI Key", "https://your Azure OpenAI Endpoint ", "your Model deployment name")
client := openai.NewClientWithConfig(config)
resp, err := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: openai.GPT3Dot5Turbo,
Messages: []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleUser,
Content: "Hello Azure OpenAI!",
},
},
},
)

if err != nil {
fmt.Printf("ChatCompletion error: %v\n", err)
return
}

fmt.Println(resp.Choices[0].Message.Content)
}
```
</details>

0 comments on commit 334ee6d

Please sign in to comment.