Skip to content

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));
Parameter Type
stream AsyncIterable<ProviderChunk>

Promise<Turn>

overload when a tool call ends the stream with no name. Whatever the stream itself throws passes through unchanged.