(delta: string, metadata: OpenRouterReasoningInfo | undefined = undefined)
| 766 | // Reasoning Parts |
| 767 | |
| 768 | const emitReasoningPart = (delta: string, metadata: OpenRouterReasoningInfo | undefined = undefined) => { |
| 769 | // End in-progress text part if present before starting reasoning |
| 770 | if (Predicate.isNotUndefined(activeTextId)) { |
| 771 | parts.push({ |
| 772 | type: "text-end", |
| 773 | id: activeTextId |
| 774 | }) |
| 775 | activeTextId = undefined |
| 776 | } |
| 777 | // Start a new reasoning part if necessary |
| 778 | if (Predicate.isUndefined(activeReasoningId)) { |
| 779 | activeReasoningId = (idCounter++).toString() |
| 780 | parts.push({ |
| 781 | type: "reasoning-start", |
| 782 | id: activeReasoningId, |
| 783 | metadata: { openrouter: metadata } |
| 784 | }) |
| 785 | } |
| 786 | // Emit the reasoning delta |
| 787 | parts.push({ |
| 788 | type: "reasoning-delta", |
| 789 | id: activeReasoningId, |
| 790 | delta, |
| 791 | metadata: { openrouter: metadata } |
| 792 | }) |
| 793 | } |
| 794 | |
| 795 | if (Predicate.isNotNullable(delta?.reasoning_details) && delta.reasoning_details.length > 0) { |
| 796 | for (const detail of delta.reasoning_details) { |
no test coverage detected