config

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDirName       = "fraga"
	ConfigFileName      = "fraga.json"
	ConfigFileNameJSONC = "fraga.jsonc"

	// Default provider URLs
	DefaultOpenAIBaseURL    = "https://api.openai.com/v1"
	DefaultAnthropicBaseURL = "https://api.anthropic.com"
)

Variables

View Source
var (
	ErrUnknownProvider = errors.New("unknown provider")
	ErrConfigExists    = errors.New("config already exists")
)

Functions

func GetConfigDir

func GetConfigDir() (string, error)

func GetSystemPromptsDir

func GetSystemPromptsDir() string

func InitDefault

func InitDefault() error

InitDefault creates a default config file with helpful comments

func InitSystemPromptsDir

func InitSystemPromptsDir() error

Types

type Config

type Config struct {
	Model     string                    `json:"model"`
	Provider  string                    `json:"provider"`
	Providers map[string]ProviderConfig `json:"providers"`
	Settings  Settings                  `json:"settings"`
	MCP       map[string]MCPServer      `json:"mcp,omitempty"`
}

Config holds the complete Fraga configuration

func Load

func Load(configDir string) (*Config, error)

Load loads config with requiring proper configuration set

func LoadWithoutValidation

func LoadWithoutValidation(configDir string) (*Config, error)

LoadWithoutValidation loads config without requiring provider configuration

type MCPServer

type MCPServer struct {
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

MCPServer holds configuration for an MCP server Headers are sent with every request when using the Streamable HTTP transport (i.e. when URL is set).

type ProviderConfig

type ProviderConfig struct {
	Type    string            `json:"type"`
	APIKey  string            `json:"api_key,omitempty"`
	BaseURL string            `json:"base_url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

ProviderConfig holds configuration for a single provider. The Type field determines which backend is used: "openai" or "anthropic".

type Settings

type Settings struct {
	Temperature    *float64 `json:"temperature,omitempty"`
	MaxTokens      int      `json:"max_tokens"`
	SystemPrompt   string   `json:"system_prompt"`
	RenderMarkdown *bool    `json:"render_markdown,omitempty"`
}

Settings holds application settings

func (Settings) ShouldRenderMarkdown

func (s Settings) ShouldRenderMarkdown() bool

ShouldRenderMarkdown returns true if markdown rendering should be enabled. It defaults to true when the field is omitted from config.

type SystemPrompt

type SystemPrompt struct {
	Content     string
	Temperature *float64
	MaxTokens   int
}

func GetDefaultSystemPrompt

func GetDefaultSystemPrompt() (SystemPrompt, error)

func LoadSystemPrompt

func LoadSystemPrompt(name string) (SystemPrompt, error)

Jump to

Keyboard shortcuts

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