File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -381,3 +381,43 @@ func main() {
381
381
}
382
382
```
383
383
</details >
384
+
385
+ <details >
386
+ <summary >Azure OpenAI ChatGPT</summary >
387
+
388
+ ``` go
389
+ package main
390
+
391
+ import (
392
+ " context"
393
+ " fmt"
394
+
395
+ openai " github.com/sashabaranov/go-openai"
396
+ )
397
+
398
+ func main () {
399
+
400
+ config := openai.DefaultAzureConfig (" your Azure OpenAI Key" , " https://your Azure OpenAI Endpoint " , " your Model deployment name" )
401
+ client := openai.NewClientWithConfig (config)
402
+ resp , err := client.CreateChatCompletion (
403
+ context.Background (),
404
+ openai.ChatCompletionRequest {
405
+ Model: openai.GPT3Dot5Turbo ,
406
+ Messages: []openai.ChatCompletionMessage {
407
+ {
408
+ Role: openai.ChatMessageRoleUser ,
409
+ Content: " Hello Azure OpenAI!" ,
410
+ },
411
+ },
412
+ },
413
+ )
414
+
415
+ if err != nil {
416
+ fmt.Printf (" ChatCompletion error: %v \n " , err)
417
+ return
418
+ }
419
+
420
+ fmt.Println (resp.Choices [0 ].Message .Content )
421
+ }
422
+ ```
423
+ </details >
You can’t perform that action at this time.
0 commit comments