* Extract text from first user message for fingerprint computation.
(messages: MessageParam[])
| 101 | * Extract text from first user message for fingerprint computation. |
| 102 | */ |
| 103 | function extractFirstUserMessageText(messages: MessageParam[]): string { |
| 104 | const firstUserMessage = messages.find(m => m.role === 'user') |
| 105 | if (!firstUserMessage) return '' |
| 106 | |
| 107 | const content = firstUserMessage.content |
| 108 | if (typeof content === 'string') return content |
| 109 | |
| 110 | // Array of content blocks - find first text block |
| 111 | const textBlock = content.find(block => block.type === 'text') |
| 112 | return textBlock?.type === 'text' ? textBlock.text : '' |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Extract system prompt text from the `system` option. |