@nemesis-oss/ollama-sdk 1.9.0 → 1.10.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.
- package/CHANGELOG.md +24 -0
- package/README.md +66 -1
- package/dist/{anthropic-5oYIRS6D.d.ts → anthropic-CPaoxeLX.d.ts} +1 -1
- package/dist/{anthropic-BIh45UXj.d.cts → anthropic-DuE8M6Tz.d.cts} +1 -1
- package/dist/{compose-DCVYMvOL.d.ts → compose-BQYXdpar.d.ts} +1 -1
- package/dist/{compose-Dj6FdF2n.d.cts → compose-lt-Qz3lI.d.cts} +1 -1
- package/dist/generated-api.d.cts +5 -5
- package/dist/generated-api.d.ts +5 -5
- package/dist/generated-runtime.d.cts +2 -2
- package/dist/generated-runtime.d.ts +2 -2
- package/dist/index.cjs +260 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +203 -9
- package/dist/index.d.ts +203 -9
- package/dist/index.js +256 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp-generated.d.cts +2 -2
- package/dist/mcp-generated.d.ts +2 -2
- package/dist/{runtime-C3rfpkZw.d.ts → runtime-BV9SK_cf.d.ts} +1 -1
- package/dist/{runtime-D2W9TfCJ.d.cts → runtime-BsdBbuOv.d.cts} +1 -1
- package/dist/skills.d.cts +3 -3
- package/dist/skills.d.ts +3 -3
- package/dist/{types-DVcX_zMp.d.cts → types-BtQexFpT.d.cts} +5 -2
- package/dist/{types-DVcX_zMp.d.ts → types-BtQexFpT.d.ts} +5 -2
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -4472,6 +4472,130 @@ function contextWarningMessage(check2, kind) {
|
|
|
4472
4472
|
return `${where}: estimated prompt size ${estimate} outright exceeds Ollama's conservative server-default context window (${OLLAMA_FALLBACK_CONTEXT_LENGTH}\u20134096 tokens when \`num_ctx\` is unset \u2014 model-dependent). Unless the model's default is larger, the server will silently truncate the top of the conversation \u2014 the model loses earlier turns with no error. Set \`options.num_ctx\` (or the client's \`defaultContextLength\`) to an explicit window to make truncation visible and controllable. Estimates are heuristic (\xB120\u201330%); see \`estimateTokens\`.`;
|
|
4473
4473
|
}
|
|
4474
4474
|
|
|
4475
|
+
// src/embed-batch.ts
|
|
4476
|
+
var DEFAULT_EMBED_BATCH_SIZE = 32;
|
|
4477
|
+
var DEFAULT_EMBED_CONCURRENCY = 3;
|
|
4478
|
+
function findOversizedEmbedInputs(input, contextLength) {
|
|
4479
|
+
const oversized = [];
|
|
4480
|
+
for (let index = 0; index < input.length; index++) {
|
|
4481
|
+
const text = input[index];
|
|
4482
|
+
if (text === void 0) continue;
|
|
4483
|
+
const estimate = estimateTokens(text);
|
|
4484
|
+
if (estimate > contextLength) {
|
|
4485
|
+
oversized.push({ index, estimate });
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4488
|
+
return oversized;
|
|
4489
|
+
}
|
|
4490
|
+
function embedBatchOverflowMessage(oversized, totalInputs, contextLength, truncateFalse) {
|
|
4491
|
+
const shown = oversized.slice(0, 5).map((entry) => `#${entry.index} (~${entry.estimate} tokens)`);
|
|
4492
|
+
const elided = oversized.length > 5 ? `, +${oversized.length - 5} more` : "";
|
|
4493
|
+
const outcome = truncateFalse ? "the server will reject them (`truncate: false`)" : "Ollama will silently truncate them, producing degraded vectors";
|
|
4494
|
+
return `embedBatch: ${oversized.length} of ${totalInputs} input strings exceed the ${contextLength}-token context window (${shown.join(", ")}${elided}). ${outcome}. Raise \`options.num_ctx\`, pre-split long inputs, or set \`truncate: true\` explicitly to acknowledge truncation.`;
|
|
4495
|
+
}
|
|
4496
|
+
function assertPositiveInteger(value, field) {
|
|
4497
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
4498
|
+
throw new OllamaClientError(
|
|
4499
|
+
`embedBatch: \`${field}\` must be a positive integer (got ${value}).`,
|
|
4500
|
+
{ code: "invalid_request" }
|
|
4501
|
+
);
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
async function batchEmbed(client, options) {
|
|
4505
|
+
const { model, input } = options;
|
|
4506
|
+
const batchSize = options.batchSize ?? DEFAULT_EMBED_BATCH_SIZE;
|
|
4507
|
+
const concurrency = options.concurrency ?? DEFAULT_EMBED_CONCURRENCY;
|
|
4508
|
+
assertPositiveInteger(batchSize, "batchSize");
|
|
4509
|
+
assertPositiveInteger(concurrency, "concurrency");
|
|
4510
|
+
if (input.length === 0) {
|
|
4511
|
+
return { model, embeddings: [], batchCount: 0 };
|
|
4512
|
+
}
|
|
4513
|
+
const batches = [];
|
|
4514
|
+
for (let start = 0; start < input.length; start += batchSize) {
|
|
4515
|
+
batches.push(input.slice(start, start + batchSize));
|
|
4516
|
+
}
|
|
4517
|
+
const embeddings = new Array(input.length);
|
|
4518
|
+
const controller = new AbortController();
|
|
4519
|
+
const propagateExternalAbort = () => {
|
|
4520
|
+
controller.abort(options.signal?.reason);
|
|
4521
|
+
};
|
|
4522
|
+
if (options.signal) {
|
|
4523
|
+
if (options.signal.aborted) {
|
|
4524
|
+
propagateExternalAbort();
|
|
4525
|
+
} else {
|
|
4526
|
+
options.signal.addEventListener("abort", propagateExternalAbort, { once: true });
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
let nextBatch = 0;
|
|
4530
|
+
let completedBatches = 0;
|
|
4531
|
+
let failure;
|
|
4532
|
+
const worker = async () => {
|
|
4533
|
+
for (; ; ) {
|
|
4534
|
+
if (controller.signal.aborted) {
|
|
4535
|
+
throw failure?.error ?? new OllamaAbortError("Embed batch aborted");
|
|
4536
|
+
}
|
|
4537
|
+
const batchIndex = nextBatch;
|
|
4538
|
+
nextBatch++;
|
|
4539
|
+
if (batchIndex >= batches.length) return;
|
|
4540
|
+
const batch = batches[batchIndex];
|
|
4541
|
+
if (!batch) return;
|
|
4542
|
+
try {
|
|
4543
|
+
const request = {
|
|
4544
|
+
model,
|
|
4545
|
+
input: batch,
|
|
4546
|
+
...options.truncate !== void 0 ? { truncate: options.truncate } : {},
|
|
4547
|
+
...options.dimensions !== void 0 ? { dimensions: options.dimensions } : {},
|
|
4548
|
+
...options.keep_alive !== void 0 ? { keep_alive: options.keep_alive } : {},
|
|
4549
|
+
...options.options !== void 0 ? { options: options.options } : {},
|
|
4550
|
+
...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
|
|
4551
|
+
signal: controller.signal
|
|
4552
|
+
};
|
|
4553
|
+
const response = await client.embed(request);
|
|
4554
|
+
if (response.embeddings.length !== batch.length) {
|
|
4555
|
+
throw new OllamaClientError(
|
|
4556
|
+
`embedBatch: server returned ${response.embeddings.length} embeddings for a batch of ${batch.length} inputs (batch ${batchIndex}).`,
|
|
4557
|
+
{ code: "invalid_response" }
|
|
4558
|
+
);
|
|
4559
|
+
}
|
|
4560
|
+
const offset = batchIndex * batchSize;
|
|
4561
|
+
for (let j = 0; j < batch.length; j++) {
|
|
4562
|
+
embeddings[offset + j] = response.embeddings[j];
|
|
4563
|
+
}
|
|
4564
|
+
completedBatches++;
|
|
4565
|
+
options.onBatchComplete?.(completedBatches, batches.length);
|
|
4566
|
+
} catch (error) {
|
|
4567
|
+
if (!failure) {
|
|
4568
|
+
failure = { error };
|
|
4569
|
+
controller.abort(error);
|
|
4570
|
+
throw error;
|
|
4571
|
+
}
|
|
4572
|
+
throw failure.error;
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
};
|
|
4576
|
+
try {
|
|
4577
|
+
const workerCount = Math.min(concurrency, batches.length);
|
|
4578
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
4579
|
+
} finally {
|
|
4580
|
+
if (options.signal) {
|
|
4581
|
+
options.signal.removeEventListener("abort", propagateExternalAbort);
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
for (let i = 0; i < embeddings.length; i++) {
|
|
4585
|
+
if (embeddings[i] === void 0) {
|
|
4586
|
+
throw new OllamaClientError(
|
|
4587
|
+
`embedBatch: internal invariant violated \u2014 no embedding produced for input #${i}.`,
|
|
4588
|
+
{ code: "invalid_response" }
|
|
4589
|
+
);
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
return {
|
|
4593
|
+
model,
|
|
4594
|
+
embeddings,
|
|
4595
|
+
batchCount: batches.length
|
|
4596
|
+
};
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4475
4599
|
// src/generated/api/operations.ts
|
|
4476
4600
|
var blobsOp = {
|
|
4477
4601
|
operationId: "blobs",
|
|
@@ -4996,6 +5120,14 @@ var OllamaClient = class {
|
|
|
4996
5120
|
contextWarningThreshold;
|
|
4997
5121
|
/** Configured overflow policy — `'warn'` (default) or `'throw'`. */
|
|
4998
5122
|
onContextOverflow;
|
|
5123
|
+
/**
|
|
5124
|
+
* Controllers for every in-flight request and active stream managed by this
|
|
5125
|
+
* client — see {@link OllamaClient.destroy} and {@link createRequestScope}.
|
|
5126
|
+
* Entries live for exactly as long as the underlying work does: until the
|
|
5127
|
+
* response settles (requests) or the stream's `finalResult` settles
|
|
5128
|
+
* (streams, via `executeWithFailover`'s `holdUntil` release path).
|
|
5129
|
+
*/
|
|
5130
|
+
activeRequests = /* @__PURE__ */ new Set();
|
|
4999
5131
|
constructor(config = {}) {
|
|
5000
5132
|
this.cloudApiKey = resolveApiKey(config.apiKey);
|
|
5001
5133
|
const defaultBaseUrl = resolveBaseUrl(config.baseUrl);
|
|
@@ -5160,6 +5292,39 @@ var OllamaClient = class {
|
|
|
5160
5292
|
}
|
|
5161
5293
|
return { ...options, num_ctx: this.defaultContextLength };
|
|
5162
5294
|
}
|
|
5295
|
+
/**
|
|
5296
|
+
* Creates the per-request abort scope registered with {@link destroy}:
|
|
5297
|
+
* a controller that fires when the caller's `signal` aborts OR when
|
|
5298
|
+
* `destroy()` runs, whichever comes first. `dispose()` removes the
|
|
5299
|
+
* registration when the work it guards settles — for plain requests when
|
|
5300
|
+
* the response settles, for streams when `finalResult` settles (the same
|
|
5301
|
+
* moment `executeWithFailover`'s `holdUntil` releases the endpoint slot),
|
|
5302
|
+
* so a destroy() can tear down a stream mid-consumption but never outlives
|
|
5303
|
+
* one that already finished.
|
|
5304
|
+
*/
|
|
5305
|
+
createRequestScope(userSignal) {
|
|
5306
|
+
const controller = new AbortController();
|
|
5307
|
+
const propagateUserAbort = () => {
|
|
5308
|
+
controller.abort(userSignal?.reason);
|
|
5309
|
+
};
|
|
5310
|
+
let detach;
|
|
5311
|
+
if (userSignal) {
|
|
5312
|
+
if (userSignal.aborted) {
|
|
5313
|
+
propagateUserAbort();
|
|
5314
|
+
} else {
|
|
5315
|
+
userSignal.addEventListener("abort", propagateUserAbort, { once: true });
|
|
5316
|
+
detach = () => userSignal.removeEventListener("abort", propagateUserAbort);
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
this.activeRequests.add(controller);
|
|
5320
|
+
return {
|
|
5321
|
+
signal: controller.signal,
|
|
5322
|
+
dispose: () => {
|
|
5323
|
+
detach?.();
|
|
5324
|
+
this.activeRequests.delete(controller);
|
|
5325
|
+
}
|
|
5326
|
+
};
|
|
5327
|
+
}
|
|
5163
5328
|
/**
|
|
5164
5329
|
* Fail-fast guard for `format` (structured output) requests: throws before any network
|
|
5165
5330
|
* call if the candidate endpoint is inferred as Ollama Cloud, which does not currently
|
|
@@ -5176,7 +5341,8 @@ var OllamaClient = class {
|
|
|
5176
5341
|
}
|
|
5177
5342
|
}
|
|
5178
5343
|
async executeWithFailover(operation, options) {
|
|
5179
|
-
const
|
|
5344
|
+
const scope = this.createRequestScope(options?.signal);
|
|
5345
|
+
const timeout = createTimeoutSignal(options?.timeoutMs ?? this.timeoutMs, scope.signal);
|
|
5180
5346
|
const requestId = createLogicalRequestId();
|
|
5181
5347
|
let deferTimeoutCancel = false;
|
|
5182
5348
|
try {
|
|
@@ -5255,6 +5421,7 @@ var OllamaClient = class {
|
|
|
5255
5421
|
if (holdPromise) {
|
|
5256
5422
|
void holdPromise.catch(() => void 0).finally(() => {
|
|
5257
5423
|
timeout.cancel();
|
|
5424
|
+
scope.dispose();
|
|
5258
5425
|
this.registry.release(endpoint.name);
|
|
5259
5426
|
});
|
|
5260
5427
|
} else {
|
|
@@ -5265,7 +5432,10 @@ var OllamaClient = class {
|
|
|
5265
5432
|
throw lastError ?? new Error("No healthy Ollama endpoints available");
|
|
5266
5433
|
}
|
|
5267
5434
|
} finally {
|
|
5268
|
-
if (!deferTimeoutCancel)
|
|
5435
|
+
if (!deferTimeoutCancel) {
|
|
5436
|
+
timeout.cancel();
|
|
5437
|
+
scope.dispose();
|
|
5438
|
+
}
|
|
5269
5439
|
}
|
|
5270
5440
|
}
|
|
5271
5441
|
async chat(req) {
|
|
@@ -5425,6 +5595,58 @@ var OllamaClient = class {
|
|
|
5425
5595
|
const res = await this.embed({ model, input });
|
|
5426
5596
|
return res.embeddings;
|
|
5427
5597
|
}
|
|
5598
|
+
/**
|
|
5599
|
+
* Batch-constrained, order-preserving embedding generation for large
|
|
5600
|
+
* corpora — the safe building block for RAG/vector-index ingestion at
|
|
5601
|
+
* scale. Splits `input` into `batchSize` slices and embeds them through
|
|
5602
|
+
* {@link embed} with at most `concurrency` batches in flight (defaults:
|
|
5603
|
+
* 32 × 3), so `Promise.all`-style floods that OOM local daemons and
|
|
5604
|
+
* saturate `OLLAMA_MAX_QUEUE` can't happen by accident. Fail-fast: the
|
|
5605
|
+
* first batch error aborts every sibling in-flight batch and rejects the
|
|
5606
|
+
* whole operation with the original error.
|
|
5607
|
+
*
|
|
5608
|
+
* Before any request is sent, `defaultContextLength` is injected as
|
|
5609
|
+
* `num_ctx` (same as chat/generate) and each input string's token estimate
|
|
5610
|
+
* is checked against the resolved window: Ollama silently truncates
|
|
5611
|
+
* oversized embedding inputs by default, so the client warns (or throws,
|
|
5612
|
+
* under `onContextOverflow: 'throw'`) with the offending indexes — see
|
|
5613
|
+
* `src/embed-batch.ts` for the exact trip point (no margin: an embedding
|
|
5614
|
+
* prompt IS the whole input).
|
|
5615
|
+
*
|
|
5616
|
+
* ```ts
|
|
5617
|
+
* const { embeddings, batchCount } = await client.embedBatch({
|
|
5618
|
+
* model: 'nomic-embed-text:latest',
|
|
5619
|
+
* input: corpus, // e.g. 50k chunks
|
|
5620
|
+
* batchSize: 32, // inputs per /api/embed request
|
|
5621
|
+
* concurrency: 3, // batches in flight
|
|
5622
|
+
* onBatchComplete: (done, total) => progress.log(`${done}/${total}`),
|
|
5623
|
+
* });
|
|
5624
|
+
* // embeddings[i] always corresponds to corpus[i]
|
|
5625
|
+
* ```
|
|
5626
|
+
*/
|
|
5627
|
+
async embedBatch(options) {
|
|
5628
|
+
const resolvedOptions = this.injectDefaultContextLength(options.options);
|
|
5629
|
+
const contextLength = resolvedOptions?.num_ctx;
|
|
5630
|
+
if (contextLength !== void 0) {
|
|
5631
|
+
const oversized = findOversizedEmbedInputs(options.input, contextLength);
|
|
5632
|
+
if (oversized.length > 0) {
|
|
5633
|
+
const message = embedBatchOverflowMessage(
|
|
5634
|
+
oversized,
|
|
5635
|
+
options.input.length,
|
|
5636
|
+
contextLength,
|
|
5637
|
+
options.truncate === false
|
|
5638
|
+
);
|
|
5639
|
+
if (this.onContextOverflow === "throw") {
|
|
5640
|
+
throw new OllamaClientError(message, { code: "context_overflow" });
|
|
5641
|
+
}
|
|
5642
|
+
this.logger.warn(message);
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
return batchEmbed(
|
|
5646
|
+
this,
|
|
5647
|
+
resolvedOptions === options.options ? options : { ...options, options: resolvedOptions }
|
|
5648
|
+
);
|
|
5649
|
+
}
|
|
5428
5650
|
/**
|
|
5429
5651
|
* @deprecated Ollama's `/api/embeddings` endpoint has been superseded by `/api/embed`
|
|
5430
5652
|
* (exposed here as {@link OllamaClient.embed}), which additionally supports batch
|
|
@@ -5594,10 +5816,12 @@ var OllamaClient = class {
|
|
|
5594
5816
|
async executeCloudRequest(operation, options) {
|
|
5595
5817
|
var _stack = [];
|
|
5596
5818
|
try {
|
|
5597
|
-
const
|
|
5819
|
+
const scope = this.createRequestScope(options.signal);
|
|
5820
|
+
const timeout = createTimeoutSignal(options.timeoutMs ?? this.timeoutMs, scope.signal);
|
|
5598
5821
|
const _timeout = __using(_stack, {
|
|
5599
5822
|
[Symbol.dispose]() {
|
|
5600
5823
|
timeout.cancel();
|
|
5824
|
+
scope.dispose();
|
|
5601
5825
|
}
|
|
5602
5826
|
});
|
|
5603
5827
|
const requestId = createLogicalRequestId();
|
|
@@ -5658,6 +5882,34 @@ var OllamaClient = class {
|
|
|
5658
5882
|
endpointStatus() {
|
|
5659
5883
|
return this.registry.status();
|
|
5660
5884
|
}
|
|
5885
|
+
/**
|
|
5886
|
+
* Immediately aborts every in-flight request and active stream managed by
|
|
5887
|
+
* this client — the clean teardown path for short-lived processes, CLI
|
|
5888
|
+
* runners, and `node:worker_threads` tasks where dangling fetch bodies,
|
|
5889
|
+
* unconsumed stream readers, or queued capacity waiters would otherwise
|
|
5890
|
+
* keep the event loop (and thus the thread/process) alive.
|
|
5891
|
+
*
|
|
5892
|
+
* Every aborted operation rejects with an {@link OllamaAbortError}
|
|
5893
|
+
* (`code: 'aborted'`) carrying `reason` as its message — including requests
|
|
5894
|
+
* still queued behind `maxConcurrentPerEndpoint`, not just dispatched ones.
|
|
5895
|
+
* Streams reject their `finalResult` and release their endpoint slots.
|
|
5896
|
+
*
|
|
5897
|
+
* Idempotent: calling it again (or on a client with nothing in flight)
|
|
5898
|
+
* is a no-op that returns `0`. The client remains usable afterward —
|
|
5899
|
+
* `destroy()` is a drain, not a permanent disable; callers that want a
|
|
5900
|
+
* permanently-dead client should discard the instance.
|
|
5901
|
+
*
|
|
5902
|
+
* @returns the number of in-flight operations that were aborted.
|
|
5903
|
+
*/
|
|
5904
|
+
destroy(reason = "Ollama client destroyed") {
|
|
5905
|
+
const controllers = [...this.activeRequests];
|
|
5906
|
+
const cause = new OllamaAbortError(reason);
|
|
5907
|
+
for (const controller of controllers) {
|
|
5908
|
+
controller.abort(cause);
|
|
5909
|
+
}
|
|
5910
|
+
this.activeRequests.clear();
|
|
5911
|
+
return controllers.length;
|
|
5912
|
+
}
|
|
5661
5913
|
// --- Compatibility Adapters ---
|
|
5662
5914
|
get openai() {
|
|
5663
5915
|
const ep = this.registry.candidates()[0];
|
|
@@ -6795,6 +7047,6 @@ function estimateSystemOneRequestBytes(request) {
|
|
|
6795
7047
|
return new TextEncoder().encode(JSON.stringify(request)).byteLength;
|
|
6796
7048
|
}
|
|
6797
7049
|
|
|
6798
|
-
export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, Agent, AnthropicCompatClient, AnthropicMessagesStream, ConversationSession, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_CONTEXT_WARNING_THRESHOLD, DEFAULT_FAILOVER_CODES, DEFAULT_FETCH_BACKOFF_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, IMAGE_TOKEN_ESTIMATE, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, McpBridge, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAuthError, OllamaBadGatewayError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaOverloadedError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestTooLargeError, OllamaRequestValidationError, OllamaResponseValidationError, OllamaServerError, OllamaServerVersionUnknownError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaStreamError, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, RETRYABLE_STATUS_CODES, ResponsesModule, ToolCallAccumulator, ToolRegistry, addSpanEvent, applySkill, calculateBackoff, checkChatContext, checkEndpointHealth, checkGenerateContext, composeMiddleware, contextWarningMessage, createConsoleLogger, createDecision, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateSystemOneRequestBytes, estimateTokens, extractUsage, fetchWithBackoff, imageStringNeedsResolution, inferRuntimeMode, isKeepAliveSugar, isKnownDoneReason, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, resolveImageInput, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|
|
7050
|
+
export { ATTR_GEN_AI_OPERATION_NAME, ATTR_GEN_AI_REQUEST_MODEL, ATTR_GEN_AI_RESPONSE_MODEL, ATTR_GEN_AI_SYSTEM, ATTR_GEN_AI_TOOL_CALL_ID, ATTR_GEN_AI_TOOL_NAME, ATTR_GEN_AI_USAGE_INPUT_TOKENS, ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_OLLAMA_AGENT_ITERATION, ATTR_OLLAMA_AGENT_MAX_ITERATIONS, ATTR_OLLAMA_ENDPOINT_ATTEMPT, ATTR_OLLAMA_ENDPOINT_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, Agent, AnthropicCompatClient, AnthropicMessagesStream, ConversationSession, DEFAULT_BACKOFF, DEFAULT_BASE_URL, DEFAULT_CONTEXT_WARNING_THRESHOLD, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_EMBED_CONCURRENCY, DEFAULT_FAILOVER_CODES, DEFAULT_FETCH_BACKOFF_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TIMEOUT_MS, EndpointRegistry, GEN_AI_SYSTEM_OLLAMA, HttpClient, IMAGE_TOKEN_ESTIMATE, KEEP_ALIVE_INDEFINITE, KEEP_ALIVE_UNLOAD, KNOWN_DONE_REASONS, MAX_SYSTEM_ONE_IMAGES_BYTES, MAX_SYSTEM_ONE_REQUEST_BYTES, McpBridge, ModelsClient, NANOS_PER_MS, NANOS_PER_SECOND, NOOP_LOGGER, OLLAMA_CLOUD_BASE_URL, OLLAMA_FALLBACK_CONTEXT_LENGTH, OllamaAbortError, OllamaAgentMaxIterationsError, OllamaAgentMaxToolCallsError, OllamaAuthError, OllamaBadGatewayError, OllamaClient, OllamaClientError, OllamaGenericClientError, OllamaIncompatibleModelError, OllamaMcpError, OllamaModelRoutingError, OllamaNetworkError, OllamaNotFoundError, OllamaOverloadedError, OllamaQuotaExceededError, OllamaRateLimitError, OllamaRequestTooLargeError, OllamaRequestValidationError, OllamaResponseValidationError, OllamaServerError, OllamaServerVersionUnknownError, OllamaSkillInvalidError, OllamaSkillNotFoundError, OllamaStream, OllamaStreamError, OllamaTimeoutError, OllamaToolTimeoutError, OllamaToolValidationError, OllamaUnsupportedCapabilityError, OpenAIChatCompletionStream, OpenAICompatClient, OpenAICompletionStream, OpenAIResponsesStream, OpenAIResponsesStreamError, QuotaManager, RETRYABLE_STATUS_CODES, ResponsesModule, ToolCallAccumulator, ToolRegistry, addSpanEvent, applySkill, batchEmbed, calculateBackoff, checkChatContext, checkEndpointHealth, checkGenerateContext, composeMiddleware, contextWarningMessage, createConsoleLogger, createDecision, createOllamaCloudFreeTierQuota, createTimeoutSignal, defineTool, detectModelCapabilities, embedBatchOverflowMessage, encodeImage, estimateChatRequestTokens, estimateGenerateRequestTokens, estimateSystemOneRequestBytes, estimateTokens, extractUsage, fetchWithBackoff, findOversizedEmbedInputs, imageStringNeedsResolution, inferRuntimeMode, isKeepAliveSugar, isKnownDoneReason, isSameToolCall, listAllMcpTools, listAvailableModels, loadMcpTools, mapError, mergeToolCall, mergeToolCallArgumentsString, mergeToolCallArrays, normalizeChatStream, normalizeGenerateStream, normalizeKeepAlive, normalizeProgressStream, parseFrontmatter, parseNdjsonStream, parseSseStream, parseStructuredOutput, registerMcpTools, resolveCredentialEndpoints, resolveImageInput, setSpanError, toDataStream, toResponse, toTextStream, withRetry, withSpan, zodToJsonSchema };
|
|
6799
7051
|
//# sourceMappingURL=index.js.map
|
|
6800
7052
|
//# sourceMappingURL=index.js.map
|