ollie/cmd/olliesrv/internal/agent/agent_config.go

47 lines
1.1 KiB
Go

package agent
import (
"encoding/json"
"io"
"ollie/cmd/olliesrv/internal/backend"
)
// Prompt holds the agent prompt — a list of file paths to read and concatenate.
// Unmarshals from either a JSON string (single path) or array of strings.
type Prompt struct {
Value []string
}
func (p *Prompt) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err == nil {
p.Value = []string{s}
return nil
}
return json.Unmarshal(data, &p.Value)
}
type AgentConfig struct {
Prompt Prompt `json:"prompt,omitempty"`
UserPrompts Prompt `json:"userPrompts,omitempty"`
Backend string `json:"backend,omitempty"`
Model string `json:"model,omitempty"`
AutoLoad []string `json:"autoLoad,omitempty"`
CompactionModel string `json:"compactionModel,omitempty"`
// SystemPrompt overrides the embedded system prompt with a file path.
SystemPrompt string `json:"systemPrompt,omitempty"`
backend.GenerationParams
}
// Load parses a Config from r.
func Load(r io.Reader) (*AgentConfig, error) {
var cfg AgentConfig
if err := json.NewDecoder(r).Decode(&cfg); err != nil {
return nil, err
}
return &cfg, nil
}