Files
ai-mailer/config/config.go

61 lines
1.2 KiB
Go

package config
import (
"os"
"time"
"gopkg.in/yaml.v3"
)
type Config struct {
IMAP IMAPConfig `yaml:"imap"`
AI AIConfig `yaml:"ai"`
Context ContextConfig `yaml:"context"`
Polling PollingConfig `yaml:"polling"`
Logging LoggingConfig `yaml:"logging"`
}
type IMAPConfig struct {
Server string `yaml:"server"`
Port int `yaml:"port"`
Username string `yaml:"username"`
Password string `yaml:"password"`
MailboxIn string `yaml:"mailbox_in"`
DraftBox string `yaml:"draft_box"`
UseTLS bool `yaml:"use_tls"`
}
type AIConfig struct {
OpenRouterAPIKey string `yaml:"openrouter_api_key"`
Model string `yaml:"model"`
Temperature float32 `yaml:"temperature"`
MaxTokens int `yaml:"max_tokens"`
}
type ContextConfig struct {
URLs []string `yaml:"urls"`
}
type PollingConfig struct {
Interval time.Duration `yaml:"interval"`
}
type LoggingConfig struct {
Level string `yaml:"level"`
FilePath string `yaml:"file_path"`
}
func Load(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var config Config
if err := yaml.Unmarshal(data, &config); err != nil {
return nil, err
}
return &config, nil
}