Files
HeatGuard/internal/llm/provider.go
vikingowl 5e6696aa42 feat: add AI-powered actions endpoint and timeline annotations
Add LLM actions endpoint that generates hour-specific heat
management recommendations. Replace static action engine with
AI-driven approach. Add cool mode logic (ventilate/ac/overloaded),
indoor temperature tracking, and timeline legend with annotations.
2026-02-10 03:54:09 +01:00

106 lines
2.5 KiB
Go

package llm
import "context"
// Provider is the interface for LLM backends.
type Provider interface {
Summarize(ctx context.Context, input SummaryInput) (string, error)
RewriteAction(ctx context.Context, action ActionInput) (string, error)
GenerateHeatPlan(ctx context.Context, input HeatPlanInput) (string, error)
GenerateActions(ctx context.Context, input ActionsInput) (string, error)
Name() string
}
// HeatSource represents a ranked heat source for summary.
type HeatSource struct {
Name string
Watts float64
}
// RiskWindowSummary is a simplified risk window for LLM input.
type RiskWindowSummary struct {
StartHour int
EndHour int
PeakTempC float64
Level string
}
// SummaryInput holds computed data for the 3-bullet summary.
type SummaryInput struct {
Date string
PeakTempC float64
MinNightTempC float64
RiskLevel string
TopHeatSources []HeatSource
ACHeadroomBTUH float64
BudgetStatus string
ActiveWarnings []string
RiskWindows []RiskWindowSummary
Language string
}
// ActionInput holds data for rewriting a technical action.
type ActionInput struct {
ActionName string
Description string
TempC float64
Hour int
}
// TimelineSlotSummary is a simplified timeline slot for LLM input.
type TimelineSlotSummary struct {
Hour int
TempC float64
RiskLevel string
BudgetStatus string
Actions []string
}
// ActionSummary is a simplified action for LLM input.
type ActionSummary struct {
Name string
Category string
Impact string
Hour int
}
// HeatPlanInput holds full day data for the 1-page plan.
type HeatPlanInput struct {
Summary SummaryInput
Timeline []TimelineSlotSummary
Actions []ActionSummary
CareChecklist []string
}
// ActionsInput holds context for AI-generated actions.
type ActionsInput struct {
Date string
Language string
IndoorTempC float64
PeakTempC float64
MinNightTempC float64
PoorNightCool bool
RiskLevel string
RiskWindows []RiskWindowSummary
Timeline []ActionsTimelineSlot
Rooms []ActionsRoom
}
// ActionsTimelineSlot is one hour's data for AI action generation.
type ActionsTimelineSlot struct {
Hour int
TempC float64
HumidityPct float64
BudgetStatus string
CoolMode string
GainsW float64
}
// ActionsRoom describes a room for AI action generation.
type ActionsRoom struct {
Name string
Orientation string
ShadingType string
HasAC bool
}