🌐
GitHub
github.com › sashabaranov › go-openai
GitHub - sashabaranov/go-openai: OpenAI ChatGPT, GPT-5, GPT-Image-1, Whisper API clients for Go
OpenAI ChatGPT, GPT-5, GPT-Image-1, Whisper API clients for Go - sashabaranov/go-openai
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.
🌐
Go Packages
pkg.go.dev › github.com › ayush6624 › go-chatgpt
chatgpt package - github.com/ayush6624/go-chatgpt - Go Packages
To use a custom model/parameters, use the Send API. 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 }
🌐
Pipedream
pipedream.com › apps › openai › integrations › go
Integrate the OpenAI (ChatGPT) API with the Go API - Pipedream
import { axios } from "@pipedream/platform" export default defineComponent({ props: { openai: { type: "app", app: "openai", } }, async run({steps, $}) { return await axios($, { url: `https://api.openai.com/v1/models`, headers: { Authorization: `Bearer ${this.openai.$auth.api_key}`, }, }) }, })
🌐
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 · go get -u -x github.com/kkdai/chatgpt · Request your OpenAPI key in https://beta.openai.com/account/api-keys · export API_KEY=YOUR_KEY chatgpt · Please open up an issue on GitHub before you put a lot efforts on pull request.
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.
🌐
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
🌐
Medium
medium.com › better-programming › chatgpt-golang-a7bd524e7563
Consume OpenAI (ChatGPT) With Golang | by Francisco Escher | Better Programming
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
🌐
YouTube
youtube.com › grow adept
Put the Power of ChatGPT in Your Golang Apps - Golang Projects - YouTube
https://www.buymeacoffee.com/GrowAdepthttps://github.com/GrowAdept/youtubeWelcome, in this tutorial we are going to use ChatGPT to write code and create a Go...
Published   March 7, 2023
Views   3K
🌐
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() { // new chatgpt client token := `copy-from-cookies` cfValue := "copy-from-cookies" cookies := []*http.Cookie{ { Name: "__Secure-next-auth.session-token", Value: token, }, { Name: "cf_clearance", Value: cfValue, }, } cli := chatgpt.NewClient( chatgpt.WithDebug(true), chatgpt.WithTimeout(60*time.Second), chatgpt.WithCookies(cookies), ) // chat in continuous conversation // first message message := "say hello to me" text, err := cli.GetChatText(message) if err != nil { log.Fatalf("get chat text fai
Starred by 159 users
Forked by 25 users
Languages   Go
🌐
ChatGPT
chatgpt.com › g › g-hz1nSk4cK-go-backend-api
ChatGPT - Go Backend API
ChatGPT is your AI chatbot for everyday use. Chat with the most advanced AI to explore ideas, solve problems, and learn faster.
🌐
GitHub
github.com › fengxxc › go-chatgpt
GitHub - fengxxc/go-chatgpt: a ChatGPT API client based on the Go
a ChatGPT API client based on the Go. Contribute to fengxxc/go-chatgpt development by creating an account on GitHub.
Author   fengxxc
🌐
Go Packages
pkg.go.dev › github.com › golang-infrastructure › go-ChatGPT
chatgpt package - github.com/golang-infrastructure/go-ChatGPT - Go Packages
github.com/golang-infrastructure/go-ChatGPT · Open Source Insights · 这是一个ChatGPT的Golang API库,让你能够把ChatGPT集成到你的Go应用中,注意这是基于逆向工程实现的并不是一个官方库。 · 优势: · 只需要提供自己的JWT就能够像在网页...
🌐
Bacancy Technology
bacancytechnology.com › bacancy technology › blog › golang
Unleashing the Power of ChatGPT in GO Apps
June 12, 2023 - Begin by setting up your development environment and ensuring compatibility with the Golang ChatGPT API. Understand and revive the documentation and guidelines provided by OpenAI. Follow the step-by-step instructions for authentication, API usage, and error handling.
🌐
Go Packages
pkg.go.dev › github.com › linweiyuan › go-chatgpt-api › api › chatgpt
chatgpt package - github.com/linweiyuan/go-chatgpt-api/api/chatgpt - Go Packages
github.com/linweiyuan/go-chatgpt-api · Open Source Insights · func CreateConversation(c *gin.Context) func Login(c *gin.Context) type Author · type Content · type CreateConversationRequest · func (c *CreateConversationRequest) AddMessage(role string, content string) type CreateConversationResponse ·
🌐
GitHub
github.com › ayush6624 › go-chatgpt
GitHub - ayush6624/go-chatgpt: Open-source GoLang client for ChatGPT
To use a custom model/parameters, use the Send API. 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 }
Starred by 28 users
Forked by 13 users
Languages   Go
🌐
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)