gpt

package
v0.0.0-...-faf3a0e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UserRole      = openai.ChatMessageRoleUser
	SystemRole    = openai.ChatMessageRoleSystem
	AssistantRole = openai.ChatMessageRoleAssistant

	GPT3_5Turbo = openai.GPT3Dot5Turbo
	GPT4        = openai.GPT4

	GPT4Prefix   = "gpt-4"
	GPT3_5Prefix = "gpt-3.5"

	GPT3_5CostInput  = 0.0015 // USD
	GPT3_5CostOutput = 0.002  //  USD
	GPT4CostInput    = 0.03   // USD
	GPT4CostOutput   = 0.06   // USD
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatModel

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

func NewChatModel

func NewChatModel(engine Engine, alias, systemPrompt string) ChatModel

func (*ChatModel) AddUserMessage

func (m *ChatModel) AddUserMessage(message string)

func (*ChatModel) SendChat

func (m *ChatModel) SendChat() (string, error)

type ChatResponse

type ChatResponse struct {
	Message            string
	Reason             string
	PromptTokenCount   int
	ResponseTokenCount int
}

type Engine

type Engine interface {
	SendChat(messages []openai.ChatCompletionMessage) (ChatResponse, error)
	GetModel() string
}

func NewGPT

func NewGPT(model, apikey string, temperature float32) Engine

func NewMockGPT

func NewMockGPT(model string) Engine

type GPT

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

func (*GPT) GetModel

func (gpt *GPT) GetModel() string

func (*GPT) SendChat

func (gpt *GPT) SendChat(messages []openai.ChatCompletionMessage) (ChatResponse, error)

type MockGPT

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

func (*MockGPT) GetModel

func (m *MockGPT) GetModel() string

func (*MockGPT) SendChat

func (m *MockGPT) SendChat(messages []openai.ChatCompletionMessage) (ChatResponse, error)

Jump to

Keyboard shortcuts

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