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