feat(llm): route adapters by provider

This commit is contained in:
Yichen Jiang
2026-07-14 21:57:52 +08:00
parent a0359bc4a9
commit e547980d77
218 changed files with 2605 additions and 1844 deletions

View File

@@ -36,6 +36,7 @@ export class BlockAssembler {
private order: number[] = []
private _usage: TokenUsage | undefined
private _finish: FinishReason | undefined
private _replayState: unknown
/**
* Feed one chunk. Returns the completed block when the chunk closes one
@@ -87,6 +88,7 @@ export class BlockAssembler {
}
case 'finish': {
this._finish = chunk.reason
this._replayState = chunk.replayState
return
}
default: return assertNever(chunk, 'BlockAssembler.push')
@@ -144,6 +146,11 @@ export class BlockAssembler {
return this._finish ?? { kind: 'stop' }
}
/** Adapter-private replay state from the terminal finish chunk, if any. */
get replayState(): unknown {
return this._replayState
}
/**
* The assembled assistant message.
* @returns an assistant-role message over `blocks()` (same open-block assembly rules).