llama-stack-client 0.0.1-alpha.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/LICENSE +201 -0
- package/README.md +298 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +243 -0
- package/core.d.ts.map +1 -0
- package/core.js +900 -0
- package/core.js.map +1 -0
- package/core.mjs +869 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +215 -0
- package/index.d.ts +215 -0
- package/index.d.ts.map +1 -0
- package/index.js +137 -0
- package/index.js.map +1 -0
- package/index.mjs +109 -0
- package/index.mjs.map +1 -0
- package/package.json +102 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/agents/agents.d.ts +233 -0
- package/resources/agents/agents.d.ts.map +1 -0
- package/resources/agents/agents.js +73 -0
- package/resources/agents/agents.js.map +1 -0
- package/resources/agents/agents.mjs +46 -0
- package/resources/agents/agents.mjs.map +1 -0
- package/resources/agents/index.d.ts +5 -0
- package/resources/agents/index.d.ts.map +1 -0
- package/resources/agents/index.js +13 -0
- package/resources/agents/index.js.map +1 -0
- package/resources/agents/index.mjs +6 -0
- package/resources/agents/index.mjs.map +1 -0
- package/resources/agents/sessions.d.ts +76 -0
- package/resources/agents/sessions.d.ts.map +1 -0
- package/resources/agents/sessions.js +52 -0
- package/resources/agents/sessions.js.map +1 -0
- package/resources/agents/sessions.mjs +48 -0
- package/resources/agents/sessions.mjs.map +1 -0
- package/resources/agents/steps.d.ts +34 -0
- package/resources/agents/steps.d.ts.map +1 -0
- package/resources/agents/steps.js +24 -0
- package/resources/agents/steps.js.map +1 -0
- package/resources/agents/steps.mjs +20 -0
- package/resources/agents/steps.mjs.map +1 -0
- package/resources/agents/turns.d.ts +133 -0
- package/resources/agents/turns.d.ts.map +1 -0
- package/resources/agents/turns.js +38 -0
- package/resources/agents/turns.js.map +1 -0
- package/resources/agents/turns.mjs +34 -0
- package/resources/agents/turns.mjs.map +1 -0
- package/resources/batch-inference.d.ts +99 -0
- package/resources/batch-inference.d.ts.map +1 -0
- package/resources/batch-inference.js +37 -0
- package/resources/batch-inference.js.map +1 -0
- package/resources/batch-inference.mjs +33 -0
- package/resources/batch-inference.mjs.map +1 -0
- package/resources/datasets.d.ts +57 -0
- package/resources/datasets.d.ts.map +1 -0
- package/resources/datasets.js +52 -0
- package/resources/datasets.js.map +1 -0
- package/resources/datasets.mjs +48 -0
- package/resources/datasets.mjs.map +1 -0
- package/resources/evaluate/evaluate.d.ts +29 -0
- package/resources/evaluate/evaluate.d.ts.map +1 -0
- package/resources/evaluate/evaluate.js +49 -0
- package/resources/evaluate/evaluate.js.map +1 -0
- package/resources/evaluate/evaluate.mjs +22 -0
- package/resources/evaluate/evaluate.mjs.map +1 -0
- package/resources/evaluate/index.d.ts +6 -0
- package/resources/evaluate/index.d.ts.map +1 -0
- package/resources/evaluate/index.js +15 -0
- package/resources/evaluate/index.js.map +1 -0
- package/resources/evaluate/index.mjs +7 -0
- package/resources/evaluate/index.mjs.map +1 -0
- package/resources/evaluate/jobs/artifacts.d.ts +22 -0
- package/resources/evaluate/jobs/artifacts.d.ts.map +1 -0
- package/resources/evaluate/jobs/artifacts.js +24 -0
- package/resources/evaluate/jobs/artifacts.js.map +1 -0
- package/resources/evaluate/jobs/artifacts.mjs +20 -0
- package/resources/evaluate/jobs/artifacts.mjs.map +1 -0
- package/resources/evaluate/jobs/index.d.ts +5 -0
- package/resources/evaluate/jobs/index.d.ts.map +1 -0
- package/resources/evaluate/jobs/index.js +13 -0
- package/resources/evaluate/jobs/index.js.map +1 -0
- package/resources/evaluate/jobs/index.mjs +6 -0
- package/resources/evaluate/jobs/index.mjs.map +1 -0
- package/resources/evaluate/jobs/jobs.d.ts +56 -0
- package/resources/evaluate/jobs/jobs.d.ts.map +1 -0
- package/resources/evaluate/jobs/jobs.js +76 -0
- package/resources/evaluate/jobs/jobs.js.map +1 -0
- package/resources/evaluate/jobs/jobs.mjs +49 -0
- package/resources/evaluate/jobs/jobs.mjs.map +1 -0
- package/resources/evaluate/jobs/logs.d.ts +22 -0
- package/resources/evaluate/jobs/logs.d.ts.map +1 -0
- package/resources/evaluate/jobs/logs.js +24 -0
- package/resources/evaluate/jobs/logs.js.map +1 -0
- package/resources/evaluate/jobs/logs.mjs +20 -0
- package/resources/evaluate/jobs/logs.mjs.map +1 -0
- package/resources/evaluate/jobs/status.d.ts +22 -0
- package/resources/evaluate/jobs/status.d.ts.map +1 -0
- package/resources/evaluate/jobs/status.js +24 -0
- package/resources/evaluate/jobs/status.js.map +1 -0
- package/resources/evaluate/jobs/status.mjs +20 -0
- package/resources/evaluate/jobs/status.mjs.map +1 -0
- package/resources/evaluate/question-answering.d.ts +22 -0
- package/resources/evaluate/question-answering.d.ts.map +1 -0
- package/resources/evaluate/question-answering.js +24 -0
- package/resources/evaluate/question-answering.js.map +1 -0
- package/resources/evaluate/question-answering.mjs +20 -0
- package/resources/evaluate/question-answering.mjs.map +1 -0
- package/resources/evaluate/summarization.d.ts +4 -0
- package/resources/evaluate/summarization.d.ts.map +1 -0
- package/resources/evaluate/summarization.js +9 -0
- package/resources/evaluate/summarization.js.map +1 -0
- package/resources/evaluate/summarization.mjs +5 -0
- package/resources/evaluate/summarization.mjs.map +1 -0
- package/resources/evaluate/text-generation.d.ts +4 -0
- package/resources/evaluate/text-generation.d.ts.map +1 -0
- package/resources/evaluate/text-generation.js +9 -0
- package/resources/evaluate/text-generation.js.map +1 -0
- package/resources/evaluate/text-generation.mjs +5 -0
- package/resources/evaluate/text-generation.mjs.map +1 -0
- package/resources/evaluations.d.ts +35 -0
- package/resources/evaluations.d.ts.map +1 -0
- package/resources/evaluations.js +37 -0
- package/resources/evaluations.js.map +1 -0
- package/resources/evaluations.mjs +33 -0
- package/resources/evaluations.mjs.map +1 -0
- package/resources/index.d.ts +17 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +50 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +18 -0
- package/resources/index.mjs.map +1 -0
- package/resources/inference/embeddings.d.ts +29 -0
- package/resources/inference/embeddings.d.ts.map +1 -0
- package/resources/inference/embeddings.js +49 -0
- package/resources/inference/embeddings.js.map +1 -0
- package/resources/inference/embeddings.mjs +22 -0
- package/resources/inference/embeddings.mjs.map +1 -0
- package/resources/inference/index.d.ts +3 -0
- package/resources/inference/index.d.ts.map +1 -0
- package/resources/inference/index.js +9 -0
- package/resources/inference/index.js.map +1 -0
- package/resources/inference/index.mjs +4 -0
- package/resources/inference/index.mjs.map +1 -0
- package/resources/inference/inference.d.ts +172 -0
- package/resources/inference/inference.d.ts.map +1 -0
- package/resources/inference/inference.js +67 -0
- package/resources/inference/inference.js.map +1 -0
- package/resources/inference/inference.mjs +40 -0
- package/resources/inference/inference.mjs.map +1 -0
- package/resources/memory/documents.d.ts +49 -0
- package/resources/memory/documents.d.ts.map +1 -0
- package/resources/memory/documents.js +39 -0
- package/resources/memory/documents.js.map +1 -0
- package/resources/memory/documents.mjs +35 -0
- package/resources/memory/documents.mjs.map +1 -0
- package/resources/memory/index.d.ts +3 -0
- package/resources/memory/index.d.ts.map +1 -0
- package/resources/memory/index.js +9 -0
- package/resources/memory/index.js.map +1 -0
- package/resources/memory/index.mjs +4 -0
- package/resources/memory/index.mjs.map +1 -0
- package/resources/memory/memory.d.ts +158 -0
- package/resources/memory/memory.d.ts.map +1 -0
- package/resources/memory/memory.js +137 -0
- package/resources/memory/memory.js.map +1 -0
- package/resources/memory/memory.mjs +110 -0
- package/resources/memory/memory.mjs.map +1 -0
- package/resources/memory-banks.d.ts +42 -0
- package/resources/memory-banks.d.ts.map +1 -0
- package/resources/memory-banks.js +40 -0
- package/resources/memory-banks.js.map +1 -0
- package/resources/memory-banks.mjs +36 -0
- package/resources/memory-banks.mjs.map +1 -0
- package/resources/models.d.ts +46 -0
- package/resources/models.d.ts.map +1 -0
- package/resources/models.js +40 -0
- package/resources/models.js.map +1 -0
- package/resources/models.mjs +36 -0
- package/resources/models.mjs.map +1 -0
- package/resources/post-training/index.d.ts +3 -0
- package/resources/post-training/index.d.ts.map +1 -0
- package/resources/post-training/index.js +9 -0
- package/resources/post-training/index.js.map +1 -0
- package/resources/post-training/index.mjs +4 -0
- package/resources/post-training/index.mjs.map +1 -0
- package/resources/post-training/jobs.d.ts +91 -0
- package/resources/post-training/jobs.d.ts.map +1 -0
- package/resources/post-training/jobs.js +80 -0
- package/resources/post-training/jobs.js.map +1 -0
- package/resources/post-training/jobs.mjs +76 -0
- package/resources/post-training/jobs.mjs.map +1 -0
- package/resources/post-training/post-training.d.ts +183 -0
- package/resources/post-training/post-training.d.ts.map +1 -0
- package/resources/post-training/post-training.js +66 -0
- package/resources/post-training/post-training.js.map +1 -0
- package/resources/post-training/post-training.mjs +39 -0
- package/resources/post-training/post-training.mjs.map +1 -0
- package/resources/reward-scoring.d.ts +47 -0
- package/resources/reward-scoring.d.ts.map +1 -0
- package/resources/reward-scoring.js +24 -0
- package/resources/reward-scoring.js.map +1 -0
- package/resources/reward-scoring.mjs +20 -0
- package/resources/reward-scoring.mjs.map +1 -0
- package/resources/safety.d.ts +41 -0
- package/resources/safety.d.ts.map +1 -0
- package/resources/safety.js +24 -0
- package/resources/safety.js.map +1 -0
- package/resources/safety.mjs +20 -0
- package/resources/safety.mjs.map +1 -0
- package/resources/shared.d.ts +42 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/resources/shields.d.ts +42 -0
- package/resources/shields.d.ts.map +1 -0
- package/resources/shields.js +40 -0
- package/resources/shields.js.map +1 -0
- package/resources/shields.mjs +36 -0
- package/resources/shields.mjs.map +1 -0
- package/resources/synthetic-data-generation.d.ts +36 -0
- package/resources/synthetic-data-generation.d.ts.map +1 -0
- package/resources/synthetic-data-generation.js +24 -0
- package/resources/synthetic-data-generation.js.map +1 -0
- package/resources/synthetic-data-generation.mjs +20 -0
- package/resources/synthetic-data-generation.mjs.map +1 -0
- package/resources/telemetry.d.ts +81 -0
- package/resources/telemetry.d.ts.map +1 -0
- package/resources/telemetry.js +38 -0
- package/resources/telemetry.js.map +1 -0
- package/resources/telemetry.mjs +34 -0
- package/resources/telemetry.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1195 -0
- package/src/error.ts +146 -0
- package/src/index.ts +298 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/agents/agents.ts +383 -0
- package/src/resources/agents/index.ts +33 -0
- package/src/resources/agents/sessions.ts +135 -0
- package/src/resources/agents/steps.ts +58 -0
- package/src/resources/agents/turns.ts +231 -0
- package/src/resources/batch-inference.ts +154 -0
- package/src/resources/datasets.ts +110 -0
- package/src/resources/evaluate/evaluate.ts +35 -0
- package/src/resources/evaluate/index.ts +14 -0
- package/src/resources/evaluate/jobs/artifacts.ts +42 -0
- package/src/resources/evaluate/jobs/index.ts +13 -0
- package/src/resources/evaluate/jobs/jobs.ts +99 -0
- package/src/resources/evaluate/jobs/logs.ts +42 -0
- package/src/resources/evaluate/jobs/status.ts +42 -0
- package/src/resources/evaluate/question-answering.ts +42 -0
- package/src/resources/evaluate/summarization.ts +5 -0
- package/src/resources/evaluate/text-generation.ts +5 -0
- package/src/resources/evaluations.ts +73 -0
- package/src/resources/index.ts +84 -0
- package/src/resources/inference/embeddings.ts +48 -0
- package/src/resources/inference/index.ts +15 -0
- package/src/resources/inference/inference.ts +268 -0
- package/src/resources/memory/documents.ts +92 -0
- package/src/resources/memory/index.ts +23 -0
- package/src/resources/memory/memory.ts +297 -0
- package/src/resources/memory-banks.ts +84 -0
- package/src/resources/models.ts +88 -0
- package/src/resources/post-training/index.ts +19 -0
- package/src/resources/post-training/jobs.ts +192 -0
- package/src/resources/post-training/post-training.ts +285 -0
- package/src/resources/reward-scoring.ts +82 -0
- package/src/resources/safety.ts +66 -0
- package/src/resources/shared.ts +75 -0
- package/src/resources/shields.ts +84 -0
- package/src/resources/synthetic-data-generation.ts +62 -0
- package/src/resources/telemetry.ts +150 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/streaming.ts +475 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +255 -0
- package/src/version.ts +1 -0
- package/streaming.d.ts +41 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +403 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +396 -0
- package/streaming.mjs.map +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +171 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +158 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
package/streaming.js
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readableStreamAsyncIterable = exports._decodeChunks = exports._iterSSEMessages = exports.Stream = void 0;
|
|
4
|
+
const index_1 = require("./_shims/index.js");
|
|
5
|
+
const error_1 = require("./error.js");
|
|
6
|
+
class Stream {
|
|
7
|
+
constructor(iterator, controller) {
|
|
8
|
+
this.iterator = iterator;
|
|
9
|
+
this.controller = controller;
|
|
10
|
+
}
|
|
11
|
+
static fromSSEResponse(response, controller) {
|
|
12
|
+
let consumed = false;
|
|
13
|
+
async function* iterator() {
|
|
14
|
+
if (consumed) {
|
|
15
|
+
throw new Error('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
16
|
+
}
|
|
17
|
+
consumed = true;
|
|
18
|
+
let done = false;
|
|
19
|
+
try {
|
|
20
|
+
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
21
|
+
try {
|
|
22
|
+
yield JSON.parse(sse.data);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.error(`Could not parse message into JSON:`, sse.data);
|
|
26
|
+
console.error(`From chunk:`, sse.raw);
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
done = true;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
34
|
+
if (e instanceof Error && e.name === 'AbortError')
|
|
35
|
+
return;
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
// If the user `break`s, abort the ongoing request.
|
|
40
|
+
if (!done)
|
|
41
|
+
controller.abort();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return new Stream(iterator, controller);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
48
|
+
* where each item is a JSON value.
|
|
49
|
+
*/
|
|
50
|
+
static fromReadableStream(readableStream, controller) {
|
|
51
|
+
let consumed = false;
|
|
52
|
+
async function* iterLines() {
|
|
53
|
+
const lineDecoder = new LineDecoder();
|
|
54
|
+
const iter = readableStreamAsyncIterable(readableStream);
|
|
55
|
+
for await (const chunk of iter) {
|
|
56
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
57
|
+
yield line;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const line of lineDecoder.flush()) {
|
|
61
|
+
yield line;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function* iterator() {
|
|
65
|
+
if (consumed) {
|
|
66
|
+
throw new Error('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
67
|
+
}
|
|
68
|
+
consumed = true;
|
|
69
|
+
let done = false;
|
|
70
|
+
try {
|
|
71
|
+
for await (const line of iterLines()) {
|
|
72
|
+
if (done)
|
|
73
|
+
continue;
|
|
74
|
+
if (line)
|
|
75
|
+
yield JSON.parse(line);
|
|
76
|
+
}
|
|
77
|
+
done = true;
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
81
|
+
if (e instanceof Error && e.name === 'AbortError')
|
|
82
|
+
return;
|
|
83
|
+
throw e;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
// If the user `break`s, abort the ongoing request.
|
|
87
|
+
if (!done)
|
|
88
|
+
controller.abort();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return new Stream(iterator, controller);
|
|
92
|
+
}
|
|
93
|
+
[Symbol.asyncIterator]() {
|
|
94
|
+
return this.iterator();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Splits the stream into two streams which can be
|
|
98
|
+
* independently read from at different speeds.
|
|
99
|
+
*/
|
|
100
|
+
tee() {
|
|
101
|
+
const left = [];
|
|
102
|
+
const right = [];
|
|
103
|
+
const iterator = this.iterator();
|
|
104
|
+
const teeIterator = (queue) => {
|
|
105
|
+
return {
|
|
106
|
+
next: () => {
|
|
107
|
+
if (queue.length === 0) {
|
|
108
|
+
const result = iterator.next();
|
|
109
|
+
left.push(result);
|
|
110
|
+
right.push(result);
|
|
111
|
+
}
|
|
112
|
+
return queue.shift();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
return [
|
|
117
|
+
new Stream(() => teeIterator(left), this.controller),
|
|
118
|
+
new Stream(() => teeIterator(right), this.controller),
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
123
|
+
* JSON stringified values in the stream
|
|
124
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
125
|
+
*/
|
|
126
|
+
toReadableStream() {
|
|
127
|
+
const self = this;
|
|
128
|
+
let iter;
|
|
129
|
+
const encoder = new TextEncoder();
|
|
130
|
+
return new index_1.ReadableStream({
|
|
131
|
+
async start() {
|
|
132
|
+
iter = self[Symbol.asyncIterator]();
|
|
133
|
+
},
|
|
134
|
+
async pull(ctrl) {
|
|
135
|
+
try {
|
|
136
|
+
const { value, done } = await iter.next();
|
|
137
|
+
if (done)
|
|
138
|
+
return ctrl.close();
|
|
139
|
+
const bytes = encoder.encode(JSON.stringify(value) + '\n');
|
|
140
|
+
ctrl.enqueue(bytes);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
ctrl.error(err);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
async cancel() {
|
|
147
|
+
await iter.return?.();
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.Stream = Stream;
|
|
153
|
+
async function* _iterSSEMessages(response, controller) {
|
|
154
|
+
if (!response.body) {
|
|
155
|
+
controller.abort();
|
|
156
|
+
throw new error_1.LlamaStackClientError(`Attempted to iterate over a response with no body`);
|
|
157
|
+
}
|
|
158
|
+
const sseDecoder = new SSEDecoder();
|
|
159
|
+
const lineDecoder = new LineDecoder();
|
|
160
|
+
const iter = readableStreamAsyncIterable(response.body);
|
|
161
|
+
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
162
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
163
|
+
const sse = sseDecoder.decode(line);
|
|
164
|
+
if (sse)
|
|
165
|
+
yield sse;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const line of lineDecoder.flush()) {
|
|
169
|
+
const sse = sseDecoder.decode(line);
|
|
170
|
+
if (sse)
|
|
171
|
+
yield sse;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports._iterSSEMessages = _iterSSEMessages;
|
|
175
|
+
/**
|
|
176
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
177
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
178
|
+
*/
|
|
179
|
+
async function* iterSSEChunks(iterator) {
|
|
180
|
+
let data = new Uint8Array();
|
|
181
|
+
for await (const chunk of iterator) {
|
|
182
|
+
if (chunk == null) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
186
|
+
: typeof chunk === 'string' ? new TextEncoder().encode(chunk)
|
|
187
|
+
: chunk;
|
|
188
|
+
let newData = new Uint8Array(data.length + binaryChunk.length);
|
|
189
|
+
newData.set(data);
|
|
190
|
+
newData.set(binaryChunk, data.length);
|
|
191
|
+
data = newData;
|
|
192
|
+
let patternIndex;
|
|
193
|
+
while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
|
|
194
|
+
yield data.slice(0, patternIndex);
|
|
195
|
+
data = data.slice(patternIndex);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (data.length > 0) {
|
|
199
|
+
yield data;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function findDoubleNewlineIndex(buffer) {
|
|
203
|
+
// This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
|
|
204
|
+
// and returns the index right after the first occurrence of any pattern,
|
|
205
|
+
// or -1 if none of the patterns are found.
|
|
206
|
+
const newline = 0x0a; // \n
|
|
207
|
+
const carriage = 0x0d; // \r
|
|
208
|
+
for (let i = 0; i < buffer.length - 2; i++) {
|
|
209
|
+
if (buffer[i] === newline && buffer[i + 1] === newline) {
|
|
210
|
+
// \n\n
|
|
211
|
+
return i + 2;
|
|
212
|
+
}
|
|
213
|
+
if (buffer[i] === carriage && buffer[i + 1] === carriage) {
|
|
214
|
+
// \r\r
|
|
215
|
+
return i + 2;
|
|
216
|
+
}
|
|
217
|
+
if (buffer[i] === carriage &&
|
|
218
|
+
buffer[i + 1] === newline &&
|
|
219
|
+
i + 3 < buffer.length &&
|
|
220
|
+
buffer[i + 2] === carriage &&
|
|
221
|
+
buffer[i + 3] === newline) {
|
|
222
|
+
// \r\n\r\n
|
|
223
|
+
return i + 4;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return -1;
|
|
227
|
+
}
|
|
228
|
+
class SSEDecoder {
|
|
229
|
+
constructor() {
|
|
230
|
+
this.event = null;
|
|
231
|
+
this.data = [];
|
|
232
|
+
this.chunks = [];
|
|
233
|
+
}
|
|
234
|
+
decode(line) {
|
|
235
|
+
if (line.endsWith('\r')) {
|
|
236
|
+
line = line.substring(0, line.length - 1);
|
|
237
|
+
}
|
|
238
|
+
if (!line) {
|
|
239
|
+
// empty line and we didn't previously encounter any messages
|
|
240
|
+
if (!this.event && !this.data.length)
|
|
241
|
+
return null;
|
|
242
|
+
const sse = {
|
|
243
|
+
event: this.event,
|
|
244
|
+
data: this.data.join('\n'),
|
|
245
|
+
raw: this.chunks,
|
|
246
|
+
};
|
|
247
|
+
this.event = null;
|
|
248
|
+
this.data = [];
|
|
249
|
+
this.chunks = [];
|
|
250
|
+
return sse;
|
|
251
|
+
}
|
|
252
|
+
this.chunks.push(line);
|
|
253
|
+
if (line.startsWith(':')) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
257
|
+
if (value.startsWith(' ')) {
|
|
258
|
+
value = value.substring(1);
|
|
259
|
+
}
|
|
260
|
+
if (fieldname === 'event') {
|
|
261
|
+
this.event = value;
|
|
262
|
+
}
|
|
263
|
+
else if (fieldname === 'data') {
|
|
264
|
+
this.data.push(value);
|
|
265
|
+
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
271
|
+
* reading lines from text.
|
|
272
|
+
*
|
|
273
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
274
|
+
*/
|
|
275
|
+
class LineDecoder {
|
|
276
|
+
constructor() {
|
|
277
|
+
this.buffer = [];
|
|
278
|
+
this.trailingCR = false;
|
|
279
|
+
}
|
|
280
|
+
decode(chunk) {
|
|
281
|
+
let text = this.decodeText(chunk);
|
|
282
|
+
if (this.trailingCR) {
|
|
283
|
+
text = '\r' + text;
|
|
284
|
+
this.trailingCR = false;
|
|
285
|
+
}
|
|
286
|
+
if (text.endsWith('\r')) {
|
|
287
|
+
this.trailingCR = true;
|
|
288
|
+
text = text.slice(0, -1);
|
|
289
|
+
}
|
|
290
|
+
if (!text) {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
294
|
+
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
295
|
+
// if there is a trailing new line then the last entry will be an empty
|
|
296
|
+
// string which we don't care about
|
|
297
|
+
if (trailingNewline) {
|
|
298
|
+
lines.pop();
|
|
299
|
+
}
|
|
300
|
+
if (lines.length === 1 && !trailingNewline) {
|
|
301
|
+
this.buffer.push(lines[0]);
|
|
302
|
+
return [];
|
|
303
|
+
}
|
|
304
|
+
if (this.buffer.length > 0) {
|
|
305
|
+
lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
|
|
306
|
+
this.buffer = [];
|
|
307
|
+
}
|
|
308
|
+
if (!trailingNewline) {
|
|
309
|
+
this.buffer = [lines.pop() || ''];
|
|
310
|
+
}
|
|
311
|
+
return lines;
|
|
312
|
+
}
|
|
313
|
+
decodeText(bytes) {
|
|
314
|
+
if (bytes == null)
|
|
315
|
+
return '';
|
|
316
|
+
if (typeof bytes === 'string')
|
|
317
|
+
return bytes;
|
|
318
|
+
// Node:
|
|
319
|
+
if (typeof Buffer !== 'undefined') {
|
|
320
|
+
if (bytes instanceof Buffer) {
|
|
321
|
+
return bytes.toString();
|
|
322
|
+
}
|
|
323
|
+
if (bytes instanceof Uint8Array) {
|
|
324
|
+
return Buffer.from(bytes).toString();
|
|
325
|
+
}
|
|
326
|
+
throw new error_1.LlamaStackClientError(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
|
|
327
|
+
}
|
|
328
|
+
// Browser
|
|
329
|
+
if (typeof TextDecoder !== 'undefined') {
|
|
330
|
+
if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
|
|
331
|
+
this.textDecoder ?? (this.textDecoder = new TextDecoder('utf8'));
|
|
332
|
+
return this.textDecoder.decode(bytes);
|
|
333
|
+
}
|
|
334
|
+
throw new error_1.LlamaStackClientError(`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`);
|
|
335
|
+
}
|
|
336
|
+
throw new error_1.LlamaStackClientError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
|
|
337
|
+
}
|
|
338
|
+
flush() {
|
|
339
|
+
if (!this.buffer.length && !this.trailingCR) {
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
342
|
+
const lines = [this.buffer.join('')];
|
|
343
|
+
this.buffer = [];
|
|
344
|
+
this.trailingCR = false;
|
|
345
|
+
return lines;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// prettier-ignore
|
|
349
|
+
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
350
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
351
|
+
/** This is an internal helper function that's just used for testing */
|
|
352
|
+
function _decodeChunks(chunks) {
|
|
353
|
+
const decoder = new LineDecoder();
|
|
354
|
+
const lines = [];
|
|
355
|
+
for (const chunk of chunks) {
|
|
356
|
+
lines.push(...decoder.decode(chunk));
|
|
357
|
+
}
|
|
358
|
+
return lines;
|
|
359
|
+
}
|
|
360
|
+
exports._decodeChunks = _decodeChunks;
|
|
361
|
+
function partition(str, delimiter) {
|
|
362
|
+
const index = str.indexOf(delimiter);
|
|
363
|
+
if (index !== -1) {
|
|
364
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
365
|
+
}
|
|
366
|
+
return [str, '', ''];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
370
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
371
|
+
*
|
|
372
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
373
|
+
*/
|
|
374
|
+
function readableStreamAsyncIterable(stream) {
|
|
375
|
+
if (stream[Symbol.asyncIterator])
|
|
376
|
+
return stream;
|
|
377
|
+
const reader = stream.getReader();
|
|
378
|
+
return {
|
|
379
|
+
async next() {
|
|
380
|
+
try {
|
|
381
|
+
const result = await reader.read();
|
|
382
|
+
if (result?.done)
|
|
383
|
+
reader.releaseLock(); // release lock when stream becomes closed
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
388
|
+
throw e;
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
async return() {
|
|
392
|
+
const cancelPromise = reader.cancel();
|
|
393
|
+
reader.releaseLock();
|
|
394
|
+
await cancelPromise;
|
|
395
|
+
return { done: true, value: undefined };
|
|
396
|
+
},
|
|
397
|
+
[Symbol.asyncIterator]() {
|
|
398
|
+
return this;
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
|
|
403
|
+
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAAA,6CAA+D;AAC/D,sCAAgD;AAUhD,MAAa,MAAM;IAGjB,YACU,QAAmC,EAC3C,UAA2B;QADnB,aAAQ,GAAR,QAAQ,CAA2B;QAG3C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,eAAe,CAAO,QAAkB,EAAE,UAA2B;QAC1E,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,KAAK,SAAS,CAAC,CAAC,QAAQ;YACtB,IAAI,QAAQ,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;aAC7F;YACD,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,IAAI,GAAG,KAAK,CAAC;YACjB,IAAI;gBACF,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE;oBAC9D,IAAI;wBACF,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;qBAC5B;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;wBAC9D,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;wBACtC,MAAM,CAAC,CAAC;qBACT;iBACF;gBACD,IAAI,GAAG,IAAI,CAAC;aACb;YAAC,OAAO,CAAC,EAAE;gBACV,kFAAkF;gBAClF,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,IAAI,K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