@nemesis-oss/ollama-sdk 1.0.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,12 @@ interface ToolCall {
28
28
  interface Message {
29
29
  readonly role: Role;
30
30
  readonly content: string;
31
- readonly images?: readonly string[] | undefined;
31
+ /**
32
+ * Base64-encoded image strings, or raw `Uint8Array` image bytes. `Uint8Array` entries
33
+ * are base64-encoded automatically (see {@link encodeImage}) before the request reaches
34
+ * the wire — Ollama's REST API only ever accepts base64 strings.
35
+ */
36
+ readonly images?: readonly (string | Uint8Array)[] | undefined;
32
37
  readonly tool_calls?: readonly ToolCall[] | undefined;
33
38
  /** Set on a `role: 'tool'` message to identify which {@link ToolCall.id} this answers. */
34
39
  readonly tool_call_id?: string | undefined;
@@ -56,6 +61,21 @@ interface ToolDefinition {
56
61
  readonly function: ToolFunctionDefinition;
57
62
  }
58
63
  type FormatOption = 'json' | Record<string, unknown>;
64
+ /** One alternative token considered at a generated position, and its log probability. */
65
+ interface LogprobToken {
66
+ readonly token: string;
67
+ readonly logprob: number;
68
+ readonly bytes?: readonly number[] | undefined;
69
+ }
70
+ /**
71
+ * Log probability info for one generated token, returned when `logprobs: true` is set on
72
+ * a `/api/chat` or `/api/generate` request. `top_logprobs` holds the `top_logprobs` most
73
+ * likely alternative tokens considered at this position (see `top_logprobs` on
74
+ * {@link ChatRequestOptions}/{@link GenerateRequestOptions}).
75
+ */
76
+ interface Logprob extends LogprobToken {
77
+ readonly top_logprobs?: readonly LogprobToken[] | undefined;
78
+ }
59
79
  interface ModelOptions {
60
80
  readonly num_keep?: number | undefined;
61
81
  readonly seed?: number | undefined;
@@ -99,6 +119,10 @@ interface ChatRequestOptions extends RequestCancellationOptions {
99
119
  readonly stream?: boolean | undefined;
100
120
  readonly keep_alive?: string | number | undefined;
101
121
  readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
122
+ /** Whether to return log probabilities of the output tokens. See {@link ChatResponse.logprobs}. */
123
+ readonly logprobs?: boolean | undefined;
124
+ /** Number of most likely alternative tokens to return at each position. Requires `logprobs: true`. */
125
+ readonly top_logprobs?: number | undefined;
102
126
  }
103
127
  interface ChatResponse {
104
128
  readonly model: string;
@@ -112,6 +136,8 @@ interface ChatResponse {
112
136
  readonly prompt_eval_duration?: number | undefined;
113
137
  readonly eval_count?: number | undefined;
114
138
  readonly eval_duration?: number | undefined;
139
+ /** Present when the request set `logprobs: true`. */
140
+ readonly logprobs?: readonly Logprob[] | undefined;
115
141
  }
116
142
  interface GenerateRequestOptions extends RequestCancellationOptions {
117
143
  readonly model: string;
@@ -123,10 +149,19 @@ interface GenerateRequestOptions extends RequestCancellationOptions {
123
149
  readonly stream?: boolean | undefined;
124
150
  readonly raw?: boolean | undefined;
125
151
  readonly format?: FormatOption | undefined;
126
- readonly images?: readonly string[] | undefined;
152
+ /**
153
+ * Base64-encoded image strings, or raw `Uint8Array` image bytes. `Uint8Array` entries
154
+ * are base64-encoded automatically (see {@link encodeImage}) before the request reaches
155
+ * the wire — Ollama's REST API only ever accepts base64 strings.
156
+ */
157
+ readonly images?: readonly (string | Uint8Array)[] | undefined;
127
158
  readonly options?: ModelOptions | undefined;
128
159
  readonly keep_alive?: string | number | undefined;
129
160
  readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
161
+ /** Whether to return log probabilities of the output tokens. See {@link GenerateResponse.logprobs}. */
162
+ readonly logprobs?: boolean | undefined;
163
+ /** Number of most likely alternative tokens to return at each position. Requires `logprobs: true`. */
164
+ readonly top_logprobs?: number | undefined;
130
165
  }
131
166
  interface GenerateResponse {
132
167
  readonly model: string;
@@ -142,6 +177,8 @@ interface GenerateResponse {
142
177
  readonly eval_count?: number | undefined;
143
178
  readonly eval_duration?: number | undefined;
144
179
  readonly thinking?: string | undefined;
180
+ /** Present when the request set `logprobs: true`. */
181
+ readonly logprobs?: readonly Logprob[] | undefined;
145
182
  }
146
183
  interface EmbedRequestOptions extends RequestCancellationOptions {
147
184
  readonly model: string;
@@ -225,12 +262,29 @@ interface PushRequestOptions extends RequestCancellationOptions {
225
262
  }
226
263
  interface CreateRequestOptions extends RequestCancellationOptions {
227
264
  readonly model: string;
265
+ /**
266
+ * @deprecated Not part of the official `/api/create` REST payload — Ollama's server
267
+ * only ever accepted this in older client tooling that assembled a Modelfile string
268
+ * client-side. Use the discrete fields below instead (`from`, `files`, `adapters`,
269
+ * `template`, `system`, `parameters`, `license`, `messages`), which map 1:1 onto the
270
+ * documented Modelfile instructions and are validated server-side. Kept for backward
271
+ * compatibility with existing callers; not read by this SDK, but still forwarded as-is
272
+ * in the request body for any server/proxy that inspects it.
273
+ */
228
274
  readonly modelfile?: string | undefined;
229
275
  readonly stream?: boolean | undefined;
230
276
  readonly quantize?: string | undefined;
231
277
  readonly from?: string | undefined;
232
278
  readonly files?: Record<string, string> | undefined;
233
279
  readonly adapters?: Record<string, string> | undefined;
280
+ readonly template?: string | undefined;
281
+ readonly renderer?: string | undefined;
282
+ readonly parser?: string | undefined;
283
+ readonly license?: string | readonly string[] | undefined;
284
+ readonly system?: string | undefined;
285
+ /** Modelfile `PARAMETER` instructions, e.g. `{ temperature: 0.7, stop: ['\n'] }`. */
286
+ readonly parameters?: Record<string, unknown> | undefined;
287
+ readonly messages?: readonly Message[] | undefined;
234
288
  }
235
289
  interface DeleteRequestOptions extends RequestCancellationOptions {
236
290
  readonly model: string;
@@ -248,23 +302,45 @@ interface VersionResponse {
248
302
  interface PsResponse {
249
303
  readonly models: readonly ModelResponse[];
250
304
  }
305
+ /**
306
+ * `webSearch`/`webFetch` call Ollama's hosted web tools at `https://ollama.com` — a
307
+ * fixed cloud service, unrelated to any locally-configured `baseUrl`/`endpoints` — and
308
+ * require an Ollama account API key (`apiKey`/`OLLAMA_API_KEY`). See
309
+ * {@link OllamaClient.webSearch}.
310
+ */
251
311
  interface WebSearchRequestOptions extends RequestCancellationOptions {
252
312
  readonly query: string;
313
+ /** Max results to return (server default 5, max 10). */
314
+ readonly max_results?: number | undefined;
315
+ /**
316
+ * @deprecated Not a field the Ollama web search API recognizes (`max_results` is).
317
+ * Kept for backward compatibility with earlier (non-functional) versions of this
318
+ * method; mapped to `max_results` when `max_results` itself isn't set.
319
+ */
253
320
  readonly count?: number | undefined;
254
321
  }
255
322
  interface WebSearchResult {
256
323
  readonly title: string;
257
324
  readonly url: string;
258
- readonly snippet: string;
325
+ readonly content: string;
326
+ /**
327
+ * @deprecated Not a field the Ollama web search API returns (`content` is) — kept, and
328
+ * populated by the SDK as a mirror of `content`, for backward compatibility with
329
+ * earlier (non-functional, wrong-endpoint) versions of `webSearch`. Use `content`.
330
+ */
331
+ readonly snippet?: string | undefined;
259
332
  }
260
333
  interface WebSearchResponse {
261
334
  readonly results: readonly WebSearchResult[];
262
335
  }
336
+ /** See {@link WebSearchRequestOptions} — same fixed Ollama Cloud endpoint and auth. */
263
337
  interface WebFetchRequestOptions extends RequestCancellationOptions {
264
338
  readonly url: string;
265
339
  }
266
340
  interface WebFetchResponse {
341
+ readonly title?: string | undefined;
267
342
  readonly content: string;
343
+ readonly links?: readonly string[] | undefined;
268
344
  }
269
345
 
270
346
  /**
@@ -427,4 +503,4 @@ interface AppliedSkillResult {
427
503
  */
428
504
  declare function applySkill(skill: Skill, options: ApplySkillOptions): AppliedSkillResult;
429
505
 
430
- export { parseFrontmatter as $, type AnyTool as A, type Role as B, type ChatResponse as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateResponse as G, type Skill as H, type SkillFrontmatter as I, type SkillSummary as J, type ToolCallFunction as K, type ListResponse as L, type Message as M, type ToolExecutionContext as N, type ToolExecutionFailure as O, type ProgressResponse as P, type ToolExecutionSuccess as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ToolCall as T, type ToolFunctionDefinition as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ToolProperty as X, type ToolRegistryOptions as Y, type WebSearchResult as Z, applySkill as _, type ModelResponse as a, type ShowResponse as b, type PullRequestOptions as c, type PushRequestOptions as d, type CreateRequestOptions as e, type StatusResponse as f, type CopyRequestOptions as g, type PsResponse as h, type ChatRequestOptions as i, type GenerateRequestOptions as j, type EmbedResponse as k, type EmbeddingsRequestOptions as l, type EmbeddingsResponse as m, type WebSearchResponse as n, type WebFetchRequestOptions as o, type WebFetchResponse as p, type ToolHandler as q, type Tool as r, ToolRegistry as s, type ToolExecutionResult as t, type ModelOptions as u, type ToolDefinition as v, type AppliedSkillResult as w, type ApplySkillOptions as x, type ModelDetails as y, type ParsedFrontmatter as z };
506
+ export { type WebSearchResult as $, type AnyTool as A, type ModelDetails as B, type ChatResponse as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateResponse as G, type ParsedFrontmatter as H, type Role as I, type Skill as J, type SkillFrontmatter as K, type ListResponse as L, type Message as M, type SkillSummary as N, type ToolCallFunction as O, type ProgressResponse as P, type ToolExecutionContext as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ToolCall as T, type ToolExecutionFailure as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ToolExecutionSuccess as X, type ToolFunctionDefinition as Y, type ToolProperty as Z, type ToolRegistryOptions as _, type ModelResponse as a, applySkill as a0, parseFrontmatter as a1, type ShowResponse as b, type PullRequestOptions as c, type PushRequestOptions as d, type CreateRequestOptions as e, type StatusResponse as f, type CopyRequestOptions as g, type PsResponse as h, type ChatRequestOptions as i, type GenerateRequestOptions as j, type EmbedResponse as k, type EmbeddingsRequestOptions as l, type EmbeddingsResponse as m, type WebSearchResponse as n, type WebFetchRequestOptions as o, type WebFetchResponse as p, type ToolHandler as q, type Tool as r, ToolRegistry as s, type ToolExecutionResult as t, type ModelOptions as u, type ToolDefinition as v, type AppliedSkillResult as w, type ApplySkillOptions as x, type Logprob as y, type LogprobToken as z };
@@ -28,7 +28,12 @@ interface ToolCall {
28
28
  interface Message {
29
29
  readonly role: Role;
30
30
  readonly content: string;
31
- readonly images?: readonly string[] | undefined;
31
+ /**
32
+ * Base64-encoded image strings, or raw `Uint8Array` image bytes. `Uint8Array` entries
33
+ * are base64-encoded automatically (see {@link encodeImage}) before the request reaches
34
+ * the wire — Ollama's REST API only ever accepts base64 strings.
35
+ */
36
+ readonly images?: readonly (string | Uint8Array)[] | undefined;
32
37
  readonly tool_calls?: readonly ToolCall[] | undefined;
33
38
  /** Set on a `role: 'tool'` message to identify which {@link ToolCall.id} this answers. */
34
39
  readonly tool_call_id?: string | undefined;
@@ -56,6 +61,21 @@ interface ToolDefinition {
56
61
  readonly function: ToolFunctionDefinition;
57
62
  }
58
63
  type FormatOption = 'json' | Record<string, unknown>;
64
+ /** One alternative token considered at a generated position, and its log probability. */
65
+ interface LogprobToken {
66
+ readonly token: string;
67
+ readonly logprob: number;
68
+ readonly bytes?: readonly number[] | undefined;
69
+ }
70
+ /**
71
+ * Log probability info for one generated token, returned when `logprobs: true` is set on
72
+ * a `/api/chat` or `/api/generate` request. `top_logprobs` holds the `top_logprobs` most
73
+ * likely alternative tokens considered at this position (see `top_logprobs` on
74
+ * {@link ChatRequestOptions}/{@link GenerateRequestOptions}).
75
+ */
76
+ interface Logprob extends LogprobToken {
77
+ readonly top_logprobs?: readonly LogprobToken[] | undefined;
78
+ }
59
79
  interface ModelOptions {
60
80
  readonly num_keep?: number | undefined;
61
81
  readonly seed?: number | undefined;
@@ -99,6 +119,10 @@ interface ChatRequestOptions extends RequestCancellationOptions {
99
119
  readonly stream?: boolean | undefined;
100
120
  readonly keep_alive?: string | number | undefined;
101
121
  readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
122
+ /** Whether to return log probabilities of the output tokens. See {@link ChatResponse.logprobs}. */
123
+ readonly logprobs?: boolean | undefined;
124
+ /** Number of most likely alternative tokens to return at each position. Requires `logprobs: true`. */
125
+ readonly top_logprobs?: number | undefined;
102
126
  }
103
127
  interface ChatResponse {
104
128
  readonly model: string;
@@ -112,6 +136,8 @@ interface ChatResponse {
112
136
  readonly prompt_eval_duration?: number | undefined;
113
137
  readonly eval_count?: number | undefined;
114
138
  readonly eval_duration?: number | undefined;
139
+ /** Present when the request set `logprobs: true`. */
140
+ readonly logprobs?: readonly Logprob[] | undefined;
115
141
  }
116
142
  interface GenerateRequestOptions extends RequestCancellationOptions {
117
143
  readonly model: string;
@@ -123,10 +149,19 @@ interface GenerateRequestOptions extends RequestCancellationOptions {
123
149
  readonly stream?: boolean | undefined;
124
150
  readonly raw?: boolean | undefined;
125
151
  readonly format?: FormatOption | undefined;
126
- readonly images?: readonly string[] | undefined;
152
+ /**
153
+ * Base64-encoded image strings, or raw `Uint8Array` image bytes. `Uint8Array` entries
154
+ * are base64-encoded automatically (see {@link encodeImage}) before the request reaches
155
+ * the wire — Ollama's REST API only ever accepts base64 strings.
156
+ */
157
+ readonly images?: readonly (string | Uint8Array)[] | undefined;
127
158
  readonly options?: ModelOptions | undefined;
128
159
  readonly keep_alive?: string | number | undefined;
129
160
  readonly think?: boolean | 'low' | 'medium' | 'high' | 'max' | undefined;
161
+ /** Whether to return log probabilities of the output tokens. See {@link GenerateResponse.logprobs}. */
162
+ readonly logprobs?: boolean | undefined;
163
+ /** Number of most likely alternative tokens to return at each position. Requires `logprobs: true`. */
164
+ readonly top_logprobs?: number | undefined;
130
165
  }
131
166
  interface GenerateResponse {
132
167
  readonly model: string;
@@ -142,6 +177,8 @@ interface GenerateResponse {
142
177
  readonly eval_count?: number | undefined;
143
178
  readonly eval_duration?: number | undefined;
144
179
  readonly thinking?: string | undefined;
180
+ /** Present when the request set `logprobs: true`. */
181
+ readonly logprobs?: readonly Logprob[] | undefined;
145
182
  }
146
183
  interface EmbedRequestOptions extends RequestCancellationOptions {
147
184
  readonly model: string;
@@ -225,12 +262,29 @@ interface PushRequestOptions extends RequestCancellationOptions {
225
262
  }
226
263
  interface CreateRequestOptions extends RequestCancellationOptions {
227
264
  readonly model: string;
265
+ /**
266
+ * @deprecated Not part of the official `/api/create` REST payload — Ollama's server
267
+ * only ever accepted this in older client tooling that assembled a Modelfile string
268
+ * client-side. Use the discrete fields below instead (`from`, `files`, `adapters`,
269
+ * `template`, `system`, `parameters`, `license`, `messages`), which map 1:1 onto the
270
+ * documented Modelfile instructions and are validated server-side. Kept for backward
271
+ * compatibility with existing callers; not read by this SDK, but still forwarded as-is
272
+ * in the request body for any server/proxy that inspects it.
273
+ */
228
274
  readonly modelfile?: string | undefined;
229
275
  readonly stream?: boolean | undefined;
230
276
  readonly quantize?: string | undefined;
231
277
  readonly from?: string | undefined;
232
278
  readonly files?: Record<string, string> | undefined;
233
279
  readonly adapters?: Record<string, string> | undefined;
280
+ readonly template?: string | undefined;
281
+ readonly renderer?: string | undefined;
282
+ readonly parser?: string | undefined;
283
+ readonly license?: string | readonly string[] | undefined;
284
+ readonly system?: string | undefined;
285
+ /** Modelfile `PARAMETER` instructions, e.g. `{ temperature: 0.7, stop: ['\n'] }`. */
286
+ readonly parameters?: Record<string, unknown> | undefined;
287
+ readonly messages?: readonly Message[] | undefined;
234
288
  }
235
289
  interface DeleteRequestOptions extends RequestCancellationOptions {
236
290
  readonly model: string;
@@ -248,23 +302,45 @@ interface VersionResponse {
248
302
  interface PsResponse {
249
303
  readonly models: readonly ModelResponse[];
250
304
  }
305
+ /**
306
+ * `webSearch`/`webFetch` call Ollama's hosted web tools at `https://ollama.com` — a
307
+ * fixed cloud service, unrelated to any locally-configured `baseUrl`/`endpoints` — and
308
+ * require an Ollama account API key (`apiKey`/`OLLAMA_API_KEY`). See
309
+ * {@link OllamaClient.webSearch}.
310
+ */
251
311
  interface WebSearchRequestOptions extends RequestCancellationOptions {
252
312
  readonly query: string;
313
+ /** Max results to return (server default 5, max 10). */
314
+ readonly max_results?: number | undefined;
315
+ /**
316
+ * @deprecated Not a field the Ollama web search API recognizes (`max_results` is).
317
+ * Kept for backward compatibility with earlier (non-functional) versions of this
318
+ * method; mapped to `max_results` when `max_results` itself isn't set.
319
+ */
253
320
  readonly count?: number | undefined;
254
321
  }
255
322
  interface WebSearchResult {
256
323
  readonly title: string;
257
324
  readonly url: string;
258
- readonly snippet: string;
325
+ readonly content: string;
326
+ /**
327
+ * @deprecated Not a field the Ollama web search API returns (`content` is) — kept, and
328
+ * populated by the SDK as a mirror of `content`, for backward compatibility with
329
+ * earlier (non-functional, wrong-endpoint) versions of `webSearch`. Use `content`.
330
+ */
331
+ readonly snippet?: string | undefined;
259
332
  }
260
333
  interface WebSearchResponse {
261
334
  readonly results: readonly WebSearchResult[];
262
335
  }
336
+ /** See {@link WebSearchRequestOptions} — same fixed Ollama Cloud endpoint and auth. */
263
337
  interface WebFetchRequestOptions extends RequestCancellationOptions {
264
338
  readonly url: string;
265
339
  }
266
340
  interface WebFetchResponse {
341
+ readonly title?: string | undefined;
267
342
  readonly content: string;
343
+ readonly links?: readonly string[] | undefined;
268
344
  }
269
345
 
270
346
  /**
@@ -427,4 +503,4 @@ interface AppliedSkillResult {
427
503
  */
428
504
  declare function applySkill(skill: Skill, options: ApplySkillOptions): AppliedSkillResult;
429
505
 
430
- export { parseFrontmatter as $, type AnyTool as A, type Role as B, type ChatResponse as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateResponse as G, type Skill as H, type SkillFrontmatter as I, type SkillSummary as J, type ToolCallFunction as K, type ListResponse as L, type Message as M, type ToolExecutionContext as N, type ToolExecutionFailure as O, type ProgressResponse as P, type ToolExecutionSuccess as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ToolCall as T, type ToolFunctionDefinition as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ToolProperty as X, type ToolRegistryOptions as Y, type WebSearchResult as Z, applySkill as _, type ModelResponse as a, type ShowResponse as b, type PullRequestOptions as c, type PushRequestOptions as d, type CreateRequestOptions as e, type StatusResponse as f, type CopyRequestOptions as g, type PsResponse as h, type ChatRequestOptions as i, type GenerateRequestOptions as j, type EmbedResponse as k, type EmbeddingsRequestOptions as l, type EmbeddingsResponse as m, type WebSearchResponse as n, type WebFetchRequestOptions as o, type WebFetchResponse as p, type ToolHandler as q, type Tool as r, ToolRegistry as s, type ToolExecutionResult as t, type ModelOptions as u, type ToolDefinition as v, type AppliedSkillResult as w, type ApplySkillOptions as x, type ModelDetails as y, type ParsedFrontmatter as z };
506
+ export { type WebSearchResult as $, type AnyTool as A, type ModelDetails as B, type ChatResponse as C, type DeleteRequestOptions as D, type EmbedRequestOptions as E, type FormatOption as F, type GenerateResponse as G, type ParsedFrontmatter as H, type Role as I, type Skill as J, type SkillFrontmatter as K, type ListResponse as L, type Message as M, type SkillSummary as N, type ToolCallFunction as O, type ProgressResponse as P, type ToolExecutionContext as Q, type RequestCancellationOptions as R, type ShowRequestOptions as S, type ToolCall as T, type ToolExecutionFailure as U, type VersionResponse as V, type WebSearchRequestOptions as W, type ToolExecutionSuccess as X, type ToolFunctionDefinition as Y, type ToolProperty as Z, type ToolRegistryOptions as _, type ModelResponse as a, applySkill as a0, parseFrontmatter as a1, type ShowResponse as b, type PullRequestOptions as c, type PushRequestOptions as d, type CreateRequestOptions as e, type StatusResponse as f, type CopyRequestOptions as g, type PsResponse as h, type ChatRequestOptions as i, type GenerateRequestOptions as j, type EmbedResponse as k, type EmbeddingsRequestOptions as l, type EmbeddingsResponse as m, type WebSearchResponse as n, type WebFetchRequestOptions as o, type WebFetchResponse as p, type ToolHandler as q, type Tool as r, ToolRegistry as s, type ToolExecutionResult as t, type ModelOptions as u, type ToolDefinition as v, type AppliedSkillResult as w, type ApplySkillOptions as x, type Logprob as y, type LogprobToken as z };