feat(api): add Phase 3 observability - expose validation warnings and metadata to frontend
Backend changes: - Create ResponseMetadata and TokenMetrics models for API responses - Modify call_gemini() and call_gemini_with_function_tools() to return (response, log_id) tuple - Add _build_response_metadata() helper to extract metadata from AICallLog - Update routines API (/suggest, /suggest-batch) to populate validation_warnings, auto_fixes_applied, and metadata - Update products API (/suggest) to populate observability fields - Update skincare API to handle new return signature Frontend changes: - Add TypeScript types: TokenMetrics, ResponseMetadata - Update RoutineSuggestion, BatchSuggestion, ShoppingSuggestionResponse with observability fields Next: Create UI components to display warnings, reasoning chains, and token metrics
This commit is contained in:
parent
3bf19d8acb
commit
3c3248c2ea
6 changed files with 213 additions and 40 deletions
|
|
@ -241,10 +241,29 @@ export interface RoutineSuggestionSummary {
|
|||
confidence: number;
|
||||
}
|
||||
|
||||
// Phase 3: Observability metadata types
|
||||
export interface TokenMetrics {
|
||||
prompt_tokens: number;
|
||||
completion_tokens: number;
|
||||
thoughts_tokens?: number;
|
||||
total_tokens: number;
|
||||
}
|
||||
|
||||
export interface ResponseMetadata {
|
||||
model_used: string;
|
||||
duration_ms: number;
|
||||
reasoning_chain?: string;
|
||||
token_metrics?: TokenMetrics;
|
||||
}
|
||||
|
||||
export interface RoutineSuggestion {
|
||||
steps: SuggestedStep[];
|
||||
reasoning: string;
|
||||
summary?: RoutineSuggestionSummary;
|
||||
// Phase 3: Observability fields
|
||||
validation_warnings?: string[];
|
||||
auto_fixes_applied?: string[];
|
||||
metadata?: ResponseMetadata;
|
||||
}
|
||||
|
||||
export interface DayPlan {
|
||||
|
|
@ -257,6 +276,10 @@ export interface DayPlan {
|
|||
export interface BatchSuggestion {
|
||||
days: DayPlan[];
|
||||
overall_reasoning: string;
|
||||
// Phase 3: Observability fields
|
||||
validation_warnings?: string[];
|
||||
auto_fixes_applied?: string[];
|
||||
metadata?: ResponseMetadata;
|
||||
}
|
||||
|
||||
// ─── Shopping suggestion types ───────────────────────────────────────────────
|
||||
|
|
@ -274,6 +297,10 @@ export interface ProductSuggestion {
|
|||
export interface ShoppingSuggestionResponse {
|
||||
suggestions: ProductSuggestion[];
|
||||
reasoning: string;
|
||||
// Phase 3: Observability fields
|
||||
validation_warnings?: string[];
|
||||
auto_fixes_applied?: string[];
|
||||
metadata?: ResponseMetadata;
|
||||
}
|
||||
|
||||
// ─── Health types ────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue