mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
65 lines
2.5 KiB
Markdown
65 lines
2.5 KiB
Markdown
<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
|
|
|
|
# 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](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/llm/llm/src/index.ts#L94)
|
|
|
|
### ctx.llm.registerAdapter(providers, adapter)
|
|
|
|
```ts website-api
|
|
registerAdapter(providers: string[], adapter: LlmAdapter): () => void
|
|
```
|
|
|
|
Register an adapter for the given provider routes. Throws `LlmError` with code `DUPLICATE_ADAPTER` if any provider already has an adapter (all-or-nothing). Disposed with the fiber.
|
|
|
|
- `providers` — every provider route this adapter should serve.
|
|
- `adapter` — the adapter that streams calls for those providers.
|
|
|
|
**Returns** the disposer that unregisters all of them.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/llm/llm/src/index.ts#L109)
|
|
|
|
### ctx.llm.listProviders()
|
|
|
|
```ts website-api
|
|
listProviders(): LlmProviderInfo[]
|
|
```
|
|
|
|
Describe provider routes with a registered adapter.
|
|
|
|
**Returns** detached provider metadata in registration order.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/llm/llm/src/index.ts#L140)
|
|
|
|
### ctx.llm.listModels(provider)
|
|
|
|
```ts website-api
|
|
async listModels(provider: string): Promise<LlmModelInfo[]>
|
|
```
|
|
|
|
Discover models advertised by one registered provider. Catalog membership is advisory and never changes routing or request validation.
|
|
|
|
- `provider` — registered provider route to inspect.
|
|
|
|
**Returns** detached model metadata in adapter-preferred order.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/llm/llm/src/index.ts#L150)
|
|
|
|
### ctx.llm.stream(options)
|
|
|
|
```ts website-api
|
|
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.provider`. Replay state is retained only when the same adapter instance owns its historical provider and the target provider. Dispatches through the `llm/stream` waterfall.
|
|
|
|
- `options` — the full request; `options.provider` selects the adapter.
|
|
|
|
**Returns** the chunk stream, possibly wrapped by `llm/stream` listeners.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/llm/llm/src/index.ts#L208)
|