Spaces:
Runtime error
Runtime error
| /** | |
| * Shared TypeScript interfaces for the health-marketing-compliance-rag frontend. | |
| * These interfaces mirror the src/persistence.py schema exactly so that any | |
| * future server-side persistence migration requires no data transformation. | |
| */ | |
| export interface Message { | |
| role: "user" | "assistant"; | |
| content: string; | |
| } | |
| export interface Citation { | |
| index: number; | |
| domain: string; | |
| title: string; | |
| source_url?: string; | |
| line_num?: number; | |
| } | |
| export interface QueryResult { | |
| citations: Citation[]; | |
| domains_searched: string[]; | |
| sections_retrieved: number; | |
| timing: Record<string, number>; | |
| token_usage: { total_tokens: number }; | |
| } | |
| export interface Conversation { | |
| id: string; // UUID | |
| title: string; // first user message, ≤80 chars | |
| created_at: string; // ISO 8601 UTC | |
| last_active_at: string; // ISO 8601 UTC | |
| messages: Message[]; | |
| history: Message[]; // condensed history for pipeline | |
| results: Record<string, QueryResult>; // keyed by message index (string) | |
| } | |
| export interface SavedResponse { | |
| id: string; // "{conversation_id}:{msg_index}" | |
| question: string; | |
| answer: string; | |
| saved_at: string; // ISO 8601 UTC | |
| source_conversation_id: string; | |
| source_conversation_title: string; | |
| msg_index: number; | |
| messages_pair: Message[]; | |
| history_pair: Message[]; | |
| result: QueryResult; | |
| } | |
| export interface ChatState { | |
| conversationId: string; // UUID, new per session | |
| messages: Message[]; // rendered chat thread | |
| history: Message[]; // condensed history sent to API | |
| results: Record<string, QueryResult>; // keyed by message index | |
| streamingIndex: number | null; // index of in-flight assistant message | |
| streamingContent: string; // accumulated SSE tokens | |
| isStreaming: boolean; | |
| } | |
| /** | |
| * Supported response languages drawn from src/language.py. | |
| * Keys are BCP-47 language codes; values are display names. | |
| */ | |
| export const SUPPORTED_LANGUAGES: Record<string, string> = { | |
| en: "English", | |
| mi: "te reo Māori", | |
| tl: "Filipino", | |
| hi: "Hindi", | |
| sm: "Samoan", | |
| "zh-cn": "Mandarin Chinese", | |
| "zh-tw": "Cantonese/Traditional Chinese", | |
| }; | |
| /** | |
| * Practitioner profession options for scoping compliance answers | |
| * to the relevant council/board rules. | |
| */ | |
| export const PROFESSIONS = [ | |
| "Chiropractor", | |
| "Osteopath", | |
| "Physiotherapist", | |
| "Chinese Medicine", | |
| "Naturopath", | |
| "Supplement Retailer", | |
| ] as const; | |
| export type Profession = (typeof PROFESSIONS)[number]; | |