| 76 | } |
| 77 | |
| 78 | function initFingerprint(req: Record<string, unknown>): string { |
| 79 | const tools = req.tools as Array<{ name?: string }> | undefined |
| 80 | const system = req.system as unknown[] | string | undefined |
| 81 | const sysLen = |
| 82 | typeof system === 'string' |
| 83 | ? system.length |
| 84 | : Array.isArray(system) |
| 85 | ? system.reduce( |
| 86 | (n: number, b) => n + ((b as { text?: string }).text?.length ?? 0), |
| 87 | 0, |
| 88 | ) |
| 89 | : 0 |
| 90 | const toolNames = tools?.map(t => t.name ?? '').join(',') ?? '' |
| 91 | return `${req.model}|${toolNames}|${sysLen}` |
| 92 | } |
| 93 | |
| 94 | function dumpRequest( |
| 95 | body: string, |