Files
deepseek-harness/website/zh-CN/api/harness/llm.md
T
lintianle efba9fab0a website: generate the API reference from source (cordis + all 15 harness services)
scripts/gen-website-api.ts renders website/zh-CN/api/{cordis,harness}/* and the
api-sidebar.json fragment the VitePress config imports, so pages and navigation
can never drift from the code: signatures, @param/@returns prose, dispatch
modes, and GitHub source links are extracted, never transcribed, and the
generator hard-errors on any rendered member missing docs. verify-website-api
(doc-sync + run-gates) is the freshness gate.

Replaces the hand-written zh api pages (7 pages covering 7 of 15 services,
with phantom APIs: Context.current/Context.events, agent/post-step, tool/call,
compact/*, llm/pre-request none of which exist) with generated English
references: 5 cordis pages, 15 per-service pages, and a 35-event catalog
grouped by scope. The hand-written hub api/index.md stays and now indexes the
full surface; zh for these pages arrives with the unified translation flow.
2026-07-16 18:13:34 +08:00

1.8 KiB

ctx.llm

LlmService — provided by @deepseek-ai/dsh-llm.

The abstract llm service: an adapter registry plus a streaming model-call surface, interceptable via the llm/stream waterfall.

Source

ctx.llm.registerAdapter(models, adapter)

registerAdapter(models: string[], adapter: LlmAdapter): () => void

Register an adapter for the given model names. Throws LlmError with code DUPLICATE_ADAPTER if any model already has an adapter (all-or-nothing). Disposed with the fiber.

  • models — every model name this adapter should serve.
  • adapter — the adapter that streams calls for those models.

Returns the disposer that unregisters all of them.

Source

ctx.llm.models()

models(): string[]

Model names with a registered adapter.

Returns the registered names, in registration order.

Source

ctx.llm.stream(options)

stream(options: GenerateOptions): AsyncIterable<StreamChunk>

Stream one model call as raw chunks (token-level deltas). Throws LlmError with code NO_ADAPTER if no adapter is registered for options.model. Dispatches through the llm/stream waterfall.

  • options — the full request; options.model selects the adapter.

Returns the chunk stream, possibly wrapped by llm/stream listeners.

Source