|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface BaseMessage { |
|
|
type: string; |
|
|
timestamp: string; |
|
|
session_id?: string; |
|
|
} |
|
|
|
|
|
|
|
|
export interface ThoughtMessage extends BaseMessage { |
|
|
type: 'thought'; |
|
|
content: string; |
|
|
variant?: 'initial' | 'intermediate' | 'final'; |
|
|
} |
|
|
|
|
|
|
|
|
export interface ActionStartMessage extends BaseMessage { |
|
|
type: 'action_start'; |
|
|
tool_name: string; |
|
|
tool_display_name: string; |
|
|
} |
|
|
|
|
|
|
|
|
export interface CVPrediction { |
|
|
condition: string; |
|
|
confidence: number; |
|
|
} |
|
|
|
|
|
export interface CVResults { |
|
|
predictions: CVPrediction[]; |
|
|
visual_features?: string[]; |
|
|
annotations?: Array<{ |
|
|
bbox: [number, number, number, number]; |
|
|
label: string; |
|
|
confidence: number; |
|
|
}>; |
|
|
model_info?: { |
|
|
name: string; |
|
|
accuracy: number; |
|
|
trained_on?: number; |
|
|
}; |
|
|
} |
|
|
|
|
|
export interface RedFlag { |
|
|
symptom: string; |
|
|
risk: string; |
|
|
severity: 'low' | 'medium' | 'high' | 'critical'; |
|
|
} |
|
|
|
|
|
export interface TriageResults { |
|
|
level: 'routine' | 'urgent' | 'emergency'; |
|
|
reasoning: string; |
|
|
confidence: number; |
|
|
red_flags: RedFlag[]; |
|
|
next_steps: string[]; |
|
|
} |
|
|
|
|
|
export interface GuidelineResults { |
|
|
query: string; |
|
|
guidelines: Array<{ |
|
|
title: string; |
|
|
content: string; |
|
|
source: string; |
|
|
relevance_score: number; |
|
|
url?: string; |
|
|
}>; |
|
|
} |
|
|
|
|
|
|
|
|
export type ToolResults = CVResults | TriageResults | GuidelineResults | Record<string, any>; |
|
|
|
|
|
|
|
|
export interface ActionCompleteMessage extends BaseMessage { |
|
|
type: 'action_complete'; |
|
|
tool_name: string; |
|
|
duration_ms: number; |
|
|
results: ToolResults; |
|
|
} |
|
|
|
|
|
|
|
|
export interface ActionErrorMessage extends BaseMessage { |
|
|
type: 'action_error'; |
|
|
tool_name: string; |
|
|
error_code: string; |
|
|
error_message: string; |
|
|
duration_ms: number; |
|
|
} |
|
|
|
|
|
|
|
|
export interface ObservationMessage extends BaseMessage { |
|
|
type: 'observation'; |
|
|
tool_name: string; |
|
|
findings: any; |
|
|
confidence: number; |
|
|
} |
|
|
|
|
|
|
|
|
export interface FinalAnswerMessage extends BaseMessage { |
|
|
type: 'final_answer'; |
|
|
result: { |
|
|
triage_level: string; |
|
|
recommendation: { |
|
|
action: string; |
|
|
timeframe: string; |
|
|
home_care_advice: string; |
|
|
warning_signs: string; |
|
|
}; |
|
|
red_flags: RedFlag[]; |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
export interface ErrorMessage extends BaseMessage { |
|
|
type: 'error'; |
|
|
code: string; |
|
|
message: string; |
|
|
} |
|
|
|
|
|
|
|
|
export type WebSocketMessage = |
|
|
| ThoughtMessage |
|
|
| ActionStartMessage |
|
|
| ActionCompleteMessage |
|
|
| ActionErrorMessage |
|
|
| ObservationMessage |
|
|
| FinalAnswerMessage |
|
|
| ErrorMessage; |
|
|
|
|
|
|
|
|
export const TOOL_DISPLAY_NAMES: Record<string, string> = { |
|
|
derm_cv: 'Dermatology CV Analysis', |
|
|
eye_cv: 'Eye Condition Analysis', |
|
|
wound_cv: 'Wound Assessment', |
|
|
triage_rules: 'Triage Classification', |
|
|
guideline_retrieval: 'Medical Guidelines', |
|
|
rag_query: 'Medical Knowledge Retrieval', |
|
|
}; |
|
|
|