config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicConfig

type AnthropicConfig struct {
	ApiKeyEnv string `toml:"api-key-env"`
	Model     string `toml:"model"`
}

type Config

type Config struct {
	// LLM provider. Either `openai`, `anthropic` or `testing`.
	Provider string `toml:"provider,omitempty"`
	// The system message is dynamically added to each request in a conversation,
	// followed by the context string.
	SystemMessage string `toml:"system-message,multiline,omitempty"`
	// Additional .gitignore patterns for files that should be excluded from the
	// context sent to the LLM.
	Exclude []string `toml:"exclude"`
	// Maximum permitted length of the full context string (including XML tags).
	MaxContextLength int `toml:"max-context-length,omitempty"`
	// Files exceeding this limit will be ignored. This value should be defined
	// using SI notation, e.g. 20KB.
	MaxFileSize string `toml:"max-file-size,omitempty"`
	// Older conversations will be pruned from the database. -1 can be set to
	// ignore this option.
	MaxConversationHistory int `toml:"max-conversation-history,omitempty"`
	// Configuration for the `openai` LLM provider.
	Openai OpenaiConfig `toml:"openai,omitempty"`
	// Configuration for the `anthropic` LLM provider.
	Anthropic AnthropicConfig `toml:"anthropic,omitempty"`
}

func ConfigFromToml

func ConfigFromToml(input string) (Config, error)

func DefaultConfig

func DefaultConfig() Config

func ResolveConfig

func ResolveConfig(overrides *Config) (Config, error)

ResolveConfig merges the default configuration with any overrides provided by the user in the `pal.toml` file.

It first creates a copy of the default configuration, and then applies any non-zero values from the user-provided overrides. This ensures that the returned configuration always contains a complete set of valid options, with the user’s overrides taking precedence.

The function also performs basic validation on the resolved configuration.

Returns the final, resolved configuration, or an error if any validation checks fail.

func (*Config) ToToml

func (c *Config) ToToml() (string, error)

func (*Config) Validate

func (c *Config) Validate() error

Provides basic validation.

type OpenaiConfig

type OpenaiConfig struct {
	ApiKeyEnv string `toml:"api-key-env"`
	Model     string `toml:"model"`
}

Jump to

Keyboard shortcuts

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