221
result.quotaSnapshots = snapshots;
222
}
223
>
const contextAttribution = readContextAttribution(meta['contextAttribution']);
sessionState.ts
224
>
if (contextAttribution) {
225
result.contextAttribution = contextAttribution;
226
}
228
>
}
229
230
>
function readAutoModeResolvedInfo(value: unknown): IAutoModeResolvedInfo | undefined {
sessionState.ts
231
>
if (!value || typeof value !== 'object' || Array.isArray(value)) {
232
return undefined;
233
}
235
>
if (typeof raw['chosenModel'] !== 'string') {
236
return undefined;
237
}
238
>
const result: Mutable<IAutoModeResolvedInfo> = { chosenModel: raw['chosenModel'] };
sessionState.ts
239
>
const reasoningBucket = raw['reasoningBucket'];
240
>
if (reasoningBucket === 'low' || reasoningBucket === 'medium' || reasoningBucket === 'high') {
241
>
result.reasoningBucket = reasoningBucket;
242
>
}
243
>
const categoryScores = raw['categoryScores'];
244
>
if (categoryScores && typeof categoryScores === 'object' && !Array.isArray(categoryScores)) {
245
>
const scores: Record<string, number> = {};
246
>
for (const [category, score] of Object.entries(categoryScores as Record<string, unknown>)) {
247
>
if (typeof score === 'number') {
248
>
scores[category] = score;
249
>
}
250
>
}
251
>
result.categoryScores = scores;
252
>
}
253
>
if (typeof raw['predictedLabel'] === 'string') { result.predictedLabel = raw['predictedLabel']; }
254
>
if (typeof raw['confidence'] === 'number') { result.confidence = raw['confidence']; }
255
>
if (Array.isArray(raw['candidateModels']) && raw['candidateModels'].every(candidate => typeof candidate === 'string')) {
256
>
result.candidateModels = raw['candidateModels'];
257
>
}
258
>
return result;
259
>
}
260
261
>
function readContextAttribution(value: unknown): IContextAttributionData | undefined {
sessionState.ts
262
>
if (!value || typeof value !== 'object' || Array.isArray(value)) {
263
>
return undefined;
264
>
}
265
const raw = value as Record<string, unknown>;
266
>
if (typeof raw['totalTokens'] !== 'number' || !Array.isArray(raw['entries'])) {
sessionState.ts
267
return undefined;
268
}