Api
Client helpers for the provider-agnostic LLM API.
Functions¶
apiDeleteTemplate()¶
Defined in: src/shared/llm/api.ts:76
Deletes the active profile's LLM template (DELETE /profiles/template).
Returns¶
Promise\<void>
Resolves when deleted.
apiGetTemplate()¶
Defined in: src/shared/llm/api.ts:40
Fetches the active profile's LLM template, or null when none is set.
Returns¶
Promise\<LlmTemplate | null>
The template, or null on 404.
apiListModels()¶
Defined in: src/shared/llm/api.ts:27
Lists the available models for a provider (/llm/models).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
provider |
string |
The provider id. |
Returns¶
Promise\<string[]>
The available model ids.
apiProviders()¶
Defined in: src/shared/llm/api.ts:16
Lists which LLM providers are usable in this deployment (/llm/providers).
Returns¶
The provider availability list.
apiUpsertTemplate()¶
Defined in: src/shared/llm/api.ts:58
Creates or updates the active profile's LLM template (POST /profiles/template).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
req |
{ model: string; prompt: string; srt_model?: string; srt_sys_msg?: string; sys_msg: string; } |
The template fields. |
req.model |
string |
The provider:model selector. |
req.prompt |
string |
The prompt template. |
req.srt_model? |
string |
- |
req.srt_sys_msg? |
string |
- |
req.sys_msg |
string |
The system message. |
Returns¶
The saved template.
formatModel()¶
Defined in: src/shared/llm/api.ts:151
Joins a provider + model name into a provider:model selector.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
provider |
string |
The provider id. |
name |
string |
The model name. |
Returns¶
string
The combined selector.
parseModel()¶
Defined in: src/shared/llm/api.ts:138
Splits a provider:model selector (provider defaults to openai).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
model |
string |
The selector. |
Returns¶
object
Provider + model name.
| Name | Type | Defined in |
|---|---|---|
name |
string |
src/shared/llm/api.ts:138 |
provider |
string |
src/shared/llm/api.ts:138 |
streamBreakdown()¶
Defined in: src/shared/llm/api.ts:89
Streams a word breakdown (/llm/breakdown): the structured focus word first,
then the explanation token by token.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
req |
{ focus: string; model: string; prompt?: string; sentence: string; sys_msg?: string; } |
The breakdown request. |
req.focus |
string |
- |
req.model |
string |
- |
req.prompt? |
string |
- |
req.sentence? |
string |
- |
req.sys_msg? |
string |
- |
handlers? |
{ onFocus: (focus) => void; onToken: (token) => void; } |
onFocus (once) + onToken (per chunk). |
handlers.onFocus? |
(focus) => void |
- |
handlers.onToken? |
(token) => void |
- |
signal? |
AbortSignal |
Aborts the stream. |
Returns¶
Promise\<void>
Resolves when the explanation finishes.
streamExplain()¶
Defined in: src/shared/llm/api.ts:124
Streams an explanation of a whole sentence (/llm/explain_sentence), token
by token.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
req |
{ model: string; prompt?: string; sentence: string; sys_msg?: string; } |
The explanation request. |
req.model |
string |
- |
req.prompt? |
string |
- |
req.sentence? |
string |
- |
req.sys_msg? |
string |
- |
handlers? |
{ onToken: (token) => void; } |
onToken (per chunk). |
handlers.onToken? |
(token) => void |
- |
signal? |
AbortSignal |
Aborts the stream. |
Returns¶
Promise\<void>
Resolves when the explanation finishes.