chatgpt

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 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 Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

func (Message) ProxyFormat

func (m Message) ProxyFormat() string

type Request

type Request struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

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