go-chatgpt

command module
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 6 Imported by: 0

README

go-chatgpt

go-chatgpt: Reverse engineered API of OpenAi's ChatGPT. ChatGPT聊天功能的逆向工程

go-chatgpt is a ChatGPT unofficial API developed using Golang. With most chatbot APIs being built on Python, go-chatgpt is unique in its ability to be easily compiled and deployed. It's designed to work seamlessly with your current applications, providing a customizable and reliable chatbot experience.

Setup

go get -u github.com/billikeu/go-chatgpt/chatgptuno

Example bot

package main

import (
	"log"
	"time"

	"github.com/billikeu/go-chatgpt/chatgptuno"
)

var conversationId string
var parentId string

// Every time data is received, this callback will be called and executed sequentially
func callback(chatRes *chatgptuno.Response, err error) {
	/*
	   Support churn transmission, here we only print the last time
	*/
	if chatRes.Message.Metadata.FinishDetails.Stop != "" {
		log.Println(chatRes.ConversationID, chatRes.Message.ID, chatRes.Message.Content.Parts)
		conversationId = chatRes.ConversationID
		parentId = chatRes.Message.ID
	}
}

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	chat := chatgptuno.NewChatGPTUnoBot(&chatgptuno.ChatGPTUnoConfig{
		Model:       "text-davinci-002-render-sha",
		Proxy:       "http://127.0.0.1:9080",
		AccessToken: "your access token",
	})
	if err := chat.Ask("give me a joke.", conversationId, parentId, "", 360, callback); err != nil {
		panic(err)
	}
	if err := chat.Ask("it's not funny.", conversationId, parentId, "", 360, callback); err != nil {
		panic(err)
	}
	log.Println(conversationId, parentId)
	// wait for change title
	time.Sleep(time.Second * 10)
}
  • Set environment variable CHATGPT_BASE_URL to change BaseURL, default: https://bypass.churchless.tech/api/

Others

Star History

Star History Chart

Contributors

This project exists thanks to all the people who contribute.

Reference

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL