* Builds a standard ProviderResponse from a completed deep research interaction.
(
content: string,
model: string,
usage: {
inputTokens: number
outputTokens: number
reasoningTokens: number
totalTokens: number
},
providerStartTime: number,
providerStartTimeISO: string,
interactionId?: string
)
| 519 | * Builds a standard ProviderResponse from a completed deep research interaction. |
| 520 | */ |
| 521 | function buildDeepResearchResponse( |
| 522 | content: string, |
| 523 | model: string, |
| 524 | usage: { |
| 525 | inputTokens: number |
| 526 | outputTokens: number |
| 527 | reasoningTokens: number |
| 528 | totalTokens: number |
| 529 | }, |
| 530 | providerStartTime: number, |
| 531 | providerStartTimeISO: string, |
| 532 | interactionId?: string |
| 533 | ): ProviderResponse { |
| 534 | const providerEndTime = Date.now() |
| 535 | const duration = providerEndTime - providerStartTime |
| 536 | |
| 537 | return { |
| 538 | content, |
| 539 | model, |
| 540 | tokens: { |
| 541 | input: usage.inputTokens, |
| 542 | output: usage.outputTokens, |
| 543 | total: usage.totalTokens, |
| 544 | }, |
| 545 | timing: { |
| 546 | startTime: providerStartTimeISO, |
| 547 | endTime: new Date(providerEndTime).toISOString(), |
| 548 | duration, |
| 549 | modelTime: duration, |
| 550 | toolsTime: 0, |
| 551 | firstResponseTime: duration, |
| 552 | iterations: 1, |
| 553 | timeSegments: [ |
| 554 | { |
| 555 | type: 'model', |
| 556 | name: 'Deep research', |
| 557 | startTime: providerStartTime, |
| 558 | endTime: providerEndTime, |
| 559 | duration, |
| 560 | }, |
| 561 | ], |
| 562 | }, |
| 563 | cost: calculateCost(model, usage.inputTokens, usage.outputTokens), |
| 564 | interactionId, |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * Creates a ReadableStream from a deep research streaming interaction. |
no test coverage detected