( parsed: Record<string, any>, keys: string[], fallback: string[], )
| 14151 | } |
| 14152 | |
| 14153 | function readAssistantStringArrayField( |
| 14154 | parsed: Record<string, any>, |
| 14155 | keys: string[], |
| 14156 | fallback: string[], |
| 14157 | ): string[] { |
| 14158 | for (const key of keys) { |
| 14159 | if (!Object.prototype.hasOwnProperty.call(parsed, key)) { |
| 14160 | continue; |
| 14161 | } |
| 14162 | if (!Array.isArray(parsed[key])) { |
| 14163 | return []; |
| 14164 | } |
| 14165 | const values = new Set<string>(); |
| 14166 | for (const value of parsed[key]) { |
| 14167 | const normalized = compactWhitespace(value); |
| 14168 | if (normalized) { |
| 14169 | values.add(normalized.replace(/^#/u, '')); |
| 14170 | } |
| 14171 | } |
| 14172 | return [...values]; |
| 14173 | } |
| 14174 | return [...fallback]; |
| 14175 | } |
| 14176 | |
| 14177 | function clampAssistantConfidence(value: number): number { |
| 14178 | if (!Number.isFinite(value)) { |
no test coverage detected