chatgpt

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 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 string `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  Properties `json:"properties"`
	Required    []string   `json:"required,omitempty"`
}

type Properties added in v1.9.0

type Properties map[string]Param

func (Properties) MarshalJSON added in v1.9.0

func (p Properties) MarshalJSON() ([]byte, error)

type Request

type Request struct {
	Model       string     `json:"model"`
	Messages    []Message  `json:"messages"`
	Functions   []Function `json:"functions,omitempty"`
	Seed        *int       `json:"seed,omitempty"`
	Temperature *float64   `json:"temperature,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