chatgpt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 10 Imported by: 1

README

chatgpt-wapi

Documentation

Index

Constants

View Source
const (
	BU        = "https://chat.openai.com/backend-api"
	Gpt3Model = "text-davinci-002-render-sha"
)

Variables

View Source
var H = map[string]string{
	"User-Agent":   "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0",
	"Content-Type": "application/json; charset=utf-8",
	"Accept":       "text/event-stream",
}

Functions

func NewError

func NewError(code int, message string) error

Types

type Chat

type Chat struct {
	Options
	Session struct {
		ConversationId string
		ParentId       string
	}
	// contains filtered or unexported fields
}

func New

func New(token string, reverseURL string) (*Chat, error)

func NewChat

func NewChat(opt Options) (*Chat, error)

func (*Chat) Reply

func (c *Chat) Reply(ctx context.Context, prompt string) (chan PartialResponse, error)

type Error

type Error struct {
	Code    int
	Message string
}

func (Error) Error

func (c Error) Error() string

type Options

type Options struct {
	Headers map[string]string
	BaseURL string
	Model   string
	Retry   int
}

type PartialResponse

type PartialResponse struct {
	Error error

	ConversationId string      `json:"conversation_id"`
	ResponseError  interface{} `json:"error"`

	Message struct {
		Id     string `json:"id"`
		Status string `json:"status"`

		Author struct {
			Role string `json:"role"`
		} `json:"author"`

		Content struct {
			ContentType string   `json:"content_type"`
			Parts       []string `json:"parts"`
		} `json:"content"`
	} `json:"message"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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