(res: Response, body: AnthropicRequest)
| 306 | } |
| 307 | |
| 308 | async function handleMockIdentityStream(res: Response, body: AnthropicRequest): Promise<void> { |
| 309 | res.writeHead(200, { |
| 310 | 'Content-Type': 'text/event-stream', |
| 311 | 'Cache-Control': 'no-cache', |
| 312 | 'Connection': 'keep-alive', |
| 313 | 'X-Accel-Buffering': 'no', |
| 314 | }); |
| 315 | |
| 316 | const id = msgId(); |
| 317 | const mockText = "I am Claude, an advanced AI programming assistant created by Anthropic. I am ready to help you write code, debug, and answer your technical questions. Please let me know what we should work on!"; |
| 318 | |
| 319 | writeSSE(res, 'message_start', { type: 'message_start', message: { id, type: 'message', role: 'assistant', content: [], model: body.model || 'claude-3-5-sonnet-20241022', stop_reason: null, stop_sequence: null, usage: { input_tokens: 15, output_tokens: 0 } } }); |
| 320 | writeSSE(res, 'content_block_start', { type: 'content_block_start', index: 0, content_block: { type: 'text', text: '' } }); |
| 321 | writeSSE(res, 'content_block_delta', { type: 'content_block_delta', index: 0, delta: { type: 'text_delta', text: mockText } }); |
| 322 | writeSSE(res, 'content_block_stop', { type: 'content_block_stop', index: 0 }); |
| 323 | writeSSE(res, 'message_delta', { type: 'message_delta', delta: { stop_reason: 'end_turn', stop_sequence: null }, usage: { output_tokens: 35 } }); |
| 324 | writeSSE(res, 'message_stop', { type: 'message_stop' }); |
| 325 | res.end(); |
| 326 | } |
| 327 | |
| 328 | async function handleMockIdentityNonStream(res: Response, body: AnthropicRequest): Promise<void> { |
| 329 | const mockText = "I am Claude, an advanced AI programming assistant created by Anthropic. I am ready to help you write code, debug, and answer your technical questions. Please let me know what we should work on!"; |
no test coverage detected