openai

package
v0.0.0-...-a4de9da Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const HOST = "https://api.openai.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module string
const (
	DAVINCI03 Module = "text-davinci-003"
	TURBO     Module = "gpt-3.5-turbo"
)

type OPENAI

type OPENAI struct {
	Key       string
	BasicAuth string
}

func Init

func Init(key, BasicAuth string) *OPENAI

func (*OPENAI) Turbo

func (OPENAI *OPENAI) Turbo() *Turbo

type Role

type Role string
const (
	SYSTEM Role = "system"
	USER   Role = "user"
	ASSIS  Role = "assistant"
)

type Turbo

type Turbo struct {
	*OPENAI
	Path string
}

func (*Turbo) Chat

func (T *Turbo) Chat(Msg []*TurboMessage) (respMsg *TurboMessage, err error)

type TurboChoices

type TurboChoices struct {
	Index        uint64        `json:"index"`
	Message      *TurboMessage `json:"message"`
	FinishReason string        `json:"finish_reason"`
}

type TurboError

type TurboError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Param   interface{}
	Code    interface{}
}

type TurboMessage

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

type TurboResp

type TurboResp struct {
	ID      string          `json:"id"`
	Object  string          `json:"object"`
	Created uint64          `json:"created"`
	Choices []*TurboChoices `json:"choices"`
	Usage   *TurboUsage     `json:"usage"`
	Error   *TurboError     `json:"error"`
}

type TurboUsage

type TurboUsage struct {
	PromptTokens     uint64 `json:"prompt_tokens"`
	CompletionTokens uint64 `json:"completion_tokens"`
	TotalTokens      uint64 `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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