54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type Persona struct {
|
|
Name string `json:"name"`
|
|
Prompt string `json:"prompt"`
|
|
}
|
|
|
|
type PersonaCollection struct {
|
|
Default string `json:"default"`
|
|
Personas []Persona `json:"personas"`
|
|
}
|
|
|
|
func (c PersonaCollection) Validate() error {
|
|
if len(c.Personas) == 0 {
|
|
return fmt.Errorf("at least one persona is required")
|
|
}
|
|
defaultName := normalizePersonaName(c.Default)
|
|
seen := make(map[string]struct{}, len(c.Personas))
|
|
for _, persona := range c.Personas {
|
|
name := normalizePersonaName(persona.Name)
|
|
if name == "" || strings.TrimSpace(persona.Prompt) == "" {
|
|
return fmt.Errorf("persona name and prompt are required")
|
|
}
|
|
if _, exists := seen[name]; exists {
|
|
return fmt.Errorf("duplicate persona %q", name)
|
|
}
|
|
seen[name] = struct{}{}
|
|
}
|
|
if _, exists := seen[defaultName]; !exists {
|
|
return fmt.Errorf("default persona %q does not exist", c.Default)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func normalizePersonaName(name string) string {
|
|
return strings.ToLower(strings.TrimSpace(name))
|
|
}
|
|
|
|
func ShippedPersonas() PersonaCollection {
|
|
return PersonaCollection{Default: "archie", Personas: []Persona{
|
|
{Name: "archie", Prompt: archieIdentity},
|
|
{Name: "helpful", Prompt: "You are a helpful, friendly AI assistant."},
|
|
{Name: "concise", Prompt: "You are a concise assistant. Keep responses brief and to the point."},
|
|
{Name: "technical", Prompt: "You are a technical expert. Provide detailed, accurate technical information."},
|
|
{Name: "creative", Prompt: "You are a creative assistant. Think outside the box and offer innovative solutions."},
|
|
{Name: "teacher", Prompt: "You are a patient teacher. Explain concepts clearly with examples."},
|
|
}}
|
|
}
|