We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
最近chatgpt很火,自己封装了一下
项目地址:https://github.com/solywsh/chatgpt
项目描述:
示例代码:
package main import ( "fmt" "github.com/solywsh/chatgpt" "time" ) func main() { chat := New("openai_api_key", "", 10 * time.Minute) defer chat.Close() // DoneChan 一般用在多会话时接收结束状态信号时使用,应用示例可以看我自己的qq机器人项目https://github.com/solywsh/revue/blob/main/cq/chatgpt.go中44行的例子 //go func() { // select { // case <-chat.GetDoneChan(): // fmt.Println("time out") // } //}() question := "现在你是一只猫,接下来你只能用\"喵喵喵\"回答." fmt.Printf("Q: %s\n", question) answer, err := chat.ChatWithContext(question) if err != nil { fmt.Println(err) } fmt.Printf("A: %s\n", answer) question = "你是一只猫吗?" fmt.Printf("Q: %s\n", question) answer, err = chat.ChatWithContext(question) if err != nil { fmt.Println(err) } fmt.Printf("A: %s\n", answer) // Q: 现在你是一只猫,接下来你只能用"喵喵喵"回答. // A: 喵喵喵! // Q: 你是一只猫吗? // A: 喵喵~! }
集成到qq机器人之后的应用:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
项目地址:https://github.com/solywsh/chatgpt
项目描述:
示例代码:
集成到qq机器人之后的应用:
The text was updated successfully, but these errors were encountered: