chatgpt

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Overview

Package chatgpt is a simple binding to the ChatGPT API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Message      Message `json:"message"`
	FinishReason string  `json:"finish_reason"`
	Index        int     `json:"index"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string) Client

func (Client) Complete

func (c Client) Complete(ctx context.Context, r Request) (*Response, error)

type Funcall

type Funcall struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments"`
}

type Function

type Function struct {
	Name        string  `json:"name"`
	Description string  `json:"description,omitempty"`
	Parameters  []Param `json:"parameters"`
}

type Message

type Message struct {
	Role         string   `json:"role"`
	Content      string   `json:"content"`
	FunctionCall *Funcall `json:"function_call,omitempty"`
}

func (Message) ProxyFormat

func (m Message) ProxyFormat() string

type Param

type Param struct {
	Type        string           `json:"type"`
	Description string           `json:"description,omitempty"`
	Enum        []string         `json:"enum,omitempty"`
	Properties  map[string]Param `json:"properties,omitempty"`
	Required    []string         `json:"required,omitempty"`
}

type Request

type Request struct {
	Model     string     `json:"model"`
	Messages  []Message  `json:"messages"`
	Functions []Function `json:"functions,omitempty"`
}

type Response

type Response struct {
	ID      string   `json:"id"`
	Object  string   `json:"object"`
	Created int      `json:"created"`
	Model   string   `json:"model"`
	Usage   Usage    `json:"usage"`
	Choices []Choice `json:"choices"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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