({rawChunk}: {rawChunk: any})
| 501 | * @returns The processed Chunk object. |
| 502 | */ |
| 503 | export const processChunk = ({rawChunk}: {rawChunk: any}): Chunk => { |
| 504 | if (rawChunk.choices[0]?.delta?.content) { |
| 505 | return {type: 'content', content: rawChunk.choices[0].delta.content}; |
| 506 | } |
| 507 | if ( |
| 508 | rawChunk.choices[0]?.delta?.tool_calls && |
| 509 | rawChunk.choices[0].delta.tool_calls.length > 0 |
| 510 | ) { |
| 511 | const toolCall = rawChunk.choices[0].delta.tool_calls[0]; |
| 512 | return {type: 'toolCall', toolCall}; |
| 513 | } |
| 514 | return {type: 'unknown', rawChunk}; |
| 515 | }; |
| 516 | |
| 517 | /** |
| 518 | * Checks if the given chunk is a ContentChunk. |
nothing calls this directly
no outgoing calls
no test coverage detected