feat: add safe growth report persistence and AvalAI client
This commit is contained in:
78
internal/growthreport/model.go
Normal file
78
internal/growthreport/model.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package growthreport
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusQueued Status = "QUEUED"
|
||||
StatusAnalyzing Status = "ANALYZING"
|
||||
StatusGenerating Status = "GENERATING"
|
||||
StatusReady Status = "READY"
|
||||
StatusPartial Status = "PARTIAL"
|
||||
StatusFailed Status = "FAILED"
|
||||
)
|
||||
|
||||
func (s Status) Terminal() bool { return s == StatusReady || s == StatusPartial || s == StatusFailed }
|
||||
|
||||
type Scope struct { TerminalID *string `json:"terminalId"` }
|
||||
|
||||
type CampaignBrief struct {
|
||||
Headline string `json:"headline"`
|
||||
Interpretation string `json:"interpretation"`
|
||||
OfferSuggestion string `json:"offerSuggestion"`
|
||||
MessageSuggestion string `json:"messageSuggestion"`
|
||||
PreparationAction string `json:"preparationAction"`
|
||||
Limitation string `json:"limitation"`
|
||||
EvidenceIDs []string `json:"evidenceIds"`
|
||||
}
|
||||
|
||||
type AICopy struct { Briefs []CampaignBrief `json:"briefs"` }
|
||||
|
||||
type Usage struct {
|
||||
InputTokens int64 `json:"inputTokens"`
|
||||
OutputTokens int64 `json:"outputTokens"`
|
||||
LatencyMS int64 `json:"latencyMs"`
|
||||
}
|
||||
|
||||
type Report struct {
|
||||
ReportID string `json:"reportId"`
|
||||
Status Status `json:"status"`
|
||||
Scope Scope `json:"scope"`
|
||||
HorizonDays int `json:"horizonDays"`
|
||||
ForecastStartDate *time.Time `json:"forecastStartDate,omitempty"`
|
||||
DeterministicEvidence json.RawMessage `json:"deterministicEvidence"`
|
||||
AICopy *AICopy `json:"aiCopy,omitempty"`
|
||||
FailureCode *string `json:"failureCode,omitempty"`
|
||||
Cached bool `json:"cached"`
|
||||
Stale bool `json:"stale"`
|
||||
NextRefreshAt time.Time `json:"nextRefreshAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
EventsURL string `json:"eventsUrl"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
Report
|
||||
MerchantID int64
|
||||
TerminalDBID *int64
|
||||
Fingerprint string
|
||||
DatasetWatermark string
|
||||
CatalogVersion string
|
||||
AnalyticsVersion string
|
||||
PromptVersion string
|
||||
SchemaVersion string
|
||||
Model string
|
||||
Usage Usage
|
||||
ManualRefresh bool
|
||||
TehranRefreshDay *time.Time
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
TerminalID string `json:"terminalId"`
|
||||
Refresh bool `json:"refresh"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user