- internal/ai/types.go: IntakeRequest, IntakeResult, TierConfig, AIConfig domain types - internal/ai/client.go: AIClient interface + TierClient (go-openai, BaseURL tier-routing) - internal/ai/mock.go: MockAIClient test double with HighConfidenceResult/LowConfidenceResult fixtures - internal/ai/prompts/intake.go: BuildIntakePrompt() JSON-extraction prompt template - internal/config/config.go: Config.AI AIConfig field, tier defaults, env bindings, ai_config.json merge - ai_config.json: template config with placeholder Tier2 API key - .gitignore: add ai_config.local.json pattern for real keys (T-02-01 mitigation) - All tests pass: TestMockAIClient, TestMockAIClientError, TestTierClientConstruction, TestAIConfigDefaults
38 lines
1.9 KiB
Go
38 lines
1.9 KiB
Go
package ai
|
||
|
||
// IntakeRequest carries 1-3 photos (base64-encoded data URLs) for AI analysis.
|
||
type IntakeRequest struct {
|
||
PhotosBase64 []string // "data:image/jpeg;base64,..."
|
||
JobID string // UUID for tracing
|
||
}
|
||
|
||
// IntakeResult is the structured output from any AI tier's photo analysis.
|
||
// The model is instructed to return this JSON shape verbatim.
|
||
type IntakeResult struct {
|
||
SerialNumber string `json:"serial_number"`
|
||
Model string `json:"model"`
|
||
Manufacturer string `json:"manufacturer"`
|
||
Category string `json:"category"` // compute | networking | storage | cable | peripheral | component | unknown
|
||
Specs map[string]string `json:"specs"`
|
||
SuggestedTags []string `json:"suggested_tags"`
|
||
AINotes string `json:"ai_notes"`
|
||
Confidence float64 `json:"confidence"` // 0.0–1.0 self-reported
|
||
ConfidenceNote string `json:"confidence_note"` // reason if < threshold
|
||
}
|
||
|
||
// TierConfig holds provider configuration for one AI tier.
|
||
type TierConfig struct {
|
||
BaseURL string `json:"base_url" mapstructure:"base_url"`
|
||
APIKey string `json:"api_key" mapstructure:"api_key"`
|
||
Model string `json:"model" mapstructure:"model"`
|
||
TimeoutSeconds int `json:"timeout_seconds" mapstructure:"timeout_seconds"`
|
||
}
|
||
|
||
// AIConfig holds all AI tier configurations and orchestration settings.
|
||
type AIConfig struct {
|
||
Tier1 TierConfig `json:"tier1" mapstructure:"tier1"`
|
||
Tier2 TierConfig `json:"tier2" mapstructure:"tier2"`
|
||
ConfidenceThreshold float64 `json:"confidence_threshold" mapstructure:"confidence_threshold"`
|
||
QuickAddEnabled bool `json:"quick_add_enabled" mapstructure:"quick_add_enabled"`
|
||
QuickAddThreshold float64 `json:"quick_add_threshold" mapstructure:"quick_add_threshold"`
|
||
}
|