Embed requests send dixie.embed_model (default honcho-embed). Wayback accepts http://web.archive.org, rewrites to https, skips non-200 closest.status. Memento-Datetime is parsed as an HTTP date and future/garbage values become empty snapshot_at. keys add writes via temp+fchown/chmod/rename so root does not clobber keys.toml. Digest fallback is capped at the 6k-token budget.
75 lines
1.6 KiB
Go
75 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/pelletier/go-toml/v2"
|
|
)
|
|
|
|
// File is the on-disk /etc/sift/config.toml.
|
|
type File struct {
|
|
Listen string `toml:"listen"`
|
|
UserAgent string `toml:"user_agent"`
|
|
DenyPrefixes []string `toml:"deny_prefixes"`
|
|
SelfIP SelfIP `toml:"self_ip"`
|
|
Dixie Dixie `toml:"dixie"`
|
|
Digest Digest `toml:"digest"`
|
|
Context Context `toml:"context"`
|
|
}
|
|
|
|
type Dixie struct {
|
|
Chat string `toml:"chat"`
|
|
Embed string `toml:"embed"`
|
|
EmbedModel string `toml:"embed_model"`
|
|
MaxInflight int `toml:"max_inflight"`
|
|
QueueDepth int `toml:"queue_depth"`
|
|
QueueWait string `toml:"queue_wait"`
|
|
}
|
|
|
|
type Digest struct {
|
|
Model string `toml:"model"`
|
|
Thinking bool `toml:"thinking"`
|
|
Cache string `toml:"cache"`
|
|
}
|
|
|
|
type Context struct {
|
|
Honcho string `toml:"honcho"`
|
|
Workspaces []string `toml:"workspaces"`
|
|
}
|
|
|
|
// SelfIP is the [self_ip] block.
|
|
type SelfIP struct {
|
|
Sources []string `toml:"sources"`
|
|
Interval string `toml:"interval"`
|
|
KeepPrevious string `toml:"keep_previous"`
|
|
Path string `toml:"path"`
|
|
}
|
|
|
|
// Load reads path. A missing file returns a zero File and a nil error.
|
|
func Load(path string) (File, error) {
|
|
var f File
|
|
b, err := os.ReadFile(path)
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
return f, nil
|
|
}
|
|
return f, err
|
|
}
|
|
if err := toml.Unmarshal(b, &f); err != nil {
|
|
return File{}, err
|
|
}
|
|
return f, nil
|
|
}
|
|
|
|
func ParseDuration(s string, def time.Duration) time.Duration {
|
|
if s == "" {
|
|
return def
|
|
}
|
|
d, err := time.ParseDuration(s)
|
|
if err != nil {
|
|
return def
|
|
}
|
|
return d
|
|
}
|