File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed
Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Package openai provides a Go SDK for the OpenAI API.this package supports severa
33models. You can specify the desired model using the ` Model ` field in the request object.
44
55
6- ## Support API
6+ ## Feature
77
88- ChatGPT (GPT-3, GPT-3.5, GPT-4)
99- DALL·E 2
@@ -12,6 +12,7 @@ models. You can specify the desired model using the `Model` field in the request
1212- Fine-Tune
1313- File
1414- Moderations
15+ - Completion Patterns
1516
1617## Install ![ Go Version] ( https://img.shields.io/badge/go%20version-%3E=1.19-61CFDD.svg?style=flat-square )
1718
@@ -55,6 +56,47 @@ func main() {
5556
5657```
5758
59+ Example Completion Patterns
60+
61+ ``` go
62+ package main
63+
64+ import (
65+ " context"
66+ " github.com/GoFarsi/openai"
67+ " github.com/GoFarsi/openai/client"
68+ " github.com/GoFarsi/openai/utils"
69+ " log"
70+ )
71+
72+ var code string = `
73+ func add(a, b int) int {
74+ return a + b
75+ }
76+ `
77+
78+ func main () {
79+ cli , err := client.New (os.Getenv (" OPENAI_API_KEY" ))
80+ if err != nil {
81+ log.Fatalln (err)
82+ }
83+
84+ c := openai.NewCompletion (cli)
85+ resp , err := c.CreateCompletionFromPattern (context.Background (), openai.ProgrammingLanguageTranslator (
86+ code,
87+ utils.Go ,
88+ utils.Python ,
89+ ))
90+
91+ if err != nil {
92+ log.Fatalln (err)
93+ }
94+
95+ log.Println (resp.Choices [0 ].Text )
96+ }
97+
98+ ```
99+
58100See more details in [ documentation] ( https://pkg.go.dev/github.com/GoFarsi/openai ) .
59101
60102## TODO
You can’t perform that action at this time.
0 commit comments