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.
Files changed (111) hide show
  1. package/index.d.mts +10 -10
  2. package/index.d.ts +10 -10
  3. package/index.d.ts.map +1 -1
  4. package/index.js +6 -6
  5. package/index.js.map +1 -1
  6. package/index.mjs +6 -6
  7. package/index.mjs.map +1 -1
  8. package/internal/decoders/line.d.ts +3 -2
  9. package/internal/decoders/line.d.ts.map +1 -1
  10. package/internal/decoders/line.js +97 -35
  11. package/internal/decoders/line.js.map +1 -1
  12. package/internal/decoders/line.mjs +95 -34
  13. package/internal/decoders/line.mjs.map +1 -1
  14. package/package.json +1 -1
  15. package/resources/agents/agents.d.ts +3 -2
  16. package/resources/agents/agents.d.ts.map +1 -1
  17. package/resources/agents/agents.js.map +1 -1
  18. package/resources/agents/agents.mjs.map +1 -1
  19. package/resources/agents/index.d.ts +1 -1
  20. package/resources/agents/index.d.ts.map +1 -1
  21. package/resources/agents/index.js.map +1 -1
  22. package/resources/agents/index.mjs.map +1 -1
  23. package/resources/agents/turn.d.ts +109 -9
  24. package/resources/agents/turn.d.ts.map +1 -1
  25. package/resources/agents/turn.js +7 -0
  26. package/resources/agents/turn.js.map +1 -1
  27. package/resources/agents/turn.mjs +7 -0
  28. package/resources/agents/turn.mjs.map +1 -1
  29. package/resources/batch-inference.d.ts +1 -1
  30. package/resources/batch-inference.d.ts.map +1 -1
  31. package/resources/benchmarks.d.ts +32 -0
  32. package/resources/benchmarks.d.ts.map +1 -0
  33. package/resources/benchmarks.js +22 -0
  34. package/resources/benchmarks.js.map +1 -0
  35. package/resources/benchmarks.mjs +18 -0
  36. package/resources/benchmarks.mjs.map +1 -0
  37. package/resources/datasets.d.ts +18 -3
  38. package/resources/datasets.d.ts.map +1 -1
  39. package/resources/eval/eval.d.ts +20 -20
  40. package/resources/eval/eval.d.ts.map +1 -1
  41. package/resources/eval/eval.js +10 -4
  42. package/resources/eval/eval.js.map +1 -1
  43. package/resources/eval/eval.mjs +10 -4
  44. package/resources/eval/eval.mjs.map +1 -1
  45. package/resources/eval/index.d.ts +1 -1
  46. package/resources/eval/index.d.ts.map +1 -1
  47. package/resources/eval/index.js.map +1 -1
  48. package/resources/eval/index.mjs.map +1 -1
  49. package/resources/eval/jobs.d.ts +3 -3
  50. package/resources/eval/jobs.d.ts.map +1 -1
  51. package/resources/eval/jobs.js +6 -6
  52. package/resources/eval/jobs.js.map +1 -1
  53. package/resources/eval/jobs.mjs +6 -6
  54. package/resources/eval/jobs.mjs.map +1 -1
  55. package/resources/eval-tasks.d.ts +6 -17
  56. package/resources/eval-tasks.d.ts.map +1 -1
  57. package/resources/eval-tasks.js.map +1 -1
  58. package/resources/eval-tasks.mjs.map +1 -1
  59. package/resources/index.d.ts +2 -2
  60. package/resources/index.d.ts.map +1 -1
  61. package/resources/index.js +3 -3
  62. package/resources/index.js.map +1 -1
  63. package/resources/index.mjs +1 -1
  64. package/resources/index.mjs.map +1 -1
  65. package/resources/inference.d.ts +35 -9
  66. package/resources/inference.d.ts.map +1 -1
  67. package/resources/shared.d.ts +92 -18
  68. package/resources/shared.d.ts.map +1 -1
  69. package/resources/telemetry.d.ts +6 -8
  70. package/resources/telemetry.d.ts.map +1 -1
  71. package/resources/telemetry.js +6 -13
  72. package/resources/telemetry.js.map +1 -1
  73. package/resources/telemetry.mjs +6 -13
  74. package/resources/telemetry.mjs.map +1 -1
  75. package/resources/tool-runtime/tool-runtime.d.ts +7 -1
  76. package/resources/tool-runtime/tool-runtime.d.ts.map +1 -1
  77. package/resources/tool-runtime/tool-runtime.js.map +1 -1
  78. package/resources/tool-runtime/tool-runtime.mjs.map +1 -1
  79. package/resources/toolgroups.d.ts +12 -3
  80. package/resources/toolgroups.d.ts.map +1 -1
  81. package/resources/toolgroups.js.map +1 -1
  82. package/resources/toolgroups.mjs.map +1 -1
  83. package/src/index.ts +27 -23
  84. package/src/internal/decoders/line.ts +100 -38
  85. package/src/resources/agents/agents.ts +8 -0
  86. package/src/resources/agents/index.ts +3 -0
  87. package/src/resources/agents/turn.ts +162 -9
  88. package/src/resources/batch-inference.ts +1 -1
  89. package/src/resources/benchmarks.ts +69 -0
  90. package/src/resources/datasets.ts +21 -3
  91. package/src/resources/eval/eval.ts +45 -30
  92. package/src/resources/eval/index.ts +3 -1
  93. package/src/resources/eval/jobs.ts +6 -6
  94. package/src/resources/eval-tasks.ts +11 -27
  95. package/src/resources/index.ts +10 -8
  96. package/src/resources/inference.ts +47 -9
  97. package/src/resources/shared.ts +113 -21
  98. package/src/resources/telemetry.ts +9 -27
  99. package/src/resources/tool-runtime/tool-runtime.ts +9 -1
  100. package/src/resources/toolgroups.ts +14 -3
  101. package/src/streaming.ts +1 -43
  102. package/src/version.ts +1 -1
  103. package/streaming.d.ts +0 -2
  104. package/streaming.d.ts.map +1 -1
  105. package/streaming.js +2 -38
  106. package/streaming.js.map +1 -1
  107. package/streaming.mjs +1 -36
  108. package/streaming.mjs.map +1 -1
  109. package/version.d.ts +1 -1
  110. package/version.js +1 -1
  111. package/version.mjs +1 -1
@@ -51,7 +51,13 @@ export interface DatasetRetrieveResponse {
51
51
 
52
52
  type: 'dataset';
53
53
 
54
- url: Shared.URL;
54
+ url: DatasetRetrieveResponse.URL;
55
+ }
56
+
57
+ export namespace DatasetRetrieveResponse {
58
+ export interface URL {
59
+ uri: string;
60
+ }
55
61
  }
56
62
 
57
63
  export type DatasetListResponse = Array<DatasetListResponse.DatasetListResponseItem>;
@@ -70,7 +76,13 @@ export namespace DatasetListResponse {
70
76
 
71
77
  type: 'dataset';
72
78
 
73
- url: Shared.URL;
79
+ url: DatasetListResponseItem.URL;
80
+ }
81
+
82
+ export namespace DatasetListResponseItem {
83
+ export interface URL {
84
+ uri: string;
85
+ }
74
86
  }
75
87
  }
76
88
 
@@ -79,7 +91,7 @@ export interface DatasetRegisterParams {
79
91
 
80
92
  dataset_schema: Record<string, Shared.ParamType>;
81
93
 
82
- url: Shared.URL;
94
+ url: DatasetRegisterParams.URL;
83
95
 
84
96
  metadata?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
85
97
 
@@ -88,6 +100,12 @@ export interface DatasetRegisterParams {
88
100
  provider_id?: string;
89
101
  }
90
102
 
103
+ export namespace DatasetRegisterParams {
104
+ export interface URL {
105
+ uri: string;
106
+ }
107
+ }
108
+
91
109
  export declare namespace Datasets {
92
110
  export {
93
111
  type ListDatasetsResponse as ListDatasetsResponse,
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { APIResource } from '../../resource';
4
4
  import * as Core from '../../core';
5
- import * as EvalAPI from './eval';
6
5
  import * as ScoringFunctionsAPI from '../scoring-functions';
7
6
  import * as Shared from '../shared';
8
7
  import * as JobsAPI from './jobs';
@@ -12,18 +11,42 @@ export class Eval extends APIResource {
12
11
  jobs: JobsAPI.Jobs = new JobsAPI.Jobs(this._client);
13
12
 
14
13
  evaluateRows(
15
- taskId: string,
14
+ benchmarkId: string,
16
15
  body: EvalEvaluateRowsParams,
17
16
  options?: Core.RequestOptions,
18
17
  ): Core.APIPromise<EvaluateResponse> {
19
- return this._client.post(`/v1/eval/tasks/${taskId}/evaluations`, { body, ...options });
18
+ return this._client.post(`/v1/eval/benchmarks/${benchmarkId}/evaluations`, { body, ...options });
20
19
  }
21
20
 
22
- runEval(taskId: string, body: EvalRunEvalParams, options?: Core.RequestOptions): Core.APIPromise<Job> {
23
- return this._client.post(`/v1/eval/tasks/${taskId}/jobs`, { body, ...options });
21
+ evaluateRowsAlpha(
22
+ benchmarkId: string,
23
+ body: EvalEvaluateRowsAlphaParams,
24
+ options?: Core.RequestOptions,
25
+ ): Core.APIPromise<EvaluateResponse> {
26
+ return this._client.post(`/v1/eval/benchmarks/${benchmarkId}/evaluations`, { body, ...options });
27
+ }
28
+
29
+ runEval(benchmarkId: string, body: EvalRunEvalParams, options?: Core.RequestOptions): Core.APIPromise<Job> {
30
+ return this._client.post(`/v1/eval/benchmarks/${benchmarkId}/jobs`, { body, ...options });
31
+ }
32
+
33
+ runEvalAlpha(
34
+ benchmarkId: string,
35
+ body: EvalRunEvalAlphaParams,
36
+ options?: Core.RequestOptions,
37
+ ): Core.APIPromise<Job> {
38
+ return this._client.post(`/v1/eval/benchmarks/${benchmarkId}/jobs`, { body, ...options });
24
39
  }
25
40
  }
26
41
 
42
+ export interface BenchmarkConfig {
43
+ eval_candidate: EvalCandidate;
44
+
45
+ scoring_params: Record<string, ScoringFunctionsAPI.ScoringFnParams>;
46
+
47
+ num_examples?: number;
48
+ }
49
+
27
50
  export type EvalCandidate = EvalCandidate.ModelCandidate | EvalCandidate.AgentCandidate;
28
51
 
29
52
  export namespace EvalCandidate {
@@ -47,28 +70,6 @@ export namespace EvalCandidate {
47
70
  }
48
71
  }
49
72
 
50
- export type EvalTaskConfig = EvalTaskConfig.BenchmarkEvalTaskConfig | EvalTaskConfig.AppEvalTaskConfig;
51
-
52
- export namespace EvalTaskConfig {
53
- export interface BenchmarkEvalTaskConfig {
54
- eval_candidate: EvalAPI.EvalCandidate;
55
-
56
- type: 'benchmark';
57
-
58
- num_examples?: number;
59
- }
60
-
61
- export interface AppEvalTaskConfig {
62
- eval_candidate: EvalAPI.EvalCandidate;
63
-
64
- scoring_params: Record<string, ScoringFunctionsAPI.ScoringFnParams>;
65
-
66
- type: 'app';
67
-
68
- num_examples?: number;
69
- }
70
- }
71
-
72
73
  export interface EvaluateResponse {
73
74
  generations: Array<Record<string, boolean | number | string | Array<unknown> | unknown | null>>;
74
75
 
@@ -84,23 +85,37 @@ export interface EvalEvaluateRowsParams {
84
85
 
85
86
  scoring_functions: Array<string>;
86
87
 
87
- task_config: EvalTaskConfig;
88
+ task_config: BenchmarkConfig;
89
+ }
90
+
91
+ export interface EvalEvaluateRowsAlphaParams {
92
+ input_rows: Array<Record<string, boolean | number | string | Array<unknown> | unknown | null>>;
93
+
94
+ scoring_functions: Array<string>;
95
+
96
+ task_config: BenchmarkConfig;
88
97
  }
89
98
 
90
99
  export interface EvalRunEvalParams {
91
- task_config: EvalTaskConfig;
100
+ task_config: BenchmarkConfig;
101
+ }
102
+
103
+ export interface EvalRunEvalAlphaParams {
104
+ task_config: BenchmarkConfig;
92
105
  }
93
106
 
94
107
  Eval.Jobs = Jobs;
95
108
 
96
109
  export declare namespace Eval {
97
110
  export {
111
+ type BenchmarkConfig as BenchmarkConfig,
98
112
  type EvalCandidate as EvalCandidate,
99
- type EvalTaskConfig as EvalTaskConfig,
100
113
  type EvaluateResponse as EvaluateResponse,
101
114
  type Job as Job,
102
115
  type EvalEvaluateRowsParams as EvalEvaluateRowsParams,
116
+ type EvalEvaluateRowsAlphaParams as EvalEvaluateRowsAlphaParams,
103
117
  type EvalRunEvalParams as EvalRunEvalParams,
118
+ type EvalRunEvalAlphaParams as EvalRunEvalAlphaParams,
104
119
  };
105
120
 
106
121
  export { Jobs as Jobs, type JobStatusResponse as JobStatusResponse };
@@ -2,11 +2,13 @@
2
2
 
3
3
  export {
4
4
  Eval,
5
+ type BenchmarkConfig,
5
6
  type EvalCandidate,
6
- type EvalTaskConfig,
7
7
  type EvaluateResponse,
8
8
  type Job,
9
9
  type EvalEvaluateRowsParams,
10
+ type EvalEvaluateRowsAlphaParams,
10
11
  type EvalRunEvalParams,
12
+ type EvalRunEvalAlphaParams,
11
13
  } from './eval';
12
14
  export { Jobs, type JobStatusResponse } from './jobs';
@@ -6,26 +6,26 @@ import * as EvalAPI from './eval';
6
6
 
7
7
  export class Jobs extends APIResource {
8
8
  retrieve(
9
- taskId: string,
9
+ benchmarkId: string,
10
10
  jobId: string,
11
11
  options?: Core.RequestOptions,
12
12
  ): Core.APIPromise<EvalAPI.EvaluateResponse> {
13
- return this._client.get(`/v1/eval/tasks/${taskId}/jobs/${jobId}/result`, options);
13
+ return this._client.get(`/v1/eval/benchmarks/${benchmarkId}/jobs/${jobId}/result`, options);
14
14
  }
15
15
 
16
- cancel(taskId: string, jobId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
17
- return this._client.delete(`/v1/eval/tasks/${taskId}/jobs/${jobId}`, {
16
+ cancel(benchmarkId: string, jobId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
17
+ return this._client.delete(`/v1/eval/benchmarks/${benchmarkId}/jobs/${jobId}`, {
18
18
  ...options,
19
19
  headers: { Accept: '*/*', ...options?.headers },
20
20
  });
21
21
  }
22
22
 
23
23
  status(
24
- taskId: string,
24
+ benchmarkId: string,
25
25
  jobId: string,
26
26
  options?: Core.RequestOptions,
27
27
  ): Core.APIPromise<JobStatusResponse | null> {
28
- return this._client.get(`/v1/eval/tasks/${taskId}/jobs/${jobId}`, options);
28
+ return this._client.get(`/v1/eval/benchmarks/${benchmarkId}/jobs/${jobId}`, options);
29
29
  }
30
30
  }
31
31
 
@@ -2,15 +2,21 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
+ import * as BenchmarksAPI from './benchmarks';
5
6
 
6
7
  export class EvalTasks extends APIResource {
7
- retrieve(evalTaskId: string, options?: Core.RequestOptions): Core.APIPromise<EvalTask | null> {
8
+ retrieve(
9
+ evalTaskId: string,
10
+ options?: Core.RequestOptions,
11
+ ): Core.APIPromise<BenchmarksAPI.Benchmark | null> {
8
12
  return this._client.get(`/v1/eval-tasks/${evalTaskId}`, options);
9
13
  }
10
14
 
11
- list(options?: Core.RequestOptions): Core.APIPromise<EvalTaskListResponse> {
15
+ list(options?: Core.RequestOptions): Core.APIPromise<BenchmarksAPI.BenchmarkListResponse> {
12
16
  return (
13
- this._client.get('/v1/eval-tasks', options) as Core.APIPromise<{ data: EvalTaskListResponse }>
17
+ this._client.get('/v1/eval-tasks', options) as Core.APIPromise<{
18
+ data: BenchmarksAPI.BenchmarkListResponse;
19
+ }>
14
20
  )._thenUnwrap((obj) => obj.data);
15
21
  }
16
22
 
@@ -23,27 +29,7 @@ export class EvalTasks extends APIResource {
23
29
  }
24
30
  }
25
31
 
26
- export interface EvalTask {
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: 'eval_task';
40
- }
41
-
42
- export interface ListEvalTasksResponse {
43
- data: EvalTaskListResponse;
44
- }
45
-
46
- export type EvalTaskListResponse = Array<EvalTask>;
32
+ export type EvalTaskListResponse = Array<BenchmarksAPI.Benchmark>;
47
33
 
48
34
  export interface EvalTaskRegisterParams {
49
35
  dataset_id: string;
@@ -54,15 +40,13 @@ export interface EvalTaskRegisterParams {
54
40
 
55
41
  metadata?: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
56
42
 
57
- provider_eval_task_id?: string;
43
+ provider_benchmark_id?: string;
58
44
 
59
45
  provider_id?: string;
60
46
  }
61
47
 
62
48
  export declare namespace EvalTasks {
63
49
  export {
64
- type EvalTask as EvalTask,
65
- type ListEvalTasksResponse as ListEvalTasksResponse,
66
50
  type EvalTaskListResponse as EvalTaskListResponse,
67
51
  type EvalTaskRegisterParams as EvalTaskRegisterParams,
68
52
  };
@@ -17,6 +17,13 @@ export {
17
17
  type BatchInferenceChatCompletionParams,
18
18
  type BatchInferenceCompletionParams,
19
19
  } from './batch-inference';
20
+ export {
21
+ Benchmarks,
22
+ type Benchmark,
23
+ type ListBenchmarksResponse,
24
+ type BenchmarkListResponse,
25
+ type BenchmarkRegisterParams,
26
+ } from './benchmarks';
20
27
  export {
21
28
  Datasetio,
22
29
  type PaginatedRowsResult,
@@ -32,20 +39,15 @@ export {
32
39
  } from './datasets';
33
40
  export {
34
41
  Eval,
42
+ type BenchmarkConfig,
35
43
  type EvalCandidate,
36
- type EvalTaskConfig,
37
44
  type EvaluateResponse,
38
45
  type Job,
39
46
  type EvalEvaluateRowsParams,
47
+ type EvalEvaluateRowsAlphaParams,
40
48
  type EvalRunEvalParams,
49
+ type EvalRunEvalAlphaParams,
41
50
  } from './eval/eval';
42
- export {
43
- EvalTasks,
44
- type EvalTask,
45
- type ListEvalTasksResponse,
46
- type EvalTaskListResponse,
47
- type EvalTaskRegisterParams,
48
- } from './eval-tasks';
49
51
  export {
50
52
  Inference,
51
53
  type ChatCompletionResponseStreamChunk,
@@ -79,6 +79,8 @@ export interface ChatCompletionResponseStreamChunk {
79
79
  * The event containing the new content
80
80
  */
81
81
  event: ChatCompletionResponseStreamChunk.Event;
82
+
83
+ metrics?: Array<ChatCompletionResponseStreamChunk.Metric>;
82
84
  }
83
85
 
84
86
  export namespace ChatCompletionResponseStreamChunk {
@@ -107,6 +109,24 @@ export namespace ChatCompletionResponseStreamChunk {
107
109
  */
108
110
  stop_reason?: 'end_of_turn' | 'end_of_message' | 'out_of_tokens';
109
111
  }
112
+
113
+ export interface Metric {
114
+ metric: string;
115
+
116
+ span_id: string;
117
+
118
+ timestamp: string;
119
+
120
+ trace_id: string;
121
+
122
+ type: 'metric';
123
+
124
+ unit: string;
125
+
126
+ value: number;
127
+
128
+ attributes?: Record<string, string | number | boolean | null>;
129
+ }
110
130
  }
111
131
 
112
132
  /**
@@ -196,7 +216,7 @@ export interface InferenceChatCompletionParamsBase {
196
216
  * (Optional) Whether tool use is required or automatic. Defaults to
197
217
  * ToolChoice.auto. .. deprecated:: Use tool_config instead.
198
218
  */
199
- tool_choice?: 'auto' | 'required';
219
+ tool_choice?: 'auto' | 'required' | 'none';
200
220
 
201
221
  /**
202
222
  * (Optional) Configuration for tool use.
@@ -244,13 +264,13 @@ export namespace InferenceChatCompletionParams {
244
264
  * the string '{{function_definitions}}' to indicate where the function definitions
245
265
  * should be inserted.
246
266
  */
247
- system_message_behavior: 'append' | 'replace';
267
+ system_message_behavior?: 'append' | 'replace';
248
268
 
249
269
  /**
250
- * (Optional) Whether tool use is required or automatic. Defaults to
251
- * ToolChoice.auto.
270
+ * (Optional) Whether tool use is automatic, required, or none. Can also specify a
271
+ * tool name to use a specific tool. Defaults to ToolChoice.auto.
252
272
  */
253
- tool_choice?: 'auto' | 'required';
273
+ tool_choice?: 'auto' | 'required' | 'none' | (string & {});
254
274
 
255
275
  /**
256
276
  * (Optional) Instructs the model how to format tool calls. By default, Llama Stack
@@ -365,17 +385,35 @@ export interface InferenceCompletionParamsStreaming extends InferenceCompletionP
365
385
 
366
386
  export interface InferenceEmbeddingsParams {
367
387
  /**
368
- * List of contents to generate embeddings for. Note that content can be
369
- * multimodal. The behavior depends on the model and provider. Some models may only
370
- * support text.
388
+ * List of contents to generate embeddings for. Each content can be a string or an
389
+ * InterleavedContentItem (and hence can be multimodal). The behavior depends on
390
+ * the model and provider. Some models may only support text.
371
391
  */
372
- contents: Array<Shared.InterleavedContent>;
392
+ contents: Array<string> | Array<Shared.InterleavedContentItem>;
373
393
 
374
394
  /**
375
395
  * The identifier of the model to use. The model must be an embedding model
376
396
  * registered with Llama Stack and available via the /models endpoint.
377
397
  */
378
398
  model_id: string;
399
+
400
+ /**
401
+ * (Optional) Output dimensionality for the embeddings. Only supported by
402
+ * Matryoshka models.
403
+ */
404
+ output_dimension?: number;
405
+
406
+ /**
407
+ * (Optional) How is the embedding being used? This is only supported by asymmetric
408
+ * embedding models.
409
+ */
410
+ task_type?: 'query' | 'document';
411
+
412
+ /**
413
+ * (Optional) Config for how to truncate text for embedding when text is longer
414
+ * than the model's max sequence length.
415
+ */
416
+ text_truncation?: 'none' | 'start' | 'end';
379
417
  }
380
418
 
381
419
  export declare namespace Inference {
@@ -5,18 +5,18 @@ import * as InferenceAPI from './inference';
5
5
  import * as ToolRuntimeAPI from './tool-runtime/tool-runtime';
6
6
 
7
7
  export interface AgentConfig {
8
- enable_session_persistence: boolean;
9
-
10
8
  instructions: string;
11
9
 
12
- max_infer_iters: number;
13
-
14
10
  model: string;
15
11
 
16
12
  client_tools?: Array<ToolRuntimeAPI.ToolDef>;
17
13
 
14
+ enable_session_persistence?: boolean;
15
+
18
16
  input_shields?: Array<string>;
19
17
 
18
+ max_infer_iters?: number;
19
+
20
20
  output_shields?: Array<string>;
21
21
 
22
22
  /**
@@ -27,22 +27,58 @@ export interface AgentConfig {
27
27
  sampling_params?: SamplingParams;
28
28
 
29
29
  /**
30
- * Whether tool use is required or automatic. This is a hint to the model which may
31
- * not be followed. It depends on the Instruction Following capabilities of the
32
- * model.
30
+ * @deprecated Whether tool use is required or automatic. This is a hint to the
31
+ * model which may not be followed. It depends on the Instruction Following
32
+ * capabilities of the model.
33
+ */
34
+ tool_choice?: 'auto' | 'required' | 'none';
35
+
36
+ /**
37
+ * Configuration for tool use.
33
38
  */
34
- tool_choice?: 'auto' | 'required';
39
+ tool_config?: AgentConfig.ToolConfig;
35
40
 
36
41
  /**
37
- * Prompt format for calling custom / zero shot tools.
42
+ * @deprecated Prompt format for calling custom / zero shot tools.
38
43
  */
39
44
  tool_prompt_format?: 'json' | 'function_tag' | 'python_list';
40
45
 
41
- toolgroups?: Array<string | AgentConfig.UnionMember1>;
46
+ toolgroups?: Array<string | AgentConfig.AgentToolGroupWithArgs>;
42
47
  }
43
48
 
44
49
  export namespace AgentConfig {
45
- export interface UnionMember1 {
50
+ /**
51
+ * Configuration for tool use.
52
+ */
53
+ export interface ToolConfig {
54
+ /**
55
+ * (Optional) Config for how to override the default system prompt. -
56
+ * `SystemMessageBehavior.append`: Appends the provided system message to the
57
+ * default system prompt. - `SystemMessageBehavior.replace`: Replaces the default
58
+ * system prompt with the provided system message. The system message can include
59
+ * the string '{{function_definitions}}' to indicate where the function definitions
60
+ * should be inserted.
61
+ */
62
+ system_message_behavior?: 'append' | 'replace';
63
+
64
+ /**
65
+ * (Optional) Whether tool use is automatic, required, or none. Can also specify a
66
+ * tool name to use a specific tool. Defaults to ToolChoice.auto.
67
+ */
68
+ tool_choice?: 'auto' | 'required' | 'none' | (string & {});
69
+
70
+ /**
71
+ * (Optional) Instructs the model how to format tool calls. By default, Llama Stack
72
+ * will attempt to use a format that is best adapted to the model. -
73
+ * `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. -
74
+ * `ToolPromptFormat.function_tag`: The tool calls are enclosed in a
75
+ * <function=function_name> tag. - `ToolPromptFormat.python_list`: The tool calls
76
+ * are output as Python syntax -- a list of function calls.
77
+ */
78
+ tool_prompt_format?: 'json' | 'function_tag' | 'python_list';
79
+ }
80
+
81
+ export interface AgentToolGroupWithArgs {
46
82
  args: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
47
83
 
48
84
  name: string;
@@ -66,6 +102,28 @@ export interface ChatCompletionResponse {
66
102
  * Optional log probabilities for generated tokens
67
103
  */
68
104
  logprobs?: Array<InferenceAPI.TokenLogProbs>;
105
+
106
+ metrics?: Array<ChatCompletionResponse.Metric>;
107
+ }
108
+
109
+ export namespace ChatCompletionResponse {
110
+ export interface Metric {
111
+ metric: string;
112
+
113
+ span_id: string;
114
+
115
+ timestamp: string;
116
+
117
+ trace_id: string;
118
+
119
+ type: 'metric';
120
+
121
+ unit: string;
122
+
123
+ value: number;
124
+
125
+ attributes?: Record<string, string | number | boolean | null>;
126
+ }
69
127
  }
70
128
 
71
129
  /**
@@ -95,7 +153,7 @@ export interface CompletionMessage {
95
153
  /**
96
154
  * List of tool calls. Each tool call is a ToolCall object.
97
155
  */
98
- tool_calls: Array<ToolCall>;
156
+ tool_calls?: Array<ToolCall>;
99
157
  }
100
158
 
101
159
  export type ContentDelta = ContentDelta.TextDelta | ContentDelta.ImageDelta | ContentDelta.ToolCallDelta;
@@ -116,7 +174,7 @@ export namespace ContentDelta {
116
174
  export interface ToolCallDelta {
117
175
  parse_status: 'started' | 'in_progress' | 'failed' | 'succeeded';
118
176
 
119
- tool_call: string | Shared.ToolCall;
177
+ tool_call: Shared.ToolCallOrString;
120
178
 
121
179
  type: 'tool_call';
122
180
  }
@@ -131,7 +189,7 @@ export interface Document {
131
189
  | Document.ImageContentItem
132
190
  | Document.TextContentItem
133
191
  | Array<InterleavedContentItem>
134
- | URL;
192
+ | Document.URL;
135
193
 
136
194
  document_id: string;
137
195
 
@@ -170,7 +228,17 @@ export namespace Document {
170
228
  * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
171
229
  * Note that URL could have length limits.
172
230
  */
173
- url?: Shared.URL;
231
+ url?: Image.URL;
232
+ }
233
+
234
+ export namespace Image {
235
+ /**
236
+ * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
237
+ * Note that URL could have length limits.
238
+ */
239
+ export interface URL {
240
+ uri: string;
241
+ }
174
242
  }
175
243
  }
176
244
 
@@ -188,6 +256,10 @@ export namespace Document {
188
256
  */
189
257
  type: 'text';
190
258
  }
259
+
260
+ export interface URL {
261
+ uri: string;
262
+ }
191
263
  }
192
264
 
193
265
  /**
@@ -229,7 +301,17 @@ export namespace InterleavedContent {
229
301
  * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
230
302
  * Note that URL could have length limits.
231
303
  */
232
- url?: Shared.URL;
304
+ url?: Image.URL;
305
+ }
306
+
307
+ export namespace Image {
308
+ /**
309
+ * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
310
+ * Note that URL could have length limits.
311
+ */
312
+ export interface URL {
313
+ uri: string;
314
+ }
233
315
  }
234
316
  }
235
317
 
@@ -286,7 +368,17 @@ export namespace InterleavedContentItem {
286
368
  * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
287
369
  * Note that URL could have length limits.
288
370
  */
289
- url?: Shared.URL;
371
+ url?: Image.URL;
372
+ }
373
+
374
+ export namespace Image {
375
+ /**
376
+ * A URL of the image or data URL in the format of data:image/{type};base64,{data}.
377
+ * Note that URL could have length limits.
378
+ */
379
+ export interface URL {
380
+ uri: string;
381
+ }
290
382
  }
291
383
  }
292
384
 
@@ -394,6 +486,8 @@ export namespace QueryGeneratorConfig {
394
486
  }
395
487
 
396
488
  export interface QueryResult {
489
+ metadata: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
490
+
397
491
  /**
398
492
  * A image content item
399
493
  */
@@ -530,6 +624,8 @@ export interface ToolCall {
530
624
  tool_name: 'brave_search' | 'wolfram_alpha' | 'photogen' | 'code_interpreter' | (string & {});
531
625
  }
532
626
 
627
+ export type ToolCallOrString = string | ToolCall;
628
+
533
629
  export interface ToolParamDefinition {
534
630
  param_type: string;
535
631
 
@@ -565,10 +661,6 @@ export interface ToolResponseMessage {
565
661
  tool_name: 'brave_search' | 'wolfram_alpha' | 'photogen' | 'code_interpreter' | (string & {});
566
662
  }
567
663
 
568
- export interface URL {
569
- uri: string;
570
- }
571
-
572
664
  /**
573
665
  * A message from the user in a chat conversation.
574
666
  */