collectTurn
function collectTurn(stream): Promise<Turn>;Defined in: core/src/turn.ts:49
Drain one turn into the assistant message it produced, plus its usage, finish reason and source.
const turn = await collectTurn(provider.createStream(history, tools));history.push(turn.message);for (const call of turn.message.toolCalls ?? []) history.push(await run(call));Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
stream |
AsyncIterable<ProviderChunk> |
Returns
Section titled “Returns”Promise<Turn>
Throws
Section titled “Throws”overload when a tool call ends the stream with no
name. Whatever the stream itself throws passes through unchanged.