ai

package module
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 6 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(limit rate.Limit) *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
}

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 *rate.Limit

	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(limit rate.Limit) 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(rate.Limit)
}

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)
}

type ModelConfig added in v1.0.6

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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