🌐
Go Packages
pkg.go.dev › github.com › ayush6624 › go-chatgpt
chatgpt package - github.com/ayush6624/go-chatgpt - Go Packages
ctx := context.Background() res, err = c.Send(ctx, &chatgpt.ChatCompletionRequest{ Model: chatgpt.GPT35Turbo, Messages: []chatgpt.ChatMessage{ { Role: chatgpt.ChatGPTModelRoleSystem, Content: "Hey, Explain GoLang to me in 2 sentences.", }, }, }) if err != nil { // handle error }
🌐
GitHub
github.com › sashabaranov › go-openai
GitHub - sashabaranov/go-openai: OpenAI ChatGPT, GPT-5, GPT-Image-1, Whisper API clients for Go
Guide the user through the solution step by step.", }, { Role: openai.ChatMessageRoleUser, Content: "how can I solve 8x + 7 = -23", }, }, ResponseFormat: &openai.ChatCompletionResponseFormat{ Type: openai.ChatCompletionResponseFormatTypeJSONSchema, JSONSchema: &openai.ChatCompletionResponseFormatJSONSchema{ Name: "math_reasoning", Schema: schema, Strict: true, }, }, }) if err != nil { log.Fatalf("CreateChatCompletion error: %v", err) } err = schema.Unmarshal(resp.Choices[0].Message.Content, &result) if err != nil { log.Fatalf("Unmarshal schema error: %v", err) } fmt.Println(result) } See the `examples/` folder for more.
Starred by 10.5K users
Forked by 1.7K users
Languages   Go
🌐
Rollbar
rollbar.com › home › how to use the chatgpt api with golang
How to Use the ChatGPT API with Golang | Rollbar
August 18, 2023 - This guide will take you step-by-step on how to bring together the text-generating wizardry of ChatGPT with the simplicity and efficiency of Golang, opening up exciting new possibilities for crafting more intelligent applications.
🌐
ChatGPT
chatgpt.com › g › g-bcOg2GHrh-go-golang
ChatGPT - Go Golang
ChatGPT is your AI chatbot for everyday use. Chat with the most advanced AI to explore ideas, solve problems, and learn faster.
🌐
Medium
medium.com › aimonks › implementing-chatgpt-api-using-golang-a-step-by-step-guide-cbb2f8a3c8d7
Implementing ChatGPT API Using Golang: A Step-by-Step Guide | by Sumair Zafar | 𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨 | Medium
May 11, 2023 - ChatGPT, powered by the GPT-3.5 architecture, is a powerful language model that can understand and generate human-like text. In this article, we will explore how to implement the ChatGPT API using the Go programming language. We will provide step-by-step instructions along with code examples to help you get started.
🌐
GitHub
github.com › ayush6624 › go-chatgpt
GitHub - ayush6624/go-chatgpt: Open-source GoLang client for ChatGPT
ctx := context.Background() res, err = c.Send(ctx, &chatgpt.ChatCompletionRequest{ Model: chatgpt.GPT35Turbo, Messages: []chatgpt.ChatMessage{ { Role: chatgpt.ChatGPTModelRoleSystem, Content: "Hey, Explain GoLang to me in 2 sentences.", }, }, ...
Starred by 28 users
Forked by 13 users
Languages   Go
🌐
YouTube
youtube.com › watch
Go and OpenAI: A Beginner’s Guide to Building AI-Powered Apps - YouTube
#golang #chatgpt #openai #chatgptapi #ai #golangapiIn this tutorial we're going to create a Golang service that communicates with Chat GPT API. After watchin...
Published   April 12, 2024
🌐
Better Programming
betterprogramming.pub › chatgpt-golang-a7bd524e7563
Consume OpenAI (ChatGPT) With Golang | by Francisco Escher | Better ...
September 11, 2023 - Consume OpenAI (ChatGPT) With Golang My Go client library for the OpenAI API Introduction Open AI exposes an API that is quite simple to use. It requires its clients to register an API Key with an …
Find elsewhere
🌐
GitHub
github.com › kkdai › chatgpt
GitHub - kkdai/chatgpt: ChatGPT Console client in Golang
A Golang console client for ChatGPT (https://chat.openai.com) using GPT
Starred by 247 users
Forked by 44 users
Languages   Go
🌐
DEV Community
dev.to › ernesto27 › create-a-golang-cli-using-openai-chatgpt-api-4hid
Create a golang cli using openAI-chatgpt API - DEV Community
March 5, 2023 - In this tutorial we are going to create a simple golang command line program that uses the openAI API to recreate a similar funcionality of the chatgpt web.
🌐
Traefik
tech.aufomm.com › how-i-use-chatgpt-to-write-a-program-in-golang
How I Use chatGPT to Write a Program in Golang
May 15, 2023 - Besides the fact that Golang is much faster (expected), chatGPT can also integrate third party library to satisfy my needs for example printing data in a table.
🌐
Go Packages
pkg.go.dev › github.com › solywsh › chatgpt
chatgpt package - github.com/solywsh/chatgpt - Go Packages
chat := chatgpt.New("openai_key", "user_id(not required)", 30*time.Second) defer chat.Close() // //select { //case <-chat.GetDoneChan(): // fmt.Println("time out/finish") //} question := "你认为2022年世界杯的冠军是谁?" fmt.Printf("Q: %s\n", question) answer, err := chat.Chat(question) ...
🌐
GitHub
github.com › chatgp › chatgpt-go
GitHub - all-in-aigc/chatgpt-webapi: chatgpt go sdk
package main import ( "log" "net/http" "time" chatgpt "github.com/chatgp/chatgpt-go" ) func main() { token := `copy-from-cookies` cfValue := "copy-from-cookies" puid := "copy-from-cookies" cookies := []*http.Cookie{ { Name: "__Secure-next-auth.session-token", Value: token, }, { Name: "cf_clearance", Value: cfValue, }, { Name: "_puid", Value: puid, }, } cli := chatgpt.NewClient( chatgpt.WithDebug(true), chatgpt.WithTimeout(60*time.Second), chatgpt.WithCookies(cookies), ) // chat in independent conversation message := "say hello to me" text, err := cli.GetChatText(message) if err != nil { log.Fatalf("get chat text failed: %v", err) } log.Printf("q: %s, a: %s\n", message, text.Content) }
Starred by 159 users
Forked by 25 users
Languages   Go
🌐
Go Packages
pkg.go.dev › github.com › golang-infrastructure › go-ChatGPT
chatgpt package - github.com/golang-infrastructure/go-ChatGPT - Go Packages
package main import ( "fmt" chatgpt "github.com/golang-infrastructure/go-ChatGPT" ) func main() { // 把JWT放到这里 jwt := "xxx" chat := chatgpt.NewChatGPT(jwt) talk, err := chat.Talk("你好,我的名字叫陈二!") if err != nil { fmt.Println(err.Error()) return } fmt.Println(talk.Message.Content) talk, err = chat.Talk("我的名字叫什么呀?") if err != nil { fmt.Println(err.Error()) return } fmt.Println(talk.Message.Content) // Output: // {text [你好,陈二!很高兴认识你。我是 Assistant,一个大型语言模型,旨在帮助人们了解更多关于世界的信
🌐
GitHub
github.com › emikhalev › chatgpt-golang-examples
GitHub - emikhalev/chatgpt-golang-examples
This repository contains examples for the article: ChatGPT Go Libraries: A Comparison With Examples
Author   emikhalev
🌐
Bacancy Technology
bacancytechnology.com › bacancy technology › blog › golang
Unleashing the Power of ChatGPT in GO Apps
June 12, 2023 - Example: Doximity – a professional network for physicians; Babylon Health – a digital healthcare platform; PatientPing – a care coordination platform using Golang to develop backend infrastructure or part of their technology stack.
🌐
Reddit
reddit.com › r/golang › trying to connect to gpt-chat
r/golang on Reddit: Trying to connect to GPT-chat
February 12, 2023 -

Hello all, trying to learn Go and API's. I'm using go-gpt3 api library found at: https://pkg.go.dev/github.com/PullRequestInc/go-gpt3#ChatCompletionResponseChoice

I've been able to connect and get simple answers back like, "what time is it", "what's your favorite color", etc.

But I'm having an issue finding how to change the personality of the AI and add better prompts. Like change the AI to be "someone who loves dad-jokes", "reply like an experienced hiker", or "reply like a secret agent".
I've been reading through the api documentation but am having issues. Anyone familiar with this library or even a good read/tutorial on how to use Gin? (it's what we use at work)

I don't count myself as a programming wiz or anything. Just trying to learn to provide a better life to my kids.

Top answer
1 of 1
3
When you first connect with OpenAI, you can set the behavior with a “System” message. The OpenAI Docs can teach you more about the structure. This Test from that go-gpt3 library can also help point you in the right direction. Example: 1. Set up the client (with your API key) gptClient := gpt3.NewClient(openAIAPIKey) 2. Set up your ChatCompletion object and save the response: ctx := context.Background() resp, err := gptClient.ChatCompletion(ctx, gpt3.ChatCompletionRequest{ Model: gpt3.GPT3Dot5Turbo, Messages: []gpt3.ChatCompletionRequestMessage{ { Role: "system", Content: "You are a dad who loves dad-jokes.", }, { Role: "user", Content: "Surely, you can tell me a good joke?", }, }, }) 3. Choose the response you want: This is the type structure of resp as well as used types. Choices can have multiple alternate answers. // ChatCompletionResponse is the full response from a request to the Chat Completions API type ChatCompletionResponse struct { ID string `json:"id"` Object string `json:"object"` Created int `json:"created"` Model string `json:"model"` Choices []ChatCompletionResponseChoice `json:"choices"` Usage ChatCompletionsResponseUsage `json:"usage"` } // ChatCompletionResponseChoice is one of the choices returned in the response to the Chat Completions API type ChatCompletionResponseChoice struct { Index int `json:"index"` FinishReason string `json:"finish_reason"` Message ChatCompletionResponseMessage `json:"message"` } // ChatCompletionResponseMessage is a message returned in the response to the Chat Completions API type ChatCompletionResponseMessage struct { Role string `json:"role"` Content string `json:"content"` } You can just loop through all of them or just get the first. for _, r := range resp.Choices { fmt.Println(r.Message.Content) } // Or just get the first one fmt.Println(resp.Choices[0].Message.Content)