Documentation
¶
Index ¶
- type ActionInfo
- type ActionRecord
- type CargoItem
- type Config
- type ConfigYAML
- type ErrorRecord
- type Evolver
- type ExperienceRecord
- type FeedbackContext
- type GlobalConfig
- type GoalContext
- type HistoryContext
- type ImprovementSuggestion
- type KnowledgeContext
- type LLMClient
- type Manager
- func (m *Manager) GetAvailableTemplates() []string
- func (m *Manager) HasTemplate(promptType string, version int) bool
- func (m *Manager) LoadTemplates() error
- func (m *Manager) ReloadTemplates() error
- func (m *Manager) RenderPrompt(promptType string, version int, ctx *TemplateContext) (string, error)
- func (m *Manager) RenderPromptByName(templateName string, ctx *TemplateContext) (string, error)
- type Metrics
- type MetricsCollector
- func (mc *MetricsCollector) GetAllMetrics() map[string]*Metrics
- func (mc *MetricsCollector) GetMetrics(promptType string, version int) *Metrics
- func (mc *MetricsCollector) Load() error
- func (mc *MetricsCollector) RecordUse(promptType string, version int, role string, success bool, confidence float64, ...)
- func (mc *MetricsCollector) Save() error
- type MetricsConfig
- type NearbyPlayerInfo
- type POIInfo
- type PersonalityContext
- type PromptConfig
- type PromptStatus
- type Registry
- type RoleMetrics
- type RouteStepInfo
- type SelectionContext
- type Selector
- type StateContext
- type SystemContext
- type SystemInfo
- type TemplateContext
- type TemplateVersion
- type TravelProgressContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionInfo ¶
type ActionInfo struct {
Name string
Description string
RequiresTarget bool
TargetType string // "poi_id", "system_name", "none"
Requirements string // e.g., "Must be docked", "Requires fuel > 10%"
}
ActionInfo describes an available action
type ActionRecord ¶
ActionRecord represents a past action
type ConfigYAML ¶
type ConfigYAML struct {
Global GlobalConfig `yaml:"global"`
Prompts map[string]PromptConfig `yaml:"prompts"`
Metrics MetricsConfig `yaml:"metrics"`
}
ConfigYAML represents the prompts configuration file
func LoadConfig ¶
func LoadConfig(path string) (*ConfigYAML, error)
LoadConfig loads the configuration from a YAML file
func (*ConfigYAML) GetActiveVersion ¶
func (c *ConfigYAML) GetActiveVersion(promptType, role string) (int, bool)
GetActiveVersion returns the active version for a prompt type and role
func (*ConfigYAML) GetFallbackVersion ¶
func (c *ConfigYAML) GetFallbackVersion(promptType string) (int, bool)
GetFallbackVersion returns the fallback version for a prompt type
type ErrorRecord ¶
type ErrorRecord struct {
Timestamp time.Time `yaml:"timestamp"`
Error string `yaml:"error"`
Context string `yaml:"context,omitempty"`
}
ErrorRecord records an error occurrence
type Evolver ¶
type Evolver struct {
// contains filtered or unexported fields
}
Evolver handles prompt evolution and improvement
func NewEvolver ¶
func NewEvolver(manager *Manager, registry *Registry, metrics *MetricsCollector, llmClient LLMClient) *Evolver
NewEvolver creates a new prompt evolver
func (*Evolver) AnalyzePrompt ¶
func (e *Evolver) AnalyzePrompt(promptType string, version int) (*ImprovementSuggestion, error)
AnalyzePrompt analyzes a prompt's metrics and suggests improvements
func (*Evolver) CreateDraftVersion ¶
CreateDraftVersion creates a draft version of a prompt
type ExperienceRecord ¶
type ExperienceRecord struct {
Time string
Type string
Description string
Outcome string
Location string
}
ExperienceRecord represents a past experience
type FeedbackContext ¶
type FeedbackContext struct {
Success bool
Action string
Target string
Message string
Error string
ErrorType string // e.g., "validation", "execution", "timeout"
}
FeedbackContext contains feedback from the last action
type GlobalConfig ¶
type GlobalConfig struct {
SelectionStrategy string `yaml:"selection_strategy"` // "stable", "latest", "role_based"
FallbackToPrevious bool `yaml:"fallback_to_previous"`
CollectMetrics bool `yaml:"collect_metrics"`
}
GlobalConfig holds global configuration
type GoalContext ¶
type GoalContext struct {
Type string // Goal type: "wealth", "skill", "exploration", "resource", "reputation"
Target string // Specific target (e.g., "Mining_5", "10000_credits")
Progress float64 // Progress towards goal (0.0 to 1.0)
Priority int // Priority level (1-10)
Reasoning string // Why this goal was set
Focus string // Current strategic focus
Constraints []string // Active constraints
Urgency int // Urgency level (1-10)
}
GoalContext contains the agent's current goal and priorities
type HistoryContext ¶
type HistoryContext struct {
RecentActions []ActionRecord
RecentExperiences []ExperienceRecord
}
HistoryContext contains recent experiences
type ImprovementSuggestion ¶
type ImprovementSuggestion struct {
PromptType string
CurrentVersion int
NewVersion int
Rationale string
Changes []string
ExpectedBenefits []string
CreatedAt time.Time
}
ImprovementSuggestion represents a suggested improvement to a prompt
type KnowledgeContext ¶
type KnowledgeContext struct {
KnownSystems []SystemInfo
POIsInSystem []POIInfo
Connections []string
UnknownConnections []string
}
KnowledgeContext contains what the agent knows
type LLMClient ¶
type LLMClient interface {
// Query sends a prompt to the LLM and returns the response
Query(prompt string) (string, error)
}
LLMClient defines the interface for LLM operations
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles prompt template loading and rendering
func NewManager ¶
NewManager creates a new PromptManager
func (*Manager) GetAvailableTemplates ¶
GetAvailableTemplates returns a list of loaded template names
func (*Manager) HasTemplate ¶
HasTemplate checks if a template is loaded
func (*Manager) LoadTemplates ¶
LoadTemplates scans and loads all template files
func (*Manager) ReloadTemplates ¶
ReloadTemplates reloads all templates from disk
func (*Manager) RenderPrompt ¶
func (m *Manager) RenderPrompt(promptType string, version int, ctx *TemplateContext) (string, error)
RenderPrompt renders a prompt template with the given context
func (*Manager) RenderPromptByName ¶
func (m *Manager) RenderPromptByName(templateName string, ctx *TemplateContext) (string, error)
RenderPromptByName renders a prompt using the template name directly
type Metrics ¶
type Metrics struct {
PromptType string `yaml:"prompt_type"`
Version int `yaml:"version"`
TotalUses int `yaml:"total_uses"`
SuccessCount int `yaml:"success_count"`
ErrorCount int `yaml:"error_count"`
AvgConfidence float64 `yaml:"avg_confidence"`
LastUsed time.Time `yaml:"last_used"`
Errors []ErrorRecord `yaml:"errors,omitempty"`
ByRole map[string]RoleMetrics `yaml:"by_role,omitempty"`
}
Metrics tracks prompt performance metrics
func (*Metrics) SuccessRate ¶
SuccessRate calculates success rate for a prompt
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects and stores prompt metrics
func NewMetricsCollector ¶
func NewMetricsCollector(storagePath string, enabled bool) *MetricsCollector
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) GetAllMetrics ¶
func (mc *MetricsCollector) GetAllMetrics() map[string]*Metrics
GetAllMetrics returns all collected metrics
func (*MetricsCollector) GetMetrics ¶
func (mc *MetricsCollector) GetMetrics(promptType string, version int) *Metrics
GetMetrics returns metrics for a specific prompt version
func (*MetricsCollector) Load ¶
func (mc *MetricsCollector) Load() error
Load loads metrics from disk
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `yaml:"enabled"`
RetentionDays int `yaml:"retention_days"`
StoragePath string `yaml:"storage_path"`
}
MetricsConfig holds metrics collection configuration
type NearbyPlayerInfo ¶
type NearbyPlayerInfo struct {
Username string
ShipClass string
FactionTag string
InCombat bool
ClanTag string
}
NearbyPlayerInfo represents a nearby player
type PersonalityContext ¶
type PersonalityContext struct {
Name string
Role string
Traits []string
Motivations []string
Skills []string
Background string
}
PersonalityContext contains agent personality information
type PromptConfig ¶
type PromptConfig struct {
ActiveVersion int `yaml:"active_version"`
RoleOverrides map[string]int `yaml:"role_overrides"`
FallbackVersion int `yaml:"fallback_version"`
}
PromptConfig holds configuration for a specific prompt type
type PromptStatus ¶
type PromptStatus string
PromptStatus represents the status of a template version
const ( StatusActive PromptStatus = "active" StatusDraft PromptStatus = "draft" StatusDeprecated PromptStatus = "deprecated" )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks available prompt templates and their versions
func NewRegistry ¶
NewRegistry creates a new prompt registry
func (*Registry) GetAllPromptTypes ¶
GetAllPromptTypes returns all registered prompt types
func (*Registry) GetLatestVersion ¶
GetLatestVersion returns the highest version number (excluding drafts)
func (*Registry) GetVersions ¶
func (r *Registry) GetVersions(promptType string) []TemplateVersion
GetVersions returns all versions for a given prompt type
func (*Registry) HasVersion ¶
HasVersion checks if a specific version exists
type RoleMetrics ¶
type RoleMetrics struct {
Uses int `yaml:"uses"`
SuccessCount int `yaml:"success_count"`
AvgConfidence float64 `yaml:"avg_confidence"`
}
RoleMetrics tracks metrics per role
type RouteStepInfo ¶
RouteStepInfo represents a step in the route home for display in prompts.
type SelectionContext ¶
type SelectionContext struct {
PromptType string
Role string
RequestedVersion int // 0 = use configured version
}
SelectionContext holds information for version selection
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector chooses the appropriate template version
func NewSelector ¶
func NewSelector(registry *Registry, config *ConfigYAML) *Selector
NewSelector creates a new version selector
func (*Selector) SelectVersion ¶
func (s *Selector) SelectVersion(ctx SelectionContext) (int, error)
SelectVersion chooses the best template version for the given context
type StateContext ¶
type StateContext struct {
SystemName string
SystemID string
Location string // e.g., "Sol-Station-Alpha"
IsDocked bool
DockedAt string
Fuel float64
MaxFuel float64
FuelPercent float64
Hull float64
MaxHull float64
HullPercent float64
Cargo []CargoItem
CargoCount int
MaxCargo int
Credits float64
Tick int64
// Combat & Tactical
Shield float64
MaxShield float64
ShieldPercent float64
ShieldRecharge float64
Armor float64
InCombat bool
NearbyPlayers int
NearbyHostiles int
NearbyList []NearbyPlayerInfo
// Ship Technical
CPUUsed float64
CPUCapacity float64
CPUPercent float64
PowerUsed float64
PowerCapacity float64
PowerPercent float64
Speed float64
ShipClass string
Modules []string
// Cargo Details
CargoUsed float64
CargoPercent float64
// Travel & Location
Traveling bool
TravelProgress *TravelProgressContext
POIDescription string
SystemSecurity string
SystemEmpire string
// Safe Haven
SafeSystem string // System ID of the agent's safe haven
SafeSystemName string // Display name of the safe system
// Route Home
RouteHome []RouteStepInfo // Cached route to safe system
RouteHomeJumps int // Total jumps to safe system
}
StateContext contains current game state information
type SystemContext ¶
type SystemContext struct {
AvailableActions []ActionInfo
CurrentTick int64
ServerTime string
}
SystemContext contains system-level information
type SystemInfo ¶
SystemInfo represents knowledge about a system
type TemplateContext ¶
type TemplateContext struct {
AgentID string
AgentName string
Role string
Personality *PersonalityContext
State *StateContext
Knowledge *KnowledgeContext
History *HistoryContext
LastFeedback *FeedbackContext
System *SystemContext
Goal *GoalContext
}
TemplateContext holds all data available to templates
func NewTemplateContext ¶
func NewTemplateContext( agentID string, agentName string, role string, personality map[string]interface{}, state *game.State, knowledge *KnowledgeContext, history *HistoryContext, lastFeedback *FeedbackContext, goal *GoalContext, ) *TemplateContext
NewTemplateContext creates a TemplateContext from game state and agent data
type TemplateVersion ¶
type TemplateVersion struct {
Name string // e.g., "decision"
Version int // e.g., 1, 2, 3
Status PromptStatus
Path string
IsDraft bool // Derived from filename (e.g., decision.v1-draft.tmpl)
}
TemplateVersion represents a specific version of a prompt template