refactor(llm): clarify request context immutability
This commit is contained in:
@@ -96,6 +96,8 @@ export const StatsLine = memo(function StatsLine({ useSession, useProjection }:
|
|||||||
const cacheHit = cacheHitPercent(usage)
|
const cacheHit = cacheHitPercent(usage)
|
||||||
if (cacheHit !== null) parts.push(`cache hit ${cacheHit}%`)
|
if (cacheHit !== null) parts.push(`cache hit ${cacheHit}%`)
|
||||||
}
|
}
|
||||||
|
// contextPercent validates both fields; repeat the capacity guard so that
|
||||||
|
// TypeScript carries the same refinement into the formatting branch.
|
||||||
parts.push(context === null || modelRequest?.contextWindow === undefined
|
parts.push(context === null || modelRequest?.contextWindow === undefined
|
||||||
? 'context unknown'
|
? 'context unknown'
|
||||||
: `context ${context}% of ${formatMetricTokens(modelRequest.contextWindow)}`)
|
: `context ${context}% of ${formatMetricTokens(modelRequest.contextWindow)}`)
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ export class LlmService extends Service {
|
|||||||
const resolvedConfig = deepFreeze(structuredClone(resolved.config))
|
const resolvedConfig = deepFreeze(structuredClone(resolved.config))
|
||||||
const context = resolved.context === undefined
|
const context = resolved.context === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: Object.freeze(structuredClone(resolved.context))
|
: deepFreeze(structuredClone(resolved.context))
|
||||||
let dispatched = false
|
let dispatched = false
|
||||||
return Object.freeze({
|
return Object.freeze({
|
||||||
config: resolvedConfig,
|
config: resolvedConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user