52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// agent_config.go — Agent configuration types and JSON unmarshaling.
|
|
//
|
|
// Defines the Prompt type (list of file paths) and related configuration
|
|
// helpers used when loading agent profiles from JSON.
|
|
|
|
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"`
|
|
|
|
Tools []string `json:"tools,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
|
|
}
|