CLI ChatBot Power By Gpt3(speed)
源代码
bilibili 在线吹水
⚽️⚽️基于gpt3引擎实现CLI版本的chatgpt~⚽️⚽️
Features
- Gpt3 ChatBot
- Store Keyring
- Cobra CLI
development
make build
go-chat key set
go-chat run
Snapshot
- 调用gpt3接口
func GetAnswer(question string) {
fmt.Print("Answer: ")
i := 0
ctx := context.Background()
if err := client.CompletionStreamWithEngine(ctx, engine, gpt3.CompletionRequest{
Prompt: []string{
question,
},
MaxTokens: gpt3.IntPtr(maxTokens),
Temperature: gpt3.Float32Ptr(temperature),
}, func(resp *gpt3.CompletionResponse) {
if i > 1 {
fmt.Print(resp.Choices[0].Text)
}
i++
}); err != nil {
log.Fatalln(err)
}
fmt.Println()
}
- cobra项目结构
├── LICENSE
├── Makefile
├── cmd
│ ├── key.go
│ ├── root.go
│ └── run.go
├── go-chat
├── go.mod
├── go.sum
├── main.go
├── readme.md
└── services
├── browse.go
├── cli.go
├── gpt.go
└── key.go