pkg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFoundErr = errors.New("not found")
	BusyErr     = errors.New("busy, not valid now")
)

Functions

This section is empty.

Types

type BackResp

type BackResp struct {
	Err     error
	Content string
	Cookie  map[string]string
}

backend response

type Backender

type Backender interface {
	// async read
	Send(prompt string, t ChatModel) (<-chan *BackResp, error)

	// bk name
	Name() string
}

type ChatModel

type ChatModel string
const (
	RoleAssistant = "assistant"
	RoleUser      = "user"
	RoleSystem    = "system"

	GPT3Model     ChatModel = "gpt-3.5"
	GPT3PlusModel ChatModel = "gpt-3.5-turbo"
	GPT4Model     ChatModel = "gpt-4"
	GPT4PlusModel ChatModel = "gpt-4-32k"

	NonModel ChatModel = ""
	ImgModel ChatModel = "image"
	TxtModel ChatModel = "text"
)

func ModelName

func ModelName(m string) (ChatModel, bool)

type ChatReq

type ChatReq struct {
	Messages    []*Delta `json:"messages"`
	Model       string   `json:"model,omitempty"`
	Stream      bool     `json:"stream,omitempty"`
	Temperature float32  `json:"temperature,omitempty"`
	Presence    int      `json:"presence_penalty,omitempty"`
}

gpt request

type ChatResp

type ChatResp struct {
	Id      string    `json:"id,omitempty"`
	Object  string    `json:"object,omitempty"`
	Model   string    `json:"model,omitempty"`
	Choices []*Choice `json:"choices,omitempty"`
}

func GetContent

func GetContent(req *ChatReq, finish bool, content string) *ChatResp

type Choice

type Choice struct {
	Delta  *Delta `json:"delta,omitempty"`
	Finish string `json:"finish_reason,omitempty"`
}

type Delta

type Delta struct {
	Role    string `json:"role,omitempty"`
	Content string `json:"content,omitempty"`
}

type Model

type Model struct {
	Id     string `json:"id"`
	Model  string `json:"model"` // equal id
	Object string `json:"object"`
}

model request

func GetModels

func GetModels() []*Model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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