assistant

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaveModeNever     = SaveMode("NEVER")
	SaveModeFsLibrary = SaveMode("FS_LIBRARY")
)
View Source
const (
	ProviderTypeOpenAI           = ProviderType("openai")
	ProviderTypeAnthropic        = ProviderType("anthropic")
	ProviderTypeGemini           = ProviderType("gemini")
	ProviderTypeOllama           = ProviderType("ollama")
	ProviderTypeOpenAICompatible = ProviderType("openai-compatible")
)

Variables

View Source
var (
	ErrorNoAssistantEnabled       = errors.New("No assistant configured or enabled")
	ErrorMultipleProvidersEnabled = errors.New("only one provider can be enabled at a time")
)

SupportedProviders lists all available provider types.

Functions

func PrepareSnippet

func PrepareSnippet(content []byte, parsed ParsedScript) model.Snippet

func RandomScriptFilename

func RandomScriptFilename() string

Types

type Assistant

type Assistant interface {
	Initialize() (bool, uimsg.Printable)
	Query(string) ParsedScript
	AutoConfig(model.AssistantKey) Config
	AssistantDescriptions(config Config) []model.AssistantDescription
}

func NewBuilder

func NewBuilder(system *system.System, config Config, cache cache.Cache, options ...Option) Assistant

type Client

type Client interface {
	Query(string) (string, error)
}

type ClientProvider

type ClientProvider interface {
	GetClient(config Config) (Client, error)
}

type Config

type Config struct {
	SaveMode  SaveMode         `` /* 157-byte string literal not displayed */
	Providers []ProviderConfig `` /* 130-byte string literal not displayed */
}

Config is the top-level assistant configuration.

func (Config) ClientKey

func (c Config) ClientKey() (model.AssistantKey, error)

ClientKey returns a key identifying the active provider.

func (Config) GetActiveProvider added in v1.6.1

func (c Config) GetActiveProvider() (*ProviderConfig, error)

GetActiveProvider returns the first enabled provider config. Returns an error if multiple providers are enabled or none are enabled.

func (Config) HasEnabledProvider added in v1.6.1

func (c Config) HasEnabledProvider() bool

HasEnabledProvider returns true if at least one provider is enabled.

func (Config) ValidateConfig added in v1.6.1

func (c Config) ValidateConfig() error

ValidateConfig returns an error if the configuration is invalid.

type DemoConfig

type DemoConfig struct {
	ScriptPaths   []string
	QueryDuration time.Duration
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a Manager.

func WithDemoConfig

func WithDemoConfig(demo DemoConfig) Option

type ParsedScript

type ParsedScript struct {
	Contents string
	Filename string
	Title    string
}

type ProviderConfig added in v1.6.1

type ProviderConfig struct {
	Type      ProviderType `yaml:"type" mapstructure:"type" head_comment:"Provider type: openai, anthropic, gemini, ollama, openai-compatible"`
	Enabled   bool         `yaml:"enabled" mapstructure:"enabled" head_comment:"If set to false, this provider will be skipped."`
	Model     string       `yaml:"model" mapstructure:"model" head_comment:"Model name to use (e.g., gpt-4o, claude-sonnet-4-20250514, gemini-1.5-flash)"`
	APIKeyEnv string       `yaml:"apiKeyEnv,omitempty" mapstructure:"apiKeyEnv" head_comment:"Environment variable holding the API key."`
	Endpoint  string       `` /* 128-byte string literal not displayed */
	// Ollama-specific
	ServerURL string `yaml:"serverUrl,omitempty" mapstructure:"serverUrl" head_comment:"Ollama server URL (for ollama provider only)."`
}

ProviderConfig represents a single LLM provider configuration.

func DefaultProviderConfig added in v1.6.1

func DefaultProviderConfig(providerType ProviderType) ProviderConfig

DefaultProviderConfig returns a default configuration for a given provider type.

type ProviderInfo added in v1.6.1

type ProviderInfo struct {
	Name             string
	Description      string
	DefaultModel     string
	DefaultAPIKeyEnv string
}

ProviderInfo contains display information for a provider.

func GetProviderInfo added in v1.6.1

func GetProviderInfo(providerType ProviderType) ProviderInfo

GetProviderInfo returns display information for a provider type.

type ProviderType added in v1.6.1

type ProviderType string

ProviderType represents the type of LLM provider.

type SaveMode

type SaveMode string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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