config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir возвращает путь к директории конфигов

Types

type Config

type Config struct {
	ActiveProvider Provider                    `json:"active_provider"`
	Providers      map[Provider]ProviderConfig `json:"providers"`
	WorkDir        string                      `json:"work_dir,omitempty"`
	Theme          string                      `json:"theme"`
	Language       string                      `json:"language"`
	SystemPrompt   string                      `json:"system_prompt"`
	// UserProfile — описание пользователя (кто я, чем занимаюсь)
	UserProfile string `json:"user_profile,omitempty"`
	// AIInstructions — инструкции для AI (как отвечать, стиль, уровень)
	AIInstructions string `json:"ai_instructions,omitempty"`
}

Config — главный конфиг TermCode

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig возвращает конфиг с разумными дефолтами

func Load

func Load() (*Config, error)

Load загружает конфиг из файла или возвращает дефолтный

func (*Config) ActiveProviderConfig

func (c *Config) ActiveProviderConfig() (ProviderConfig, bool)

ActiveProviderConfig возвращает конфиг активного провайдера

func (*Config) Save

func (c *Config) Save() error

Save сохраняет конфиг на диск

type Provider

type Provider string

Provider идентифицирует AI провайдера

const (
	ProviderOllama     Provider = "ollama"
	ProviderOpenAI     Provider = "openai"
	ProviderAnthropic  Provider = "anthropic"
	ProviderOpenRouter Provider = "openrouter"
)

type ProviderConfig

type ProviderConfig struct {
	BaseURL string `json:"base_url"`
	APIKey  string `json:"api_key"`
	Model   string `json:"model"`
	// MaxTokens — максимум токенов в одном ответе (0 = авто по модели)
	MaxTokens int `json:"max_tokens,omitempty"`
	// ContextLength — размер окна контекста (0 = авто по модели)
	ContextLength int `json:"context_length,omitempty"`
}

ProviderConfig — настройки одного провайдера

func (ProviderConfig) GetContextLength

func (pc ProviderConfig) GetContextLength() int

GetContextLength возвращает размер контекстного окна

func (ProviderConfig) GetMaxTokens

func (pc ProviderConfig) GetMaxTokens() int

GetMaxTokens возвращает лимит токенов ответа для данного конфига провайдера

Jump to

Keyboard shortcuts

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