File size: 3,970 Bytes
375924d
56a15bc
375924d
9a82bce
ce51e88
 
9a82bce
 
 
 
ce51e88
375924d
 
 
 
c269c95
 
375924d
8539a00
ce51e88
948a968
ce51e88
375924d
 
 
 
 
 
 
 
 
535a98d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375924d
 
 
 
 
 
 
ce51e88
535a98d
 
ce51e88
 
 
 
 
 
375924d
 
 
 
 
 
 
 
 
 
f5e9ec3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690c106
 
 
 
 
 
 
 
 
 
 
 
f5e9ec3
 
 
 
 
 
 
690c106
 
df78c68
 
 
 
 
 
 
 
 
 
 
 
375924d
 
 
 
df78c68
375924d
 
 
 
 
ed5dd6f
ce51e88
690c106
375924d
 
 
 
 
 
 
ed5dd6f
ce51e88
 
 
690c106
df78c68
 
 
 
 
 
375924d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
export type Affect = "HAPPY" | "FRUSTRATED" | "NEUTRAL" | "SURPRISED";
export type GestureName = "THUMBS_UP" | "THUMBS_DOWN" | "POINTING_UP" | "CLOSED_FIST" | "OPEN_PALM" | "VICTORY" | "I_LOVE_YOU";
export type MemoryBucket = "family" | "medical" | "hobbies" | "daily_routine" | "social";
export type HeadSignal = "HEAD_SHAKE" | "HEAD_NOD" | "HEAD_NOD_DISSATISFIED";

export interface HeadDebug {
  pitch: number;     // degrees — nod angle
  yaw: number;       // degrees — shake angle
  roll: number;      // degrees — tilt angle
  crossings: number; // yaw direction reversals in current window
}

export interface SensingState {
  affect: Affect | null;
  gestureTag: GestureName | null;
  gazeZone: MemoryBucket | null;   // current zone (updates every frame)
  gazeBucket: MemoryBucket | null; // fired bucket (only after dwell completes)
  airWrittenText: string;
  airWritingActive: boolean;
  headSignal: HeadSignal | null;
  headCalibrated: boolean;
  headDebug: HeadDebug;
}

export interface Persona {
  id: string;
  name: string;
  condition: string;
  style: string;
}

export type ResolvedSource =
  | "voice_only"
  | "air_only"
  | "agree"
  | "conflict_air"
  | "conflict_voice"
  | "none";

export interface ResolvedIntent {
  text: string;
  source: ResolvedSource;
  voice_text: string | null;
  air_text: string | null;
}

export interface ChatRequest {
  user_id: string;
  query: string;
  affect_override: Affect | null;
  gesture_tag: GestureName | null;
  gaze_bucket: MemoryBucket | null;
  air_written_text: string | null;
  head_signal?: HeadSignal | null;
  voice_text?: string | null;
  resolved_intent?: ResolvedIntent | null;
}

export interface TurnaroundRequest {
  user_id: string;
  turn_id?: number;
  head_signal?: HeadSignal | null;
}

export interface LatencyLog {
  t_sensing: number;
  t_intent: number;
  t_retrieval: number;
  t_generation: number;
  t_total: number;
}

export interface EvalExplainAffect {
  target: string;
  pos_words: number;
  neg_words: number;
  sentiment: number;
}

export interface EvalExplainGesture {
  tag: string;
  has_pattern: boolean;
  matched: boolean | null;
}

export interface EvalExplainGaze {
  bucket: string;
  matched_chunks: number;
  total_chunks: number;
}

export interface EvalExplain {
  affect?: EvalExplainAffect;
  gesture?: EvalExplainGesture;
  gaze?: EvalExplainGaze;
}

export interface EvalScores {
  groundedness: number;
  hallucination_rate: number;
  no_evidence: boolean;
  t_total_s: number;
  slo_target_s: number;
  slo_passed: boolean;
  slo_margin_s: number;
  multimodal_alignment: number;
  affect_alignment: number;
  gesture_alignment: number;
  gaze_alignment: number;
  sentences_total?: number;
  sentences_grounded?: number;
  nli_threshold?: number;
  relevance?: number;
  n_candidates?: number;
  candidate_diversity?: number;
  explain?: EvalExplain;
}

export type CandidateStrategy =
  | "broad"
  | "focused"
  | "serendipitous"
  | "side_index";

export interface Candidate {
  text: string;
  strategy: CandidateStrategy | string;
  grounded_buckets: string[];
}

export interface ChatResponse {
  user_id: string;
  query: string;
  response: string;
  candidates: Candidate[];
  affect: string;
  llm_tier: string;
  retrieval_mode: string;
  latency: LatencyLog;
  guardrail_passed: boolean;
  run_id: string | null;
  turn_id: number;
  eval_scores?: EvalScores | null;
}

export interface ChatMessage {
  role: "partner" | "aac_user";
  content: string;
  latency?: LatencyLog;
  affect?: string;
  runId?: string | null;
  turnId?: number;
  rephrased?: boolean;
  isTurnaround?: boolean;
  evalScores?: EvalScores | null;
  candidates?: Candidate[];
  // picked becomes true after the user clicks one — also locks in `content` to the picked text
  picked?: boolean;
  pickedIdx?: number;
  // Candidates from prior regeneration rounds — rendered struck-through above the active picker
  rejectedRounds?: Candidate[][];
}