Documentation
¶
Overview ¶
eliza implements a mock LLM provider based on the classic ELIZA chatbot, created by Joseph Weizenbaum at MIT in 1966, which simulates a psychotherapist using pattern matching and transformation rules. It has a model for each of its languages, and makes no network calls at all, so it's always reachable, which is useful for exercising provider code paths (like connectivity checks, and generating messages) without depending on a real LLM backend.
Index ¶
- Constants
- func LoadLanguages() (map[string]*Language, error)
- type Client
- func (c *Client) GetModel(ctx context.Context, name string) (llm.Model, error)
- func (c *Client) ListModels(ctx context.Context) ([]llm.Model, error)
- func (*Client) Name() string
- func (*Client) Ping(ctx context.Context) error
- func (c *Client) Self() llm.Provider
- func (*Client) URL() *url.URL
- func (c *Client) WithoutSession(ctx context.Context, model llm.Model, messages []llm.Message, tools []llm.Tool, ...) (llm.Message, llm.Usage, error)
- type Engine
- type Language
- type Model
- func (m *Model) Aliases() []string
- func (m *Model) Capabilities() llm.ModelCap
- func (m *Model) Created() time.Time
- func (m *Model) Description() string
- func (m *Model) InputTokenLimit() *uint
- func (m *Model) Meta() map[string]json.RawMessage
- func (m *Model) Name() string
- func (m *Model) OutputTokenLimit() *uint
- func (m *Model) Provider() llm.Provider
- type Opt
- type Rule
Constants ¶
const ModelName = "eliza"
ModelName is an alias of eliza's English model, which is its default
Variables ¶
This section is empty.
Functions ¶
func LoadLanguages ¶
LoadLanguages reads all embedded lang/*.json files and returns them keyed by model name
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the ELIZA chatbot as an LLM provider
func New ¶
New creates a new eliza client, with its languages. It takes no endpoint, since it makes no network calls at all.
func (*Client) GetModel ¶
GetModel returns the model with the name, or the English model for eliza, or a not-found error
func (*Client) ListModels ¶
ListModels returns a model for each of eliza's languages, in order of their names
func (*Client) WithoutSession ¶
func (c *Client) WithoutSession(ctx context.Context, model llm.Model, messages []llm.Message, tools []llm.Tool, stream llm.GeneratorStreamFn, opts ...llm.Opt) (llm.Message, llm.Usage, error)
WithoutSession returns eliza's reply to the last of the messages, which is the user's, and must be for a model of this client, and the tokens used, which are estimated, as eliza has no tokens. Eliza remembers what the user said in the earlier messages, and with WithThinking, the reply's thinking is what it remembers. It can't call tools, so there can't be any. When the stream function isn't nil, it's called with the reply's thinking, and then its text a word at a time, as a model would generate it. The reply is the same for the same messages, with the client's seed.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the classic ELIZA conversation algorithm created by Joseph Weizenbaum at MIT in 1966.
func (*Engine) InferMemory ¶
InferMemory rebuilds the memory from the text of the user's earlier messages which match memorable rules, so the engine can be created fresh for each request while remembering the conversation
type Language ¶
type Language struct {
Model string `json:"model"`
Description string `json:"description"`
LanguageCode string `json:"language"`
Quits []string `json:"quits"`
Greetings []string `json:"greetings"`
Reflections map[string]string `json:"reflections"`
Rules []Rule `json:"rules"`
GreetingResponses []string `json:"greetingResponses"`
GoodbyeResponses []string `json:"goodbyeResponses"`
DefaultResponses []string `json:"defaultResponses"`
MemoryResponses []string `json:"memoryResponses"`
}
Language defines all the text data for an ELIZA language variant
type Model ¶ added in v0.5.0
type Model struct {
// contains filtered or unexported fields
}
Model is one of eliza's languages
func (*Model) Aliases ¶ added in v0.5.0
Aliases returns eliza for the English model, which is its default
func (*Model) Capabilities ¶ added in v0.5.0
Capabilities returns that eliza replies to messages, and thinks, with WithThinking, without tools, and does nothing else. Each capability is its own value, so it can be changed without changing the others.
func (*Model) Description ¶ added in v0.5.0
func (*Model) InputTokenLimit ¶ added in v0.5.0
InputTokenLimit is not meaningful for a mock model.
func (*Model) Meta ¶ added in v0.5.0
func (m *Model) Meta() map[string]json.RawMessage
Meta returns who created ELIZA, and the model's language
func (*Model) OutputTokenLimit ¶ added in v0.5.0
OutputTokenLimit is not meaningful for a mock model.