llama-stack-client 0.0.35 → 0.1.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 +22 -201
- package/README.md +60 -26
- package/core.d.ts +7 -7
- package/core.d.ts.map +1 -1
- package/core.js +35 -16
- package/core.js.map +1 -1
- package/core.mjs +32 -14
- package/core.mjs.map +1 -1
- package/error.d.ts +18 -24
- package/error.d.ts.map +1 -1
- package/error.js +1 -31
- package/error.js.map +1 -1
- package/error.mjs +1 -31
- package/error.mjs.map +1 -1
- package/index.d.mts +100 -121
- package/index.d.ts +100 -121
- package/index.d.ts.map +1 -1
- package/index.js +90 -44
- package/index.js.map +1 -1
- package/index.mjs +74 -43
- package/index.mjs.map +1 -1
- package/internal/decoders/jsonl.d.ts +12 -0
- package/internal/decoders/jsonl.d.ts.map +1 -0
- package/internal/decoders/jsonl.js +35 -0
- package/internal/decoders/jsonl.js.map +1 -0
- package/internal/decoders/jsonl.mjs +31 -0
- package/internal/decoders/jsonl.mjs.map +1 -0
- package/internal/decoders/line.d.ts +20 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +88 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +84 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +11 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +8 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +280 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +276 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +229 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/stream-utils.d.ts +8 -0
- package/internal/stream-utils.d.ts.map +1 -0
- package/internal/stream-utils.js +39 -0
- package/internal/stream-utils.js.map +1 -0
- package/internal/stream-utils.mjs +35 -0
- package/internal/stream-utils.mjs.map +1 -0
- package/package.json +8 -6
- package/resources/agents/agents.d.ts +22 -187
- package/resources/agents/agents.d.ts.map +1 -1
- package/resources/agents/agents.js +15 -32
- package/resources/agents/agents.js.map +1 -1
- package/resources/agents/agents.mjs +15 -32
- package/resources/agents/agents.mjs.map +1 -1
- package/resources/agents/index.d.ts +4 -4
- package/resources/agents/index.d.ts.map +1 -1
- package/resources/agents/index.js +7 -7
- package/resources/agents/index.js.map +1 -1
- package/resources/agents/index.mjs +3 -3
- package/resources/agents/index.mjs.map +1 -1
- package/resources/agents/session.d.ts +28 -0
- package/resources/agents/session.d.ts.map +1 -0
- package/resources/agents/session.js +25 -0
- package/resources/agents/session.js.map +1 -0
- package/resources/agents/session.mjs +21 -0
- package/resources/agents/session.mjs.map +1 -0
- package/resources/agents/steps.d.ts +3 -24
- package/resources/agents/steps.d.ts.map +1 -1
- package/resources/agents/steps.js +2 -14
- package/resources/agents/steps.js.map +1 -1
- package/resources/agents/steps.mjs +2 -14
- package/resources/agents/steps.mjs.map +1 -1
- package/resources/agents/turn.d.ts +169 -0
- package/resources/agents/turn.d.ts.map +1 -0
- package/resources/agents/turn.js +19 -0
- package/resources/agents/turn.js.map +1 -0
- package/resources/agents/turn.mjs +15 -0
- package/resources/agents/turn.mjs.map +1 -0
- package/resources/batch-inference.d.ts +17 -64
- package/resources/batch-inference.d.ts.map +1 -1
- package/resources/batch-inference.js +4 -26
- package/resources/batch-inference.js.map +1 -1
- package/resources/batch-inference.mjs +4 -26
- package/resources/batch-inference.mjs.map +1 -1
- package/resources/datasetio.d.ts +25 -0
- package/resources/datasetio.d.ts.map +1 -0
- package/resources/datasetio.js +19 -0
- package/resources/datasetio.js.map +1 -0
- package/resources/datasetio.mjs +15 -0
- package/resources/datasetio.mjs.map +1 -0
- package/resources/datasets.d.ts +45 -46
- package/resources/datasets.d.ts.map +1 -1
- package/resources/datasets.js +11 -35
- package/resources/datasets.js.map +1 -1
- package/resources/datasets.mjs +11 -35
- package/resources/datasets.mjs.map +1 -1
- package/resources/eval/eval.d.ts +59 -0
- package/resources/eval/eval.d.ts.map +1 -0
- package/resources/{inference/embeddings.js → eval/eval.js} +16 -20
- package/resources/eval/eval.js.map +1 -0
- package/resources/eval/eval.mjs +18 -0
- package/resources/eval/eval.mjs.map +1 -0
- package/resources/eval/index.d.ts +3 -0
- package/resources/eval/index.d.ts.map +1 -0
- package/resources/eval/index.js +9 -0
- package/resources/eval/index.js.map +1 -0
- package/resources/eval/index.mjs +4 -0
- package/resources/eval/index.mjs.map +1 -0
- package/resources/eval/jobs.d.ts +13 -0
- package/resources/eval/jobs.d.ts.map +1 -0
- package/resources/eval/jobs.js +21 -0
- package/resources/eval/jobs.js.map +1 -0
- package/resources/eval/jobs.mjs +17 -0
- package/resources/eval/jobs.mjs.map +1 -0
- package/resources/eval-tasks.d.ts +32 -0
- package/resources/eval-tasks.d.ts.map +1 -0
- package/resources/eval-tasks.js +22 -0
- package/resources/eval-tasks.js.map +1 -0
- package/resources/eval-tasks.mjs +18 -0
- package/resources/eval-tasks.mjs.map +1 -0
- package/resources/index.d.ts +23 -15
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +33 -17
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +19 -11
- package/resources/index.mjs.map +1 -1
- package/resources/inference.d.ts +241 -0
- package/resources/inference.d.ts.map +1 -0
- package/resources/inference.js +29 -0
- package/resources/inference.js.map +1 -0
- package/resources/inference.mjs +25 -0
- package/resources/inference.mjs.map +1 -0
- package/resources/inspect.d.ts +26 -0
- package/resources/inspect.d.ts.map +1 -0
- package/resources/inspect.js +15 -0
- package/resources/inspect.js.map +1 -0
- package/resources/inspect.mjs +11 -0
- package/resources/inspect.mjs.map +1 -0
- package/resources/models.d.ts +21 -36
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +11 -27
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +11 -27
- package/resources/models.mjs.map +1 -1
- package/resources/post-training/index.d.ts +2 -2
- package/resources/post-training/index.d.ts.map +1 -1
- package/resources/post-training/index.js +3 -3
- package/resources/post-training/index.js.map +1 -1
- package/resources/post-training/index.mjs +1 -1
- package/resources/post-training/index.mjs.map +1 -1
- package/resources/post-training/job.d.ts +40 -0
- package/resources/post-training/job.d.ts.map +1 -0
- package/resources/post-training/job.js +25 -0
- package/resources/post-training/job.js.map +1 -0
- package/resources/post-training/job.mjs +21 -0
- package/resources/post-training/job.mjs.map +1 -0
- package/resources/post-training/post-training.d.ts +95 -142
- package/resources/post-training/post-training.d.ts.map +1 -1
- package/resources/post-training/post-training.js +8 -29
- package/resources/post-training/post-training.js.map +1 -1
- package/resources/post-training/post-training.mjs +8 -29
- package/resources/post-training/post-training.mjs.map +1 -1
- package/resources/providers.d.ts +14 -0
- package/resources/providers.d.ts.map +1 -0
- package/resources/providers.js +12 -0
- package/resources/providers.js.map +1 -0
- package/resources/providers.mjs +8 -0
- package/resources/providers.mjs.map +1 -0
- package/resources/routes.d.ts +14 -0
- package/resources/routes.d.ts.map +1 -0
- package/resources/routes.js +12 -0
- package/resources/routes.js.map +1 -0
- package/resources/routes.mjs +8 -0
- package/resources/routes.mjs.map +1 -0
- package/resources/safety.d.ts +6 -29
- package/resources/safety.d.ts.map +1 -1
- package/resources/safety.js +2 -14
- package/resources/safety.js.map +1 -1
- package/resources/safety.mjs +2 -14
- package/resources/safety.mjs.map +1 -1
- package/resources/scoring-functions.d.ts +53 -0
- package/resources/scoring-functions.d.ts.map +1 -0
- package/resources/scoring-functions.js +22 -0
- package/resources/scoring-functions.js.map +1 -0
- package/resources/scoring-functions.mjs +18 -0
- package/resources/scoring-functions.mjs.map +1 -0
- package/resources/scoring.d.ts +28 -0
- package/resources/scoring.d.ts.map +1 -0
- package/resources/scoring.js +15 -0
- package/resources/scoring.js.map +1 -0
- package/resources/scoring.mjs +11 -0
- package/resources/scoring.mjs.map +1 -0
- package/resources/shared.d.ts +338 -14
- package/resources/shared.d.ts.map +1 -1
- package/resources/shields.d.ts +18 -32
- package/resources/shields.d.ts.map +1 -1
- package/resources/shields.js +7 -29
- package/resources/shields.js.map +1 -1
- package/resources/shields.mjs +7 -29
- package/resources/shields.mjs.map +1 -1
- package/resources/synthetic-data-generation.d.ts +7 -24
- package/resources/synthetic-data-generation.d.ts.map +1 -1
- package/resources/synthetic-data-generation.js +5 -17
- package/resources/synthetic-data-generation.js.map +1 -1
- package/resources/synthetic-data-generation.mjs +3 -15
- package/resources/synthetic-data-generation.mjs.map +1 -1
- package/resources/telemetry.d.ts +95 -35
- package/resources/telemetry.d.ts.map +1 -1
- package/resources/telemetry.js +29 -22
- package/resources/telemetry.js.map +1 -1
- package/resources/telemetry.mjs +29 -22
- package/resources/telemetry.mjs.map +1 -1
- package/resources/tool-runtime/index.d.ts +3 -0
- package/resources/tool-runtime/index.d.ts.map +1 -0
- package/resources/tool-runtime/index.js +9 -0
- package/resources/tool-runtime/index.js.map +1 -0
- package/resources/tool-runtime/index.mjs +4 -0
- package/resources/tool-runtime/index.mjs.map +1 -0
- package/resources/tool-runtime/rag-tool.d.ts +27 -0
- package/resources/tool-runtime/rag-tool.d.ts.map +1 -0
- package/resources/tool-runtime/rag-tool.js +25 -0
- package/resources/tool-runtime/rag-tool.js.map +1 -0
- package/resources/tool-runtime/rag-tool.mjs +21 -0
- package/resources/tool-runtime/rag-tool.mjs.map +1 -0
- package/resources/tool-runtime/tool-runtime.d.ts +48 -0
- package/resources/tool-runtime/tool-runtime.d.ts.map +1 -0
- package/resources/{evaluate/evaluate.js → tool-runtime/tool-runtime.js} +29 -18
- package/resources/tool-runtime/tool-runtime.js.map +1 -0
- package/resources/tool-runtime/tool-runtime.mjs +33 -0
- package/resources/tool-runtime/tool-runtime.mjs.map +1 -0
- package/resources/toolgroups.d.ts +40 -0
- package/resources/toolgroups.d.ts.map +1 -0
- package/resources/toolgroups.js +37 -0
- package/resources/toolgroups.js.map +1 -0
- package/resources/toolgroups.mjs +33 -0
- package/resources/toolgroups.mjs.map +1 -0
- package/resources/tools.d.ts +41 -0
- package/resources/tools.d.ts.map +1 -0
- package/resources/tools.js +19 -0
- package/resources/tools.js.map +1 -0
- package/resources/tools.mjs +15 -0
- package/resources/tools.mjs.map +1 -0
- package/resources/vector-dbs.d.ts +59 -0
- package/resources/vector-dbs.d.ts.map +1 -0
- package/resources/vector-dbs.js +24 -0
- package/resources/vector-dbs.js.map +1 -0
- package/resources/vector-dbs.mjs +20 -0
- package/resources/vector-dbs.mjs.map +1 -0
- package/resources/vector-io.d.ts +37 -0
- package/resources/vector-io.d.ts.map +1 -0
- package/resources/vector-io.js +19 -0
- package/resources/vector-io.js.map +1 -0
- package/resources/vector-io.mjs +15 -0
- package/resources/vector-io.mjs.map +1 -0
- package/src/core.ts +46 -24
- package/src/error.ts +25 -41
- package/src/index.ts +437 -155
- package/src/internal/decoders/jsonl.ts +41 -0
- package/src/internal/decoders/line.ts +114 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +9 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +388 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/stream-utils.ts +32 -0
- package/src/resources/agents/agents.ts +72 -299
- package/src/resources/agents/index.ts +24 -27
- package/src/resources/agents/session.ts +73 -0
- package/src/resources/agents/steps.ts +14 -40
- package/src/resources/agents/turn.ts +292 -0
- package/src/resources/batch-inference.ts +30 -95
- package/src/resources/datasetio.ts +53 -0
- package/src/resources/datasets.ts +87 -81
- package/src/resources/eval/eval.ts +104 -0
- package/src/resources/eval/index.ts +12 -0
- package/src/resources/eval/jobs.ts +36 -0
- package/src/resources/eval-tasks.ts +69 -0
- package/src/resources/index.ts +141 -65
- package/src/resources/inference.ts +346 -0
- package/src/resources/inspect.ts +47 -0
- package/src/resources/models.ts +46 -66
- package/src/resources/post-training/index.ts +14 -14
- package/src/resources/post-training/job.ts +84 -0
- package/src/resources/post-training/post-training.ts +151 -182
- package/src/resources/providers.ts +26 -0
- package/src/resources/routes.ts +23 -0
- package/src/resources/safety.ts +8 -47
- package/src/resources/scoring-functions.ts +108 -0
- package/src/resources/scoring.ts +52 -0
- package/src/resources/shared.ts +462 -14
- package/src/resources/shields.ts +37 -64
- package/src/resources/synthetic-data-generation.ts +13 -40
- package/src/resources/telemetry.ts +229 -65
- package/src/resources/tool-runtime/index.ts +10 -0
- package/src/resources/tool-runtime/rag-tool.ts +45 -0
- package/src/resources/tool-runtime/tool-runtime.ts +106 -0
- package/src/resources/toolgroups.ts +80 -0
- package/src/resources/tools.ts +81 -0
- package/src/resources/vector-dbs.ts +121 -0
- package/src/resources/vector-io.ts +65 -0
- package/src/streaming.ts +6 -148
- package/src/version.ts +1 -1
- package/streaming.d.ts +0 -7
- package/streaming.d.ts.map +1 -1
- package/streaming.js +8 -123
- package/streaming.js.map +1 -1
- package/streaming.mjs +4 -118
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/agents/sessions.d.ts +0 -76
- package/resources/agents/sessions.d.ts.map +0 -1
- package/resources/agents/sessions.js +0 -52
- package/resources/agents/sessions.js.map +0 -1
- package/resources/agents/sessions.mjs +0 -48
- package/resources/agents/sessions.mjs.map +0 -1
- package/resources/agents/turns.d.ts +0 -133
- package/resources/agents/turns.d.ts.map +0 -1
- package/resources/agents/turns.js +0 -38
- package/resources/agents/turns.js.map +0 -1
- package/resources/agents/turns.mjs +0 -34
- package/resources/agents/turns.mjs.map +0 -1
- package/resources/evaluate/evaluate.d.ts +0 -29
- package/resources/evaluate/evaluate.d.ts.map +0 -1
- package/resources/evaluate/evaluate.js.map +0 -1
- package/resources/evaluate/evaluate.mjs +0 -22
- package/resources/evaluate/evaluate.mjs.map +0 -1
- package/resources/evaluate/index.d.ts +0 -6
- package/resources/evaluate/index.d.ts.map +0 -1
- package/resources/evaluate/index.js +0 -15
- package/resources/evaluate/index.js.map +0 -1
- package/resources/evaluate/index.mjs +0 -7
- package/resources/evaluate/index.mjs.map +0 -1
- package/resources/evaluate/jobs/artifacts.d.ts +0 -22
- package/resources/evaluate/jobs/artifacts.d.ts.map +0 -1
- package/resources/evaluate/jobs/artifacts.js +0 -24
- package/resources/evaluate/jobs/artifacts.js.map +0 -1
- package/resources/evaluate/jobs/artifacts.mjs +0 -20
- package/resources/evaluate/jobs/artifacts.mjs.map +0 -1
- package/resources/evaluate/jobs/index.d.ts +0 -5
- package/resources/evaluate/jobs/index.d.ts.map +0 -1
- package/resources/evaluate/jobs/index.js +0 -13
- package/resources/evaluate/jobs/index.js.map +0 -1
- package/resources/evaluate/jobs/index.mjs +0 -6
- package/resources/evaluate/jobs/index.mjs.map +0 -1
- package/resources/evaluate/jobs/jobs.d.ts +0 -56
- package/resources/evaluate/jobs/jobs.d.ts.map +0 -1
- package/resources/evaluate/jobs/jobs.js +0 -76
- package/resources/evaluate/jobs/jobs.js.map +0 -1
- package/resources/evaluate/jobs/jobs.mjs +0 -49
- package/resources/evaluate/jobs/jobs.mjs.map +0 -1
- package/resources/evaluate/jobs/logs.d.ts +0 -22
- package/resources/evaluate/jobs/logs.d.ts.map +0 -1
- package/resources/evaluate/jobs/logs.js +0 -24
- package/resources/evaluate/jobs/logs.js.map +0 -1
- package/resources/evaluate/jobs/logs.mjs +0 -20
- package/resources/evaluate/jobs/logs.mjs.map +0 -1
- package/resources/evaluate/jobs/status.d.ts +0 -22
- package/resources/evaluate/jobs/status.d.ts.map +0 -1
- package/resources/evaluate/jobs/status.js +0 -24
- package/resources/evaluate/jobs/status.js.map +0 -1
- package/resources/evaluate/jobs/status.mjs +0 -20
- package/resources/evaluate/jobs/status.mjs.map +0 -1
- package/resources/evaluate/question-answering.d.ts +0 -22
- package/resources/evaluate/question-answering.d.ts.map +0 -1
- package/resources/evaluate/question-answering.js +0 -24
- package/resources/evaluate/question-answering.js.map +0 -1
- package/resources/evaluate/question-answering.mjs +0 -20
- package/resources/evaluate/question-answering.mjs.map +0 -1
- package/resources/evaluate/summarization.d.ts +0 -4
- package/resources/evaluate/summarization.d.ts.map +0 -1
- package/resources/evaluate/summarization.js +0 -9
- package/resources/evaluate/summarization.js.map +0 -1
- package/resources/evaluate/summarization.mjs +0 -5
- package/resources/evaluate/summarization.mjs.map +0 -1
- package/resources/evaluate/text-generation.d.ts +0 -4
- package/resources/evaluate/text-generation.d.ts.map +0 -1
- package/resources/evaluate/text-generation.js +0 -9
- package/resources/evaluate/text-generation.js.map +0 -1
- package/resources/evaluate/text-generation.mjs +0 -5
- package/resources/evaluate/text-generation.mjs.map +0 -1
- package/resources/evaluations.d.ts +0 -35
- package/resources/evaluations.d.ts.map +0 -1
- package/resources/evaluations.js +0 -37
- package/resources/evaluations.js.map +0 -1
- package/resources/evaluations.mjs +0 -33
- package/resources/evaluations.mjs.map +0 -1
- package/resources/inference/embeddings.d.ts +0 -29
- package/resources/inference/embeddings.d.ts.map +0 -1
- package/resources/inference/embeddings.js.map +0 -1
- package/resources/inference/embeddings.mjs +0 -22
- package/resources/inference/embeddings.mjs.map +0 -1
- package/resources/inference/index.d.ts +0 -3
- package/resources/inference/index.d.ts.map +0 -1
- package/resources/inference/index.js +0 -9
- package/resources/inference/index.js.map +0 -1
- package/resources/inference/index.mjs +0 -4
- package/resources/inference/index.mjs.map +0 -1
- package/resources/inference/inference.d.ts +0 -172
- package/resources/inference/inference.d.ts.map +0 -1
- package/resources/inference/inference.js +0 -67
- package/resources/inference/inference.js.map +0 -1
- package/resources/inference/inference.mjs +0 -40
- package/resources/inference/inference.mjs.map +0 -1
- package/resources/memory/documents.d.ts +0 -49
- package/resources/memory/documents.d.ts.map +0 -1
- package/resources/memory/documents.js +0 -39
- package/resources/memory/documents.js.map +0 -1
- package/resources/memory/documents.mjs +0 -35
- package/resources/memory/documents.mjs.map +0 -1
- package/resources/memory/index.d.ts +0 -3
- package/resources/memory/index.d.ts.map +0 -1
- package/resources/memory/index.js +0 -9
- package/resources/memory/index.js.map +0 -1
- package/resources/memory/index.mjs +0 -4
- package/resources/memory/index.mjs.map +0 -1
- package/resources/memory/memory.d.ts +0 -158
- package/resources/memory/memory.d.ts.map +0 -1
- package/resources/memory/memory.js +0 -137
- package/resources/memory/memory.js.map +0 -1
- package/resources/memory/memory.mjs +0 -110
- package/resources/memory/memory.mjs.map +0 -1
- package/resources/memory-banks.d.ts +0 -42
- package/resources/memory-banks.d.ts.map +0 -1
- package/resources/memory-banks.js +0 -40
- package/resources/memory-banks.js.map +0 -1
- package/resources/memory-banks.mjs +0 -36
- package/resources/memory-banks.mjs.map +0 -1
- package/resources/post-training/jobs.d.ts +0 -91
- package/resources/post-training/jobs.d.ts.map +0 -1
- package/resources/post-training/jobs.js +0 -80
- package/resources/post-training/jobs.js.map +0 -1
- package/resources/post-training/jobs.mjs +0 -76
- package/resources/post-training/jobs.mjs.map +0 -1
- package/resources/reward-scoring.d.ts +0 -47
- package/resources/reward-scoring.d.ts.map +0 -1
- package/resources/reward-scoring.js +0 -24
- package/resources/reward-scoring.js.map +0 -1
- package/resources/reward-scoring.mjs +0 -20
- package/resources/reward-scoring.mjs.map +0 -1
- package/src/resources/agents/sessions.ts +0 -135
- package/src/resources/agents/turns.ts +0 -231
- package/src/resources/evaluate/evaluate.ts +0 -35
- package/src/resources/evaluate/index.ts +0 -14
- package/src/resources/evaluate/jobs/artifacts.ts +0 -42
- package/src/resources/evaluate/jobs/index.ts +0 -13
- package/src/resources/evaluate/jobs/jobs.ts +0 -99
- package/src/resources/evaluate/jobs/logs.ts +0 -42
- package/src/resources/evaluate/jobs/status.ts +0 -42
- package/src/resources/evaluate/question-answering.ts +0 -42
- package/src/resources/evaluate/summarization.ts +0 -5
- package/src/resources/evaluate/text-generation.ts +0 -5
- package/src/resources/evaluations.ts +0 -73
- package/src/resources/inference/embeddings.ts +0 -48
- package/src/resources/inference/index.ts +0 -15
- package/src/resources/inference/inference.ts +0 -268
- package/src/resources/memory/documents.ts +0 -92
- package/src/resources/memory/index.ts +0 -23
- package/src/resources/memory/memory.ts +0 -297
- package/src/resources/memory-banks.ts +0 -84
- package/src/resources/post-training/jobs.ts +0 -192
- package/src/resources/reward-scoring.ts +0 -82
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import { isRequestOptions } from '../core';
|
|
5
|
+
import * as Core from '../core';
|
|
6
|
+
|
|
7
|
+
export class Tools extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* List tools with optional tool group
|
|
10
|
+
*/
|
|
11
|
+
list(query?: ToolListParams, options?: Core.RequestOptions): Core.APIPromise<ToolListResponse>;
|
|
12
|
+
list(options?: Core.RequestOptions): Core.APIPromise<ToolListResponse>;
|
|
13
|
+
list(
|
|
14
|
+
query: ToolListParams | Core.RequestOptions = {},
|
|
15
|
+
options?: Core.RequestOptions,
|
|
16
|
+
): Core.APIPromise<ToolListResponse> {
|
|
17
|
+
if (isRequestOptions(query)) {
|
|
18
|
+
return this.list({}, query);
|
|
19
|
+
}
|
|
20
|
+
return (
|
|
21
|
+
this._client.get('/v1/tools', { query, ...options }) as Core.APIPromise<{ data: ToolListResponse }>
|
|
22
|
+
)._thenUnwrap((obj) => obj.data);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get(toolName: string, options?: Core.RequestOptions): Core.APIPromise<Tool> {
|
|
26
|
+
return this._client.get(`/v1/tools/${toolName}`, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ListToolsResponse {
|
|
31
|
+
data: Array<Tool>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Tool {
|
|
35
|
+
description: string;
|
|
36
|
+
|
|
37
|
+
identifier: string;
|
|
38
|
+
|
|
39
|
+
parameters: Array<Tool.Parameter>;
|
|
40
|
+
|
|
41
|
+
provider_id: string;
|
|
42
|
+
|
|
43
|
+
provider_resource_id: string;
|
|
44
|
+
|
|
45
|
+
tool_host: 'distribution' | 'client' | 'model_context_protocol';
|
|
46
|
+
|
|
47
|
+
toolgroup_id: string;
|
|
48
|
+
|
|
49
|
+
type: 'tool';
|
|
50
|
+
|
|
51
|
+
metadata?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export namespace Tool {
|
|
55
|
+
export interface Parameter {
|
|
56
|
+
description: string;
|
|
57
|
+
|
|
58
|
+
name: string;
|
|
59
|
+
|
|
60
|
+
parameter_type: string;
|
|
61
|
+
|
|
62
|
+
required: boolean;
|
|
63
|
+
|
|
64
|
+
default?: boolean | number | string | Array<unknown> | unknown | null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ToolListResponse = Array<Tool>;
|
|
69
|
+
|
|
70
|
+
export interface ToolListParams {
|
|
71
|
+
toolgroup_id?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export declare namespace Tools {
|
|
75
|
+
export {
|
|
76
|
+
type ListToolsResponse as ListToolsResponse,
|
|
77
|
+
type Tool as Tool,
|
|
78
|
+
type ToolListResponse as ToolListResponse,
|
|
79
|
+
type ToolListParams as ToolListParams,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
|
|
6
|
+
export class VectorDBs extends APIResource {
|
|
7
|
+
retrieve(
|
|
8
|
+
vectorDBId: string,
|
|
9
|
+
options?: Core.RequestOptions,
|
|
10
|
+
): Core.APIPromise<VectorDBRetrieveResponse | null> {
|
|
11
|
+
return this._client.get(`/v1/vector-dbs/${vectorDBId}`, options);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
list(options?: Core.RequestOptions): Core.APIPromise<VectorDBListResponse> {
|
|
15
|
+
return (
|
|
16
|
+
this._client.get('/v1/vector-dbs', options) as Core.APIPromise<{ data: VectorDBListResponse }>
|
|
17
|
+
)._thenUnwrap((obj) => obj.data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
register(
|
|
21
|
+
body: VectorDBRegisterParams,
|
|
22
|
+
options?: Core.RequestOptions,
|
|
23
|
+
): Core.APIPromise<VectorDBRegisterResponse> {
|
|
24
|
+
return this._client.post('/v1/vector-dbs', { body, ...options });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unregister(vectorDBId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
28
|
+
return this._client.delete(`/v1/vector-dbs/${vectorDBId}`, {
|
|
29
|
+
...options,
|
|
30
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ListVectorDBsResponse {
|
|
36
|
+
data: Array<ListVectorDBsResponse.Data>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export namespace ListVectorDBsResponse {
|
|
40
|
+
export interface Data {
|
|
41
|
+
embedding_dimension: number;
|
|
42
|
+
|
|
43
|
+
embedding_model: string;
|
|
44
|
+
|
|
45
|
+
identifier: string;
|
|
46
|
+
|
|
47
|
+
provider_id: string;
|
|
48
|
+
|
|
49
|
+
provider_resource_id: string;
|
|
50
|
+
|
|
51
|
+
type: 'vector_db';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface VectorDBRetrieveResponse {
|
|
56
|
+
embedding_dimension: number;
|
|
57
|
+
|
|
58
|
+
embedding_model: string;
|
|
59
|
+
|
|
60
|
+
identifier: string;
|
|
61
|
+
|
|
62
|
+
provider_id: string;
|
|
63
|
+
|
|
64
|
+
provider_resource_id: string;
|
|
65
|
+
|
|
66
|
+
type: 'vector_db';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type VectorDBListResponse = Array<VectorDBListResponse.VectorDBListResponseItem>;
|
|
70
|
+
|
|
71
|
+
export namespace VectorDBListResponse {
|
|
72
|
+
export interface VectorDBListResponseItem {
|
|
73
|
+
embedding_dimension: number;
|
|
74
|
+
|
|
75
|
+
embedding_model: string;
|
|
76
|
+
|
|
77
|
+
identifier: string;
|
|
78
|
+
|
|
79
|
+
provider_id: string;
|
|
80
|
+
|
|
81
|
+
provider_resource_id: string;
|
|
82
|
+
|
|
83
|
+
type: 'vector_db';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface VectorDBRegisterResponse {
|
|
88
|
+
embedding_dimension: number;
|
|
89
|
+
|
|
90
|
+
embedding_model: string;
|
|
91
|
+
|
|
92
|
+
identifier: string;
|
|
93
|
+
|
|
94
|
+
provider_id: string;
|
|
95
|
+
|
|
96
|
+
provider_resource_id: string;
|
|
97
|
+
|
|
98
|
+
type: 'vector_db';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface VectorDBRegisterParams {
|
|
102
|
+
embedding_model: string;
|
|
103
|
+
|
|
104
|
+
vector_db_id: string;
|
|
105
|
+
|
|
106
|
+
embedding_dimension?: number;
|
|
107
|
+
|
|
108
|
+
provider_id?: string;
|
|
109
|
+
|
|
110
|
+
provider_vector_db_id?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export declare namespace VectorDBs {
|
|
114
|
+
export {
|
|
115
|
+
type ListVectorDBsResponse as ListVectorDBsResponse,
|
|
116
|
+
type VectorDBRetrieveResponse as VectorDBRetrieveResponse,
|
|
117
|
+
type VectorDBListResponse as VectorDBListResponse,
|
|
118
|
+
type VectorDBRegisterResponse as VectorDBRegisterResponse,
|
|
119
|
+
type VectorDBRegisterParams as VectorDBRegisterParams,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as Shared from './shared';
|
|
6
|
+
|
|
7
|
+
export class VectorIo extends APIResource {
|
|
8
|
+
insert(body: VectorIoInsertParams, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
9
|
+
return this._client.post('/v1/vector-io/insert', {
|
|
10
|
+
body,
|
|
11
|
+
...options,
|
|
12
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
query(body: VectorIoQueryParams, options?: Core.RequestOptions): Core.APIPromise<QueryChunksResponse> {
|
|
17
|
+
return this._client.post('/v1/vector-io/query', { body, ...options });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface QueryChunksResponse {
|
|
22
|
+
chunks: Array<QueryChunksResponse.Chunk>;
|
|
23
|
+
|
|
24
|
+
scores: Array<number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export namespace QueryChunksResponse {
|
|
28
|
+
export interface Chunk {
|
|
29
|
+
content: Shared.InterleavedContent;
|
|
30
|
+
|
|
31
|
+
metadata: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface VectorIoInsertParams {
|
|
36
|
+
chunks: Array<VectorIoInsertParams.Chunk>;
|
|
37
|
+
|
|
38
|
+
vector_db_id: string;
|
|
39
|
+
|
|
40
|
+
ttl_seconds?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export namespace VectorIoInsertParams {
|
|
44
|
+
export interface Chunk {
|
|
45
|
+
content: Shared.InterleavedContent;
|
|
46
|
+
|
|
47
|
+
metadata: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface VectorIoQueryParams {
|
|
52
|
+
query: Shared.InterleavedContent;
|
|
53
|
+
|
|
54
|
+
vector_db_id: string;
|
|
55
|
+
|
|
56
|
+
params?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare namespace VectorIo {
|
|
60
|
+
export {
|
|
61
|
+
type QueryChunksResponse as QueryChunksResponse,
|
|
62
|
+
type VectorIoInsertParams as VectorIoInsertParams,
|
|
63
|
+
type VectorIoQueryParams as VectorIoQueryParams,
|
|
64
|
+
};
|
|
65
|
+
}
|
package/src/streaming.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReadableStream, type Response } from './_shims/index';
|
|
2
2
|
import { LlamaStackClientError } from './error';
|
|
3
|
+
import { LineDecoder } from './internal/decoders/line';
|
|
4
|
+
import { ReadableStreamToAsyncIterable } from './internal/stream-utils';
|
|
3
5
|
|
|
4
6
|
type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
|
|
5
7
|
|
|
@@ -19,7 +21,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
19
21
|
this.controller = controller;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
static fromSSEResponse<Item>(response: Response, controller: AbortController) {
|
|
24
|
+
static fromSSEResponse<Item>(response: Response, controller: AbortController): Stream<Item> {
|
|
23
25
|
let consumed = false;
|
|
24
26
|
|
|
25
27
|
async function* iterator(): AsyncIterator<Item, any, undefined> {
|
|
@@ -56,13 +58,13 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
56
58
|
* Generates a Stream from a newline-separated ReadableStream
|
|
57
59
|
* where each item is a JSON value.
|
|
58
60
|
*/
|
|
59
|
-
static fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController) {
|
|
61
|
+
static fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController): Stream<Item> {
|
|
60
62
|
let consumed = false;
|
|
61
63
|
|
|
62
64
|
async function* iterLines(): AsyncGenerator<string, void, unknown> {
|
|
63
65
|
const lineDecoder = new LineDecoder();
|
|
64
66
|
|
|
65
|
-
const iter =
|
|
67
|
+
const iter = ReadableStreamToAsyncIterable<Bytes>(readableStream);
|
|
66
68
|
for await (const chunk of iter) {
|
|
67
69
|
for (const line of lineDecoder.decode(chunk)) {
|
|
68
70
|
yield line;
|
|
@@ -176,7 +178,7 @@ export async function* _iterSSEMessages(
|
|
|
176
178
|
const sseDecoder = new SSEDecoder();
|
|
177
179
|
const lineDecoder = new LineDecoder();
|
|
178
180
|
|
|
179
|
-
const iter =
|
|
181
|
+
const iter = ReadableStreamToAsyncIterable<Bytes>(response.body);
|
|
180
182
|
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
181
183
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
182
184
|
const sse = sseDecoder.decode(line);
|
|
@@ -310,117 +312,6 @@ class SSEDecoder {
|
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
314
|
|
|
313
|
-
/**
|
|
314
|
-
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
315
|
-
* reading lines from text.
|
|
316
|
-
*
|
|
317
|
-
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
318
|
-
*/
|
|
319
|
-
class LineDecoder {
|
|
320
|
-
// prettier-ignore
|
|
321
|
-
static NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
322
|
-
static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
323
|
-
|
|
324
|
-
buffer: string[];
|
|
325
|
-
trailingCR: boolean;
|
|
326
|
-
textDecoder: any; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
|
|
327
|
-
|
|
328
|
-
constructor() {
|
|
329
|
-
this.buffer = [];
|
|
330
|
-
this.trailingCR = false;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
decode(chunk: Bytes): string[] {
|
|
334
|
-
let text = this.decodeText(chunk);
|
|
335
|
-
|
|
336
|
-
if (this.trailingCR) {
|
|
337
|
-
text = '\r' + text;
|
|
338
|
-
this.trailingCR = false;
|
|
339
|
-
}
|
|
340
|
-
if (text.endsWith('\r')) {
|
|
341
|
-
this.trailingCR = true;
|
|
342
|
-
text = text.slice(0, -1);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (!text) {
|
|
346
|
-
return [];
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
350
|
-
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
351
|
-
|
|
352
|
-
// if there is a trailing new line then the last entry will be an empty
|
|
353
|
-
// string which we don't care about
|
|
354
|
-
if (trailingNewline) {
|
|
355
|
-
lines.pop();
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (lines.length === 1 && !trailingNewline) {
|
|
359
|
-
this.buffer.push(lines[0]!);
|
|
360
|
-
return [];
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (this.buffer.length > 0) {
|
|
364
|
-
lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
|
|
365
|
-
this.buffer = [];
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (!trailingNewline) {
|
|
369
|
-
this.buffer = [lines.pop() || ''];
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return lines;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
decodeText(bytes: Bytes): string {
|
|
376
|
-
if (bytes == null) return '';
|
|
377
|
-
if (typeof bytes === 'string') return bytes;
|
|
378
|
-
|
|
379
|
-
// Node:
|
|
380
|
-
if (typeof Buffer !== 'undefined') {
|
|
381
|
-
if (bytes instanceof Buffer) {
|
|
382
|
-
return bytes.toString();
|
|
383
|
-
}
|
|
384
|
-
if (bytes instanceof Uint8Array) {
|
|
385
|
-
return Buffer.from(bytes).toString();
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
throw new LlamaStackClientError(
|
|
389
|
-
`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.`,
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Browser
|
|
394
|
-
if (typeof TextDecoder !== 'undefined') {
|
|
395
|
-
if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
|
|
396
|
-
this.textDecoder ??= new TextDecoder('utf8');
|
|
397
|
-
return this.textDecoder.decode(bytes);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
throw new LlamaStackClientError(
|
|
401
|
-
`Unexpected: received non-Uint8Array/ArrayBuffer (${
|
|
402
|
-
(bytes as any).constructor.name
|
|
403
|
-
}) in a web platform. Please report this error.`,
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
throw new LlamaStackClientError(
|
|
408
|
-
`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`,
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
flush(): string[] {
|
|
413
|
-
if (!this.buffer.length && !this.trailingCR) {
|
|
414
|
-
return [];
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const lines = [this.buffer.join('')];
|
|
418
|
-
this.buffer = [];
|
|
419
|
-
this.trailingCR = false;
|
|
420
|
-
return lines;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
315
|
/** This is an internal helper function that's just used for testing */
|
|
425
316
|
export function _decodeChunks(chunks: string[]): string[] {
|
|
426
317
|
const decoder = new LineDecoder();
|
|
@@ -440,36 +331,3 @@ function partition(str: string, delimiter: string): [string, string, string] {
|
|
|
440
331
|
|
|
441
332
|
return [str, '', ''];
|
|
442
333
|
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
446
|
-
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
447
|
-
*
|
|
448
|
-
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
449
|
-
*/
|
|
450
|
-
export function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
|
|
451
|
-
if (stream[Symbol.asyncIterator]) return stream;
|
|
452
|
-
|
|
453
|
-
const reader = stream.getReader();
|
|
454
|
-
return {
|
|
455
|
-
async next() {
|
|
456
|
-
try {
|
|
457
|
-
const result = await reader.read();
|
|
458
|
-
if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
|
|
459
|
-
return result;
|
|
460
|
-
} catch (e) {
|
|
461
|
-
reader.releaseLock(); // release lock when stream becomes errored
|
|
462
|
-
throw e;
|
|
463
|
-
}
|
|
464
|
-
},
|
|
465
|
-
async return() {
|
|
466
|
-
const cancelPromise = reader.cancel();
|
|
467
|
-
reader.releaseLock();
|
|
468
|
-
await cancelPromise;
|
|
469
|
-
return { done: true, value: undefined };
|
|
470
|
-
},
|
|
471
|
-
[Symbol.asyncIterator]() {
|
|
472
|
-
return this;
|
|
473
|
-
},
|
|
474
|
-
};
|
|
475
|
-
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.0
|
|
1
|
+
export const VERSION = '0.1.0';
|
package/streaming.d.ts
CHANGED
|
@@ -31,11 +31,4 @@ export declare class Stream<Item> implements AsyncIterable<Item> {
|
|
|
31
31
|
export declare function _iterSSEMessages(response: Response, controller: AbortController): AsyncGenerator<ServerSentEvent, void, unknown>;
|
|
32
32
|
/** This is an internal helper function that's just used for testing */
|
|
33
33
|
export declare function _decodeChunks(chunks: string[]): string[];
|
|
34
|
-
/**
|
|
35
|
-
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
36
|
-
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
37
|
-
*
|
|
38
|
-
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
39
|
-
*/
|
|
40
|
-
export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
|
|
41
34
|
//# sourceMappingURL=streaming.d.ts.map
|
package/streaming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/D,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,qBAAa,MAAM,CAAC,IAAI,CAAE,YAAW,aAAa,CAAC,IAAI,CAAC;IAIpD,OAAO,CAAC,QAAQ;IAHlB,UAAU,EAAE,eAAe,CAAC;gBAGlB,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,EAC3C,UAAU,EAAE,eAAe;IAK7B,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC;IAiC3F;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC;IA2C1G,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;IAI7C;;;OAGG;IACH,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAwBnC;;;;OAIG;IACH,gBAAgB,IAAI,cAAc;CA0BnC;AAED,wBAAuB,gBAAgB,CACrC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,eAAe,GAC1B,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAqBhD;AA0HD,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxD"}
|
package/streaming.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._decodeChunks = exports._iterSSEMessages = exports.Stream = void 0;
|
|
4
4
|
const index_1 = require("./_shims/index.js");
|
|
5
5
|
const error_1 = require("./error.js");
|
|
6
|
+
const line_1 = require("./internal/decoders/line.js");
|
|
7
|
+
const stream_utils_1 = require("./internal/stream-utils.js");
|
|
6
8
|
class Stream {
|
|
7
9
|
constructor(iterator, controller) {
|
|
8
10
|
this.iterator = iterator;
|
|
@@ -50,8 +52,8 @@ class Stream {
|
|
|
50
52
|
static fromReadableStream(readableStream, controller) {
|
|
51
53
|
let consumed = false;
|
|
52
54
|
async function* iterLines() {
|
|
53
|
-
const lineDecoder = new LineDecoder();
|
|
54
|
-
const iter =
|
|
55
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
56
|
+
const iter = (0, stream_utils_1.ReadableStreamToAsyncIterable)(readableStream);
|
|
55
57
|
for await (const chunk of iter) {
|
|
56
58
|
for (const line of lineDecoder.decode(chunk)) {
|
|
57
59
|
yield line;
|
|
@@ -156,8 +158,8 @@ async function* _iterSSEMessages(response, controller) {
|
|
|
156
158
|
throw new error_1.LlamaStackClientError(`Attempted to iterate over a response with no body`);
|
|
157
159
|
}
|
|
158
160
|
const sseDecoder = new SSEDecoder();
|
|
159
|
-
const lineDecoder = new LineDecoder();
|
|
160
|
-
const iter =
|
|
161
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
162
|
+
const iter = (0, stream_utils_1.ReadableStreamToAsyncIterable)(response.body);
|
|
161
163
|
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
162
164
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
163
165
|
const sse = sseDecoder.decode(line);
|
|
@@ -266,91 +268,9 @@ class SSEDecoder {
|
|
|
266
268
|
return null;
|
|
267
269
|
}
|
|
268
270
|
}
|
|
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
271
|
/** This is an internal helper function that's just used for testing */
|
|
352
272
|
function _decodeChunks(chunks) {
|
|
353
|
-
const decoder = new LineDecoder();
|
|
273
|
+
const decoder = new line_1.LineDecoder();
|
|
354
274
|
const lines = [];
|
|
355
275
|
for (const chunk of chunks) {
|
|
356
276
|
lines.push(...decoder.decode(chunk));
|
|
@@ -365,39 +285,4 @@ function partition(str, delimiter) {
|
|
|
365
285
|
}
|
|
366
286
|
return [str, '', ''];
|
|
367
287
|
}
|
|
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
288
|
//# sourceMappingURL=streaming.js.map
|