ai

package module
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAIClosed = errors.New("AI client is nil or already closed")

Functions

func ApplyModelConfig added in v1.0.6

func ApplyModelConfig(ai AI, cfg ModelConfig)

func NewLimiter

func NewLimiter(rpm int64) *rate.Limiter

Types

type AI

type AI interface {
	LLMs() LLMs
	Model(context.Context) (string, error)

	Limiter

	SetModel(string)
	Model

	Chatbot
	ChatSession() ChatSession

	Close() error
}

type ChatResponse

type ChatResponse interface {
	Results() []string
	TokenCount() TokenCount
}

type ChatSession added in v1.0.2

type ChatSession interface {
	Chatbot
	History() []Message
}

type ChatStream

type ChatStream interface {
	Next() (ChatResponse, error)
	Close() error
}

type Chatbot

type Chatbot interface {
	Chat(context.Context, ...string) (ChatResponse, error)
	ChatStream(context.Context, ...string) (ChatStream, error)
}

type ClientConfig added in v1.0.6

type ClientConfig struct {
	LLMs LLMs

	APIKey   string
	Endpoint string
	Proxy    string

	Limit *int64

	Model       string
	ModelConfig ModelConfig
}

type ClientOption added in v1.0.6

type ClientOption interface {
	Apply(*ClientConfig)
}

func WithAPIKey added in v1.0.6

func WithAPIKey(apiKey string) ClientOption

func WithEndpoint added in v1.0.6

func WithEndpoint(endpoint string) ClientOption

func WithLimit added in v1.0.6

func WithLimit(rpm int64) ClientOption

func WithModel added in v1.0.7

func WithModel(model string) ClientOption

func WithModelConfig added in v1.0.6

func WithModelConfig(config ModelConfig) ClientOption

func WithProxy added in v1.0.6

func WithProxy(proxy string) ClientOption

type LLMs added in v1.0.6

type LLMs string
const (
	ChatGPT LLMs = "ChatGPT"
	Gemini  LLMs = "Gemini"
)

func (LLMs) MarshalText added in v1.0.6

func (m LLMs) MarshalText() ([]byte, error)

func (*LLMs) UnmarshalText added in v1.0.6

func (m *LLMs) UnmarshalText(text []byte) error

type Limiter

type Limiter interface {
	SetLimit(rpm int64)
	Limit() (rpm int64)
}

type Message added in v1.0.2

type Message struct {
	Content string
	Role    string
}

type Model

type Model interface {
	SetCount(x int32)
	SetMaxTokens(x int32)
	SetTemperature(x float32)
	SetTopP(x float32)
	SetJSONResponse(b bool)
}

type ModelConfig added in v1.0.6

type ModelConfig struct {
	Count        *int32
	MaxTokens    *int32
	Temperature  *float32
	TopP         *float32
	JSONResponse *bool
}

type TokenCount added in v1.0.13

type TokenCount struct {
	Prompt int
	Result int
	Total  int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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