llama-stack-client 0.1.2 → 0.1.4
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/index.d.mts +10 -10
- package/index.d.ts +10 -10
- package/index.d.ts.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/index.mjs +6 -6
- package/index.mjs.map +1 -1
- package/internal/decoders/line.d.ts +3 -2
- package/internal/decoders/line.d.ts.map +1 -1
- package/internal/decoders/line.js +97 -35
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +95 -34
- package/internal/decoders/line.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/agents/agents.d.ts +3 -2
- package/resources/agents/agents.d.ts.map +1 -1
- package/resources/agents/agents.js.map +1 -1
- package/resources/agents/agents.mjs.map +1 -1
- package/resources/agents/index.d.ts +1 -1
- package/resources/agents/index.d.ts.map +1 -1
- package/resources/agents/index.js.map +1 -1
- package/resources/agents/index.mjs.map +1 -1
- package/resources/agents/turn.d.ts +109 -9
- package/resources/agents/turn.d.ts.map +1 -1
- package/resources/agents/turn.js +7 -0
- package/resources/agents/turn.js.map +1 -1
- package/resources/agents/turn.mjs +7 -0
- package/resources/agents/turn.mjs.map +1 -1
- package/resources/batch-inference.d.ts +1 -1
- package/resources/batch-inference.d.ts.map +1 -1
- package/resources/benchmarks.d.ts +32 -0
- package/resources/benchmarks.d.ts.map +1 -0
- package/resources/benchmarks.js +22 -0
- package/resources/benchmarks.js.map +1 -0
- package/resources/benchmarks.mjs +18 -0
- package/resources/benchmarks.mjs.map +1 -0
- package/resources/datasets.d.ts +18 -3
- package/resources/datasets.d.ts.map +1 -1
- package/resources/eval/eval.d.ts +20 -20
- package/resources/eval/eval.d.ts.map +1 -1
- package/resources/eval/eval.js +10 -4
- package/resources/eval/eval.js.map +1 -1
- package/resources/eval/eval.mjs +10 -4
- package/resources/eval/eval.mjs.map +1 -1
- package/resources/eval/index.d.ts +1 -1
- package/resources/eval/index.d.ts.map +1 -1
- package/resources/eval/index.js.map +1 -1
- package/resources/eval/index.mjs.map +1 -1
- package/resources/eval/jobs.d.ts +3 -3
- package/resources/eval/jobs.d.ts.map +1 -1
- package/resources/eval/jobs.js +6 -6
- package/resources/eval/jobs.js.map +1 -1
- package/resources/eval/jobs.mjs +6 -6
- package/resources/eval/jobs.mjs.map +1 -1
- package/resources/eval-tasks.d.ts +6 -17
- package/resources/eval-tasks.d.ts.map +1 -1
- package/resources/eval-tasks.js.map +1 -1
- package/resources/eval-tasks.mjs.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/inference.d.ts +35 -9
- package/resources/inference.d.ts.map +1 -1
- package/resources/shared.d.ts +92 -18
- package/resources/shared.d.ts.map +1 -1
- package/resources/telemetry.d.ts +6 -8
- package/resources/telemetry.d.ts.map +1 -1
- package/resources/telemetry.js +6 -13
- package/resources/telemetry.js.map +1 -1
- package/resources/telemetry.mjs +6 -13
- package/resources/telemetry.mjs.map +1 -1
- package/resources/tool-runtime/tool-runtime.d.ts +7 -1
- package/resources/tool-runtime/tool-runtime.d.ts.map +1 -1
- package/resources/tool-runtime/tool-runtime.js.map +1 -1
- package/resources/tool-runtime/tool-runtime.mjs.map +1 -1
- package/resources/toolgroups.d.ts +12 -3
- package/resources/toolgroups.d.ts.map +1 -1
- package/resources/toolgroups.js.map +1 -1
- package/resources/toolgroups.mjs.map +1 -1
- package/src/index.ts +27 -23
- package/src/internal/decoders/line.ts +100 -38
- package/src/resources/agents/agents.ts +8 -0
- package/src/resources/agents/index.ts +3 -0
- package/src/resources/agents/turn.ts +162 -9
- package/src/resources/batch-inference.ts +1 -1
- package/src/resources/benchmarks.ts +69 -0
- package/src/resources/datasets.ts +21 -3
- package/src/resources/eval/eval.ts +45 -30
- package/src/resources/eval/index.ts +3 -1
- package/src/resources/eval/jobs.ts +6 -6
- package/src/resources/eval-tasks.ts +11 -27
- package/src/resources/index.ts +10 -8
- package/src/resources/inference.ts +47 -9
- package/src/resources/shared.ts +113 -21
- package/src/resources/telemetry.ts +9 -27
- package/src/resources/tool-runtime/tool-runtime.ts +9 -1
- package/src/resources/toolgroups.ts +14 -3
- package/src/streaming.ts +1 -43
- package/src/version.ts +1 -1
- package/streaming.d.ts +0 -2
- package/streaming.d.ts.map +1 -1
- package/streaming.js +2 -38
- package/streaming.js.map +1 -1
- package/streaming.mjs +1 -36
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/index.ts
CHANGED
|
@@ -12,6 +12,13 @@ import {
|
|
|
12
12
|
BatchInferenceChatCompletionResponse,
|
|
13
13
|
BatchInferenceCompletionParams,
|
|
14
14
|
} from './resources/batch-inference';
|
|
15
|
+
import {
|
|
16
|
+
Benchmark,
|
|
17
|
+
BenchmarkListResponse,
|
|
18
|
+
BenchmarkRegisterParams,
|
|
19
|
+
Benchmarks,
|
|
20
|
+
ListBenchmarksResponse,
|
|
21
|
+
} from './resources/benchmarks';
|
|
15
22
|
import {
|
|
16
23
|
Datasetio,
|
|
17
24
|
DatasetioAppendRowsParams,
|
|
@@ -25,13 +32,6 @@ import {
|
|
|
25
32
|
Datasets,
|
|
26
33
|
ListDatasetsResponse,
|
|
27
34
|
} from './resources/datasets';
|
|
28
|
-
import {
|
|
29
|
-
EvalTask,
|
|
30
|
-
EvalTaskListResponse,
|
|
31
|
-
EvalTaskRegisterParams,
|
|
32
|
-
EvalTasks,
|
|
33
|
-
ListEvalTasksResponse,
|
|
34
|
-
} from './resources/eval-tasks';
|
|
35
35
|
import {
|
|
36
36
|
ChatCompletionResponseStreamChunk,
|
|
37
37
|
CompletionResponse,
|
|
@@ -134,11 +134,13 @@ import {
|
|
|
134
134
|
ToolResponse,
|
|
135
135
|
} from './resources/agents/agents';
|
|
136
136
|
import {
|
|
137
|
+
BenchmarkConfig,
|
|
137
138
|
Eval,
|
|
138
139
|
EvalCandidate,
|
|
140
|
+
EvalEvaluateRowsAlphaParams,
|
|
139
141
|
EvalEvaluateRowsParams,
|
|
142
|
+
EvalRunEvalAlphaParams,
|
|
140
143
|
EvalRunEvalParams,
|
|
141
|
-
EvalTaskConfig,
|
|
142
144
|
EvaluateResponse,
|
|
143
145
|
Job,
|
|
144
146
|
} from './resources/eval/eval';
|
|
@@ -160,14 +162,14 @@ import {
|
|
|
160
162
|
|
|
161
163
|
export interface ClientOptions {
|
|
162
164
|
/**
|
|
163
|
-
* Defaults to process.env['
|
|
165
|
+
* Defaults to process.env['LLAMA_STACK_API_KEY'].
|
|
164
166
|
*/
|
|
165
167
|
apiKey?: string | null | undefined;
|
|
166
168
|
|
|
167
169
|
/**
|
|
168
170
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
169
171
|
*
|
|
170
|
-
* Defaults to process.env['
|
|
172
|
+
* Defaults to process.env['LLAMA_STACK_BASE_URL'].
|
|
171
173
|
*/
|
|
172
174
|
baseURL?: string | null | undefined;
|
|
173
175
|
|
|
@@ -232,8 +234,8 @@ export class LlamaStackClient extends Core.APIClient {
|
|
|
232
234
|
/**
|
|
233
235
|
* API Client for interfacing with the Llama Stack Client API.
|
|
234
236
|
*
|
|
235
|
-
* @param {string | null | undefined} [opts.apiKey=process.env['
|
|
236
|
-
* @param {string} [opts.baseURL=process.env['
|
|
237
|
+
* @param {string | null | undefined} [opts.apiKey=process.env['LLAMA_STACK_API_KEY'] ?? null]
|
|
238
|
+
* @param {string} [opts.baseURL=process.env['LLAMA_STACK_BASE_URL'] ?? http://any-hosted-llama-stack.com] - Override the default base URL for the API.
|
|
237
239
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
238
240
|
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
239
241
|
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -242,8 +244,8 @@ export class LlamaStackClient extends Core.APIClient {
|
|
|
242
244
|
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
243
245
|
*/
|
|
244
246
|
constructor({
|
|
245
|
-
baseURL = Core.readEnv('
|
|
246
|
-
apiKey = Core.readEnv('
|
|
247
|
+
baseURL = Core.readEnv('LLAMA_STACK_BASE_URL'),
|
|
248
|
+
apiKey = Core.readEnv('LLAMA_STACK_API_KEY') ?? null,
|
|
247
249
|
...opts
|
|
248
250
|
}: ClientOptions = {}) {
|
|
249
251
|
const options: ClientOptions = {
|
|
@@ -287,7 +289,7 @@ export class LlamaStackClient extends Core.APIClient {
|
|
|
287
289
|
datasetio: API.Datasetio = new API.Datasetio(this);
|
|
288
290
|
scoring: API.Scoring = new API.Scoring(this);
|
|
289
291
|
scoringFunctions: API.ScoringFunctions = new API.ScoringFunctions(this);
|
|
290
|
-
|
|
292
|
+
benchmarks: API.Benchmarks = new API.Benchmarks(this);
|
|
291
293
|
|
|
292
294
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
293
295
|
return this._options.defaultQuery;
|
|
@@ -354,7 +356,7 @@ LlamaStackClient.Telemetry = Telemetry;
|
|
|
354
356
|
LlamaStackClient.Datasetio = Datasetio;
|
|
355
357
|
LlamaStackClient.Scoring = Scoring;
|
|
356
358
|
LlamaStackClient.ScoringFunctions = ScoringFunctions;
|
|
357
|
-
LlamaStackClient.
|
|
359
|
+
LlamaStackClient.Benchmarks = Benchmarks;
|
|
358
360
|
export declare namespace LlamaStackClient {
|
|
359
361
|
export type RequestOptions = Core.RequestOptions;
|
|
360
362
|
|
|
@@ -410,12 +412,14 @@ export declare namespace LlamaStackClient {
|
|
|
410
412
|
|
|
411
413
|
export {
|
|
412
414
|
Eval as Eval,
|
|
415
|
+
type BenchmarkConfig as BenchmarkConfig,
|
|
413
416
|
type EvalCandidate as EvalCandidate,
|
|
414
|
-
type EvalTaskConfig as EvalTaskConfig,
|
|
415
417
|
type EvaluateResponse as EvaluateResponse,
|
|
416
418
|
type Job as Job,
|
|
417
419
|
type EvalEvaluateRowsParams as EvalEvaluateRowsParams,
|
|
420
|
+
type EvalEvaluateRowsAlphaParams as EvalEvaluateRowsAlphaParams,
|
|
418
421
|
type EvalRunEvalParams as EvalRunEvalParams,
|
|
422
|
+
type EvalRunEvalAlphaParams as EvalRunEvalAlphaParams,
|
|
419
423
|
};
|
|
420
424
|
|
|
421
425
|
export {
|
|
@@ -549,11 +553,11 @@ export declare namespace LlamaStackClient {
|
|
|
549
553
|
};
|
|
550
554
|
|
|
551
555
|
export {
|
|
552
|
-
|
|
553
|
-
type
|
|
554
|
-
type
|
|
555
|
-
type
|
|
556
|
-
type
|
|
556
|
+
Benchmarks as Benchmarks,
|
|
557
|
+
type Benchmark as Benchmark,
|
|
558
|
+
type ListBenchmarksResponse as ListBenchmarksResponse,
|
|
559
|
+
type BenchmarkListResponse as BenchmarkListResponse,
|
|
560
|
+
type BenchmarkRegisterParams as BenchmarkRegisterParams,
|
|
557
561
|
};
|
|
558
562
|
|
|
559
563
|
export type AgentConfig = API.AgentConfig;
|
|
@@ -576,9 +580,9 @@ export declare namespace LlamaStackClient {
|
|
|
576
580
|
export type ScoringResult = API.ScoringResult;
|
|
577
581
|
export type SystemMessage = API.SystemMessage;
|
|
578
582
|
export type ToolCall = API.ToolCall;
|
|
583
|
+
export type ToolCallOrString = API.ToolCallOrString;
|
|
579
584
|
export type ToolParamDefinition = API.ToolParamDefinition;
|
|
580
585
|
export type ToolResponseMessage = API.ToolResponseMessage;
|
|
581
|
-
export type URL = API.URL;
|
|
582
586
|
export type UserMessage = API.UserMessage;
|
|
583
587
|
}
|
|
584
588
|
|
|
@@ -13,52 +13,58 @@ export class LineDecoder {
|
|
|
13
13
|
static NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
14
14
|
static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
15
15
|
|
|
16
|
-
buffer:
|
|
17
|
-
|
|
16
|
+
buffer: Uint8Array;
|
|
17
|
+
#carriageReturnIndex: number | null;
|
|
18
18
|
textDecoder: any; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
|
|
19
19
|
|
|
20
20
|
constructor() {
|
|
21
|
-
this.buffer =
|
|
22
|
-
this
|
|
21
|
+
this.buffer = new Uint8Array();
|
|
22
|
+
this.#carriageReturnIndex = null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
decode(chunk: Bytes): string[] {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (this.trailingCR) {
|
|
29
|
-
text = '\r' + text;
|
|
30
|
-
this.trailingCR = false;
|
|
31
|
-
}
|
|
32
|
-
if (text.endsWith('\r')) {
|
|
33
|
-
this.trailingCR = true;
|
|
34
|
-
text = text.slice(0, -1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!text) {
|
|
26
|
+
if (chunk == null) {
|
|
38
27
|
return [];
|
|
39
28
|
}
|
|
40
29
|
|
|
41
|
-
const
|
|
42
|
-
|
|
30
|
+
const binaryChunk =
|
|
31
|
+
chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
32
|
+
: typeof chunk === 'string' ? new TextEncoder().encode(chunk)
|
|
33
|
+
: chunk;
|
|
34
|
+
|
|
35
|
+
let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
|
|
36
|
+
newData.set(this.buffer);
|
|
37
|
+
newData.set(binaryChunk, this.buffer.length);
|
|
38
|
+
this.buffer = newData;
|
|
39
|
+
|
|
40
|
+
const lines: string[] = [];
|
|
41
|
+
let patternIndex;
|
|
42
|
+
while ((patternIndex = findNewlineIndex(this.buffer, this.#carriageReturnIndex)) != null) {
|
|
43
|
+
if (patternIndex.carriage && this.#carriageReturnIndex == null) {
|
|
44
|
+
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
45
|
+
this.#carriageReturnIndex = patternIndex.index;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
// we got double \r or \rtext\n
|
|
50
|
+
if (
|
|
51
|
+
this.#carriageReturnIndex != null &&
|
|
52
|
+
(patternIndex.index !== this.#carriageReturnIndex + 1 || patternIndex.carriage)
|
|
53
|
+
) {
|
|
54
|
+
lines.push(this.decodeText(this.buffer.slice(0, this.#carriageReturnIndex - 1)));
|
|
55
|
+
this.buffer = this.buffer.slice(this.#carriageReturnIndex);
|
|
56
|
+
this.#carriageReturnIndex = null;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
60
|
+
const endIndex =
|
|
61
|
+
this.#carriageReturnIndex !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
lines
|
|
57
|
-
this.buffer = [];
|
|
58
|
-
}
|
|
63
|
+
const line = this.decodeText(this.buffer.slice(0, endIndex));
|
|
64
|
+
lines.push(line);
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
this
|
|
66
|
+
this.buffer = this.buffer.slice(patternIndex.index);
|
|
67
|
+
this.#carriageReturnIndex = null;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
return lines;
|
|
@@ -102,13 +108,69 @@ export class LineDecoder {
|
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
flush(): string[] {
|
|
105
|
-
if (!this.buffer.length
|
|
111
|
+
if (!this.buffer.length) {
|
|
106
112
|
return [];
|
|
107
113
|
}
|
|
114
|
+
return this.decode('\n');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
/**
|
|
119
|
+
* This function searches the buffer for the end patterns, (\r or \n)
|
|
120
|
+
* and returns an object with the index preceding the matched newline and the
|
|
121
|
+
* index after the newline char. `null` is returned if no new line is found.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
function findNewlineIndex(
|
|
128
|
+
buffer: Uint8Array,
|
|
129
|
+
startIndex: number | null,
|
|
130
|
+
): { preceding: number; index: number; carriage: boolean } | null {
|
|
131
|
+
const newline = 0x0a; // \n
|
|
132
|
+
const carriage = 0x0d; // \r
|
|
133
|
+
|
|
134
|
+
for (let i = startIndex ?? 0; i < buffer.length; i++) {
|
|
135
|
+
if (buffer[i] === newline) {
|
|
136
|
+
return { preceding: i, index: i + 1, carriage: false };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (buffer[i] === carriage) {
|
|
140
|
+
return { preceding: i, index: i + 1, carriage: true };
|
|
141
|
+
}
|
|
113
142
|
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function findDoubleNewlineIndex(buffer: Uint8Array): number {
|
|
148
|
+
// This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
|
|
149
|
+
// and returns the index right after the first occurrence of any pattern,
|
|
150
|
+
// or -1 if none of the patterns are found.
|
|
151
|
+
const newline = 0x0a; // \n
|
|
152
|
+
const carriage = 0x0d; // \r
|
|
153
|
+
|
|
154
|
+
for (let i = 0; i < buffer.length - 1; i++) {
|
|
155
|
+
if (buffer[i] === newline && buffer[i + 1] === newline) {
|
|
156
|
+
// \n\n
|
|
157
|
+
return i + 2;
|
|
158
|
+
}
|
|
159
|
+
if (buffer[i] === carriage && buffer[i + 1] === carriage) {
|
|
160
|
+
// \r\r
|
|
161
|
+
return i + 2;
|
|
162
|
+
}
|
|
163
|
+
if (
|
|
164
|
+
buffer[i] === carriage &&
|
|
165
|
+
buffer[i + 1] === newline &&
|
|
166
|
+
i + 3 < buffer.length &&
|
|
167
|
+
buffer[i + 2] === carriage &&
|
|
168
|
+
buffer[i + 3] === newline
|
|
169
|
+
) {
|
|
170
|
+
// \r\n\r\n
|
|
171
|
+
return i + 4;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return -1;
|
|
114
176
|
}
|
|
@@ -23,6 +23,9 @@ import {
|
|
|
23
23
|
TurnResource,
|
|
24
24
|
TurnResponseEvent,
|
|
25
25
|
TurnResponseEventPayload,
|
|
26
|
+
TurnResumeParams,
|
|
27
|
+
TurnResumeParamsNonStreaming,
|
|
28
|
+
TurnResumeParamsStreaming,
|
|
26
29
|
} from './turn';
|
|
27
30
|
|
|
28
31
|
export class Agents extends APIResource {
|
|
@@ -117,6 +120,8 @@ export interface ToolResponse {
|
|
|
117
120
|
content: Shared.InterleavedContent;
|
|
118
121
|
|
|
119
122
|
tool_name: 'brave_search' | 'wolfram_alpha' | 'photogen' | 'code_interpreter' | (string & {});
|
|
123
|
+
|
|
124
|
+
metadata?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
export interface AgentCreateResponse {
|
|
@@ -161,5 +166,8 @@ export declare namespace Agents {
|
|
|
161
166
|
type TurnCreateParams as TurnCreateParams,
|
|
162
167
|
type TurnCreateParamsNonStreaming as TurnCreateParamsNonStreaming,
|
|
163
168
|
type TurnCreateParamsStreaming as TurnCreateParamsStreaming,
|
|
169
|
+
type TurnResumeParams as TurnResumeParams,
|
|
170
|
+
type TurnResumeParamsNonStreaming as TurnResumeParamsNonStreaming,
|
|
171
|
+
type TurnResumeParamsStreaming as TurnResumeParamsStreaming,
|
|
164
172
|
};
|
|
165
173
|
}
|
|
@@ -48,6 +48,47 @@ export class TurnResource extends APIResource {
|
|
|
48
48
|
): Core.APIPromise<Turn> {
|
|
49
49
|
return this._client.get(`/v1/agents/${agentId}/session/${sessionId}/turn/${turnId}`, options);
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resume an agent turn with executed tool call responses. When a Turn has the
|
|
54
|
+
* status `awaiting_input` due to pending input from client side tool calls, this
|
|
55
|
+
* endpoint can be used to submit the outputs from the tool calls once they are
|
|
56
|
+
* ready.
|
|
57
|
+
*/
|
|
58
|
+
resume(
|
|
59
|
+
agentId: string,
|
|
60
|
+
sessionId: string,
|
|
61
|
+
turnId: string,
|
|
62
|
+
body: TurnResumeParamsNonStreaming,
|
|
63
|
+
options?: Core.RequestOptions,
|
|
64
|
+
): APIPromise<Turn>;
|
|
65
|
+
resume(
|
|
66
|
+
agentId: string,
|
|
67
|
+
sessionId: string,
|
|
68
|
+
turnId: string,
|
|
69
|
+
body: TurnResumeParamsStreaming,
|
|
70
|
+
options?: Core.RequestOptions,
|
|
71
|
+
): APIPromise<Stream<AgentTurnResponseStreamChunk>>;
|
|
72
|
+
resume(
|
|
73
|
+
agentId: string,
|
|
74
|
+
sessionId: string,
|
|
75
|
+
turnId: string,
|
|
76
|
+
body: TurnResumeParamsBase,
|
|
77
|
+
options?: Core.RequestOptions,
|
|
78
|
+
): APIPromise<Stream<AgentTurnResponseStreamChunk> | Turn>;
|
|
79
|
+
resume(
|
|
80
|
+
agentId: string,
|
|
81
|
+
sessionId: string,
|
|
82
|
+
turnId: string,
|
|
83
|
+
body: TurnResumeParams,
|
|
84
|
+
options?: Core.RequestOptions,
|
|
85
|
+
): APIPromise<Turn> | APIPromise<Stream<AgentTurnResponseStreamChunk>> {
|
|
86
|
+
return this._client.post(`/v1/agents/${agentId}/session/${sessionId}/turn/${turnId}/resume`, {
|
|
87
|
+
body,
|
|
88
|
+
...options,
|
|
89
|
+
stream: body.stream ?? false,
|
|
90
|
+
}) as APIPromise<Turn> | APIPromise<Stream<AgentTurnResponseStreamChunk>>;
|
|
91
|
+
}
|
|
51
92
|
}
|
|
52
93
|
|
|
53
94
|
/**
|
|
@@ -63,8 +104,6 @@ export interface AgentTurnResponseStreamChunk {
|
|
|
63
104
|
export interface Turn {
|
|
64
105
|
input_messages: Array<Shared.UserMessage | Shared.ToolResponseMessage>;
|
|
65
106
|
|
|
66
|
-
output_attachments: Array<Turn.OutputAttachment>;
|
|
67
|
-
|
|
68
107
|
/**
|
|
69
108
|
* A message containing the model's (assistant) response in a chat conversation.
|
|
70
109
|
*/
|
|
@@ -84,6 +123,8 @@ export interface Turn {
|
|
|
84
123
|
turn_id: string;
|
|
85
124
|
|
|
86
125
|
completed_at?: string;
|
|
126
|
+
|
|
127
|
+
output_attachments?: Array<Turn.OutputAttachment>;
|
|
87
128
|
}
|
|
88
129
|
|
|
89
130
|
export namespace Turn {
|
|
@@ -96,7 +137,7 @@ export namespace Turn {
|
|
|
96
137
|
| OutputAttachment.ImageContentItem
|
|
97
138
|
| OutputAttachment.TextContentItem
|
|
98
139
|
| Array<Shared.InterleavedContentItem>
|
|
99
|
-
|
|
|
140
|
+
| OutputAttachment.URL;
|
|
100
141
|
|
|
101
142
|
mime_type: string;
|
|
102
143
|
}
|
|
@@ -131,7 +172,17 @@ export namespace Turn {
|
|
|
131
172
|
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
|
|
132
173
|
* Note that URL could have length limits.
|
|
133
174
|
*/
|
|
134
|
-
url?:
|
|
175
|
+
url?: Image.URL;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export namespace Image {
|
|
179
|
+
/**
|
|
180
|
+
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
|
|
181
|
+
* Note that URL could have length limits.
|
|
182
|
+
*/
|
|
183
|
+
export interface URL {
|
|
184
|
+
uri: string;
|
|
185
|
+
}
|
|
135
186
|
}
|
|
136
187
|
}
|
|
137
188
|
|
|
@@ -149,6 +200,10 @@ export namespace Turn {
|
|
|
149
200
|
*/
|
|
150
201
|
type: 'text';
|
|
151
202
|
}
|
|
203
|
+
|
|
204
|
+
export interface URL {
|
|
205
|
+
uri: string;
|
|
206
|
+
}
|
|
152
207
|
}
|
|
153
208
|
}
|
|
154
209
|
|
|
@@ -161,7 +216,8 @@ export type TurnResponseEventPayload =
|
|
|
161
216
|
| TurnResponseEventPayload.AgentTurnResponseStepProgressPayload
|
|
162
217
|
| TurnResponseEventPayload.AgentTurnResponseStepCompletePayload
|
|
163
218
|
| TurnResponseEventPayload.AgentTurnResponseTurnStartPayload
|
|
164
|
-
| TurnResponseEventPayload.AgentTurnResponseTurnCompletePayload
|
|
219
|
+
| TurnResponseEventPayload.AgentTurnResponseTurnCompletePayload
|
|
220
|
+
| TurnResponseEventPayload.AgentTurnResponseTurnAwaitingInputPayload;
|
|
165
221
|
|
|
166
222
|
export namespace TurnResponseEventPayload {
|
|
167
223
|
export interface AgentTurnResponseStepStartPayload {
|
|
@@ -212,6 +268,15 @@ export namespace TurnResponseEventPayload {
|
|
|
212
268
|
*/
|
|
213
269
|
turn: TurnAPI.Turn;
|
|
214
270
|
}
|
|
271
|
+
|
|
272
|
+
export interface AgentTurnResponseTurnAwaitingInputPayload {
|
|
273
|
+
event_type: 'turn_awaiting_input';
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A single turn in an interaction with an Agentic System.
|
|
277
|
+
*/
|
|
278
|
+
turn: TurnAPI.Turn;
|
|
279
|
+
}
|
|
215
280
|
}
|
|
216
281
|
|
|
217
282
|
export type TurnCreateParams = TurnCreateParamsNonStreaming | TurnCreateParamsStreaming;
|
|
@@ -219,11 +284,18 @@ export type TurnCreateParams = TurnCreateParamsNonStreaming | TurnCreateParamsSt
|
|
|
219
284
|
export interface TurnCreateParamsBase {
|
|
220
285
|
messages: Array<Shared.UserMessage | Shared.ToolResponseMessage>;
|
|
221
286
|
|
|
287
|
+
allow_turn_resume?: boolean;
|
|
288
|
+
|
|
222
289
|
documents?: Array<TurnCreateParams.Document>;
|
|
223
290
|
|
|
224
291
|
stream?: boolean;
|
|
225
292
|
|
|
226
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Configuration for tool use.
|
|
295
|
+
*/
|
|
296
|
+
tool_config?: TurnCreateParams.ToolConfig;
|
|
297
|
+
|
|
298
|
+
toolgroups?: Array<string | TurnCreateParams.AgentToolGroupWithArgs>;
|
|
227
299
|
}
|
|
228
300
|
|
|
229
301
|
export namespace TurnCreateParams {
|
|
@@ -236,7 +308,7 @@ export namespace TurnCreateParams {
|
|
|
236
308
|
| Document.ImageContentItem
|
|
237
309
|
| Document.TextContentItem
|
|
238
310
|
| Array<Shared.InterleavedContentItem>
|
|
239
|
-
|
|
|
311
|
+
| Document.URL;
|
|
240
312
|
|
|
241
313
|
mime_type: string;
|
|
242
314
|
}
|
|
@@ -271,7 +343,17 @@ export namespace TurnCreateParams {
|
|
|
271
343
|
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
|
|
272
344
|
* Note that URL could have length limits.
|
|
273
345
|
*/
|
|
274
|
-
url?:
|
|
346
|
+
url?: Image.URL;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export namespace Image {
|
|
350
|
+
/**
|
|
351
|
+
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
|
|
352
|
+
* Note that URL could have length limits.
|
|
353
|
+
*/
|
|
354
|
+
export interface URL {
|
|
355
|
+
uri: string;
|
|
356
|
+
}
|
|
275
357
|
}
|
|
276
358
|
}
|
|
277
359
|
|
|
@@ -289,9 +371,44 @@ export namespace TurnCreateParams {
|
|
|
289
371
|
*/
|
|
290
372
|
type: 'text';
|
|
291
373
|
}
|
|
374
|
+
|
|
375
|
+
export interface URL {
|
|
376
|
+
uri: string;
|
|
377
|
+
}
|
|
292
378
|
}
|
|
293
379
|
|
|
294
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Configuration for tool use.
|
|
382
|
+
*/
|
|
383
|
+
export interface ToolConfig {
|
|
384
|
+
/**
|
|
385
|
+
* (Optional) Config for how to override the default system prompt. -
|
|
386
|
+
* `SystemMessageBehavior.append`: Appends the provided system message to the
|
|
387
|
+
* default system prompt. - `SystemMessageBehavior.replace`: Replaces the default
|
|
388
|
+
* system prompt with the provided system message. The system message can include
|
|
389
|
+
* the string '{{function_definitions}}' to indicate where the function definitions
|
|
390
|
+
* should be inserted.
|
|
391
|
+
*/
|
|
392
|
+
system_message_behavior?: 'append' | 'replace';
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* (Optional) Whether tool use is automatic, required, or none. Can also specify a
|
|
396
|
+
* tool name to use a specific tool. Defaults to ToolChoice.auto.
|
|
397
|
+
*/
|
|
398
|
+
tool_choice?: 'auto' | 'required' | 'none' | (string & {});
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* (Optional) Instructs the model how to format tool calls. By default, Llama Stack
|
|
402
|
+
* will attempt to use a format that is best adapted to the model. -
|
|
403
|
+
* `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. -
|
|
404
|
+
* `ToolPromptFormat.function_tag`: The tool calls are enclosed in a
|
|
405
|
+
* <function=function_name> tag. - `ToolPromptFormat.python_list`: The tool calls
|
|
406
|
+
* are output as Python syntax -- a list of function calls.
|
|
407
|
+
*/
|
|
408
|
+
tool_prompt_format?: 'json' | 'function_tag' | 'python_list';
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface AgentToolGroupWithArgs {
|
|
295
412
|
args: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
296
413
|
|
|
297
414
|
name: string;
|
|
@@ -309,6 +426,39 @@ export interface TurnCreateParamsStreaming extends TurnCreateParamsBase {
|
|
|
309
426
|
stream: true;
|
|
310
427
|
}
|
|
311
428
|
|
|
429
|
+
export type TurnResumeParams = TurnResumeParamsNonStreaming | TurnResumeParamsStreaming;
|
|
430
|
+
|
|
431
|
+
export interface TurnResumeParamsBase {
|
|
432
|
+
/**
|
|
433
|
+
* The tool call responses to resume the turn with.
|
|
434
|
+
*/
|
|
435
|
+
tool_responses: Array<Shared.ToolResponseMessage>;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Whether to stream the response.
|
|
439
|
+
*/
|
|
440
|
+
stream?: boolean;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export namespace TurnResumeParams {
|
|
444
|
+
export type TurnResumeParamsNonStreaming = TurnAPI.TurnResumeParamsNonStreaming;
|
|
445
|
+
export type TurnResumeParamsStreaming = TurnAPI.TurnResumeParamsStreaming;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface TurnResumeParamsNonStreaming extends TurnResumeParamsBase {
|
|
449
|
+
/**
|
|
450
|
+
* Whether to stream the response.
|
|
451
|
+
*/
|
|
452
|
+
stream?: false;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface TurnResumeParamsStreaming extends TurnResumeParamsBase {
|
|
456
|
+
/**
|
|
457
|
+
* Whether to stream the response.
|
|
458
|
+
*/
|
|
459
|
+
stream: true;
|
|
460
|
+
}
|
|
461
|
+
|
|
312
462
|
export declare namespace TurnResource {
|
|
313
463
|
export {
|
|
314
464
|
type AgentTurnResponseStreamChunk as AgentTurnResponseStreamChunk,
|
|
@@ -318,5 +468,8 @@ export declare namespace TurnResource {
|
|
|
318
468
|
type TurnCreateParams as TurnCreateParams,
|
|
319
469
|
type TurnCreateParamsNonStreaming as TurnCreateParamsNonStreaming,
|
|
320
470
|
type TurnCreateParamsStreaming as TurnCreateParamsStreaming,
|
|
471
|
+
type TurnResumeParams as TurnResumeParams,
|
|
472
|
+
type TurnResumeParamsNonStreaming as TurnResumeParamsNonStreaming,
|
|
473
|
+
type TurnResumeParamsStreaming as TurnResumeParamsStreaming,
|
|
321
474
|
};
|
|
322
475
|
}
|
|
@@ -43,7 +43,7 @@ export interface BatchInferenceChatCompletionParams {
|
|
|
43
43
|
* not be followed. It depends on the Instruction Following capabilities of the
|
|
44
44
|
* model.
|
|
45
45
|
*/
|
|
46
|
-
tool_choice?: 'auto' | 'required';
|
|
46
|
+
tool_choice?: 'auto' | 'required' | 'none';
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Prompt format for calling custom / zero shot tools.
|
|
@@ -0,0 +1,69 @@
|
|
|
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 Benchmarks extends APIResource {
|
|
7
|
+
retrieve(benchmarkId: string, options?: Core.RequestOptions): Core.APIPromise<Benchmark | null> {
|
|
8
|
+
return this._client.get(`/v1/eval/benchmarks/${benchmarkId}`, options);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
list(options?: Core.RequestOptions): Core.APIPromise<BenchmarkListResponse> {
|
|
12
|
+
return (
|
|
13
|
+
this._client.get('/v1/eval/benchmarks', options) as Core.APIPromise<{ data: BenchmarkListResponse }>
|
|
14
|
+
)._thenUnwrap((obj) => obj.data);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
register(body: BenchmarkRegisterParams, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
18
|
+
return this._client.post('/v1/eval/benchmarks', {
|
|
19
|
+
body,
|
|
20
|
+
...options,
|
|
21
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Benchmark {
|
|
27
|
+
dataset_id: string;
|
|
28
|
+
|
|
29
|
+
identifier: string;
|
|
30
|
+
|
|
31
|
+
metadata: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
32
|
+
|
|
33
|
+
provider_id: string;
|
|
34
|
+
|
|
35
|
+
provider_resource_id: string;
|
|
36
|
+
|
|
37
|
+
scoring_functions: Array<string>;
|
|
38
|
+
|
|
39
|
+
type: 'benchmark';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ListBenchmarksResponse {
|
|
43
|
+
data: BenchmarkListResponse;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type BenchmarkListResponse = Array<Benchmark>;
|
|
47
|
+
|
|
48
|
+
export interface BenchmarkRegisterParams {
|
|
49
|
+
benchmark_id: string;
|
|
50
|
+
|
|
51
|
+
dataset_id: string;
|
|
52
|
+
|
|
53
|
+
scoring_functions: Array<string>;
|
|
54
|
+
|
|
55
|
+
metadata?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
|
|
56
|
+
|
|
57
|
+
provider_benchmark_id?: string;
|
|
58
|
+
|
|
59
|
+
provider_id?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare namespace Benchmarks {
|
|
63
|
+
export {
|
|
64
|
+
type Benchmark as Benchmark,
|
|
65
|
+
type ListBenchmarksResponse as ListBenchmarksResponse,
|
|
66
|
+
type BenchmarkListResponse as BenchmarkListResponse,
|
|
67
|
+
type BenchmarkRegisterParams as BenchmarkRegisterParams,
|
|
68
|
+
};
|
|
69
|
+
}
|