llama-stack-client 0.2.0 → 0.2.3-rc5

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 (124) hide show
  1. package/_shims/index.d.ts +2 -0
  2. package/_shims/index.js +5 -1
  3. package/_shims/index.mjs +5 -1
  4. package/core.d.ts +12 -1
  5. package/core.d.ts.map +1 -1
  6. package/core.js +8 -6
  7. package/core.js.map +1 -1
  8. package/core.mjs +9 -7
  9. package/core.mjs.map +1 -1
  10. package/index.d.mts +10 -7
  11. package/index.d.ts +10 -7
  12. package/index.d.ts.map +1 -1
  13. package/index.js +6 -3
  14. package/index.js.map +1 -1
  15. package/index.mjs +6 -3
  16. package/index.mjs.map +1 -1
  17. package/package.json +1 -1
  18. package/resources/chat/chat.d.ts +153 -0
  19. package/resources/chat/chat.d.ts.map +1 -0
  20. package/resources/chat/chat.js +39 -0
  21. package/resources/chat/chat.js.map +1 -0
  22. package/resources/chat/chat.mjs +12 -0
  23. package/resources/chat/chat.mjs.map +1 -0
  24. package/resources/chat/completions.d.ts +632 -0
  25. package/resources/chat/completions.d.ts.map +1 -0
  26. package/resources/chat/completions.js +16 -0
  27. package/resources/chat/completions.js.map +1 -0
  28. package/resources/chat/completions.mjs +12 -0
  29. package/resources/chat/completions.mjs.map +1 -0
  30. package/resources/chat/index.d.ts +3 -0
  31. package/resources/chat/index.d.ts.map +1 -0
  32. package/resources/chat/index.js +9 -0
  33. package/resources/chat/index.js.map +1 -0
  34. package/resources/chat/index.mjs +4 -0
  35. package/resources/chat/index.mjs.map +1 -0
  36. package/resources/chat.d.ts +2 -0
  37. package/resources/chat.d.ts.map +1 -0
  38. package/resources/chat.js +19 -0
  39. package/resources/chat.js.map +1 -0
  40. package/resources/chat.mjs +3 -0
  41. package/resources/chat.mjs.map +1 -0
  42. package/resources/completions.d.ts +193 -0
  43. package/resources/completions.d.ts.map +1 -0
  44. package/resources/completions.js +16 -0
  45. package/resources/completions.js.map +1 -0
  46. package/resources/completions.mjs +12 -0
  47. package/resources/completions.mjs.map +1 -0
  48. package/resources/datasets.d.ts +13 -6
  49. package/resources/datasets.d.ts.map +1 -1
  50. package/resources/datasets.js.map +1 -1
  51. package/resources/datasets.mjs.map +1 -1
  52. package/resources/eval/eval.d.ts +1 -1
  53. package/resources/eval/eval.d.ts.map +1 -1
  54. package/resources/index.d.ts +4 -3
  55. package/resources/index.d.ts.map +1 -1
  56. package/resources/index.js +5 -3
  57. package/resources/index.js.map +1 -1
  58. package/resources/index.mjs +2 -1
  59. package/resources/index.mjs.map +1 -1
  60. package/resources/inference.d.ts +86 -1
  61. package/resources/inference.d.ts.map +1 -1
  62. package/resources/inference.js +6 -0
  63. package/resources/inference.js.map +1 -1
  64. package/resources/inference.mjs +6 -0
  65. package/resources/inference.mjs.map +1 -1
  66. package/resources/inspect.d.ts +2 -1
  67. package/resources/inspect.d.ts.map +1 -1
  68. package/resources/post-training/job.d.ts +1 -1
  69. package/resources/post-training/job.d.ts.map +1 -1
  70. package/resources/post-training/post-training.d.ts +19 -19
  71. package/resources/post-training/post-training.d.ts.map +1 -1
  72. package/resources/shared.d.ts +40 -1
  73. package/resources/shared.d.ts.map +1 -1
  74. package/resources/tool-runtime/index.d.ts +1 -1
  75. package/resources/tool-runtime/index.d.ts.map +1 -1
  76. package/resources/tool-runtime/index.js.map +1 -1
  77. package/resources/tool-runtime/index.mjs.map +1 -1
  78. package/resources/tool-runtime/tool-runtime.d.ts +4 -4
  79. package/resources/tool-runtime/tool-runtime.d.ts.map +1 -1
  80. package/resources/tool-runtime/tool-runtime.js +1 -9
  81. package/resources/tool-runtime/tool-runtime.js.map +1 -1
  82. package/resources/tool-runtime/tool-runtime.mjs +1 -9
  83. package/resources/tool-runtime/tool-runtime.mjs.map +1 -1
  84. package/src/_shims/index.d.ts +2 -0
  85. package/src/_shims/index.js +5 -1
  86. package/src/_shims/index.mjs +5 -1
  87. package/src/core.ts +24 -5
  88. package/src/index.ts +30 -15
  89. package/src/resources/chat/chat.ts +206 -0
  90. package/src/resources/chat/completions.ts +890 -0
  91. package/src/resources/chat/index.ts +10 -0
  92. package/src/resources/chat.ts +3 -0
  93. package/src/resources/completions.ts +268 -0
  94. package/src/resources/datasets.ts +13 -6
  95. package/src/resources/eval/eval.ts +1 -1
  96. package/src/resources/index.ts +12 -6
  97. package/src/resources/inference.ts +121 -0
  98. package/src/resources/inspect.ts +3 -1
  99. package/src/resources/post-training/job.ts +1 -1
  100. package/src/resources/post-training/post-training.ts +32 -32
  101. package/src/resources/shared.ts +42 -1
  102. package/src/resources/tool-runtime/index.ts +1 -0
  103. package/src/resources/tool-runtime/tool-runtime.ts +11 -12
  104. package/src/version.ts +1 -1
  105. package/version.d.ts +1 -1
  106. package/version.d.ts.map +1 -1
  107. package/version.js +1 -1
  108. package/version.js.map +1 -1
  109. package/version.mjs +1 -1
  110. package/version.mjs.map +1 -1
  111. package/internal/decoders/jsonl.d.ts +0 -12
  112. package/internal/decoders/jsonl.d.ts.map +0 -1
  113. package/internal/decoders/jsonl.js +0 -35
  114. package/internal/decoders/jsonl.js.map +0 -1
  115. package/internal/decoders/jsonl.mjs +0 -31
  116. package/internal/decoders/jsonl.mjs.map +0 -1
  117. package/resources/batch-inference.d.ts +0 -66
  118. package/resources/batch-inference.d.ts.map +0 -1
  119. package/resources/batch-inference.js +0 -15
  120. package/resources/batch-inference.js.map +0 -1
  121. package/resources/batch-inference.mjs +0 -11
  122. package/resources/batch-inference.mjs.map +0 -1
  123. package/src/internal/decoders/jsonl.ts +0 -41
  124. package/src/resources/batch-inference.ts +0 -103
@@ -3,5 +3,9 @@
3
3
  */
4
4
  import * as shims from './registry.mjs';
5
5
  import * as auto from "./auto/runtime";
6
- if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
6
+ export const init = () => {
7
+ if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
8
+ };
7
9
  export * from './registry.mjs';
10
+
11
+ init();
package/src/core.ts CHANGED
@@ -17,7 +17,12 @@ import {
17
17
  type RequestInit,
18
18
  type Response,
19
19
  type HeadersInit,
20
+ init,
20
21
  } from './_shims/index';
22
+
23
+ // try running side effects outside of _shims/index to workaround https://github.com/vercel/next.js/issues/76881
24
+ init();
25
+
21
26
  export { type Response };
22
27
  import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
23
28
  export {
@@ -29,6 +34,20 @@ export {
29
34
 
30
35
  export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
31
36
 
37
+ /**
38
+ * An alias to the builtin `Array` type so we can
39
+ * easily alias it in import statements if there are name clashes.
40
+ */
41
+ type _Array<T> = Array<T>;
42
+
43
+ /**
44
+ * An alias to the builtin `Record` type so we can
45
+ * easily alias it in import statements if there are name clashes.
46
+ */
47
+ type _Record<K extends keyof any, T> = Record<K, T>;
48
+
49
+ export type { _Array as Array, _Record as Record };
50
+
32
51
  type PromiseOrValue<T> = T | Promise<T>;
33
52
 
34
53
  type APIResponseProps = {
@@ -291,10 +310,10 @@ export abstract class APIClient {
291
310
  }
292
311
 
293
312
  buildRequest<Req>(
294
- options: FinalRequestOptions<Req>,
313
+ inputOptions: FinalRequestOptions<Req>,
295
314
  { retryCount = 0 }: { retryCount?: number } = {},
296
315
  ): { req: RequestInit; url: string; timeout: number } {
297
- options = { ...options };
316
+ const options = { ...inputOptions };
298
317
  const { method, path, query, headers: headers = {} } = options;
299
318
 
300
319
  const body =
@@ -322,8 +341,8 @@ export abstract class APIClient {
322
341
  }
323
342
 
324
343
  if (this.idempotencyHeader && method !== 'get') {
325
- if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
326
- headers[this.idempotencyHeader] = options.idempotencyKey;
344
+ if (!inputOptions.idempotencyKey) inputOptions.idempotencyKey = this.defaultIdempotencyKey();
345
+ headers[this.idempotencyHeader] = inputOptions.idempotencyKey;
327
346
  }
328
347
 
329
348
  const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount });
@@ -380,7 +399,7 @@ export abstract class APIClient {
380
399
  getHeader(headers, 'x-stainless-timeout') === undefined &&
381
400
  options.timeout
382
401
  ) {
383
- reqHeaders['x-stainless-timeout'] = String(options.timeout);
402
+ reqHeaders['x-stainless-timeout'] = String(Math.trunc(options.timeout / 1000));
384
403
  }
385
404
 
386
405
  this.validateHeaders(reqHeaders, headers);
package/src/index.ts CHANGED
@@ -8,12 +8,6 @@ import * as Pagination from './pagination';
8
8
  import { type DatasetsIterrowsParams, DatasetsIterrowsResponse } from './pagination';
9
9
  import * as Uploads from './uploads';
10
10
  import * as API from './resources/index';
11
- import {
12
- BatchInference,
13
- BatchInferenceChatCompletionParams,
14
- BatchInferenceChatCompletionResponse,
15
- BatchInferenceCompletionParams,
16
- } from './resources/batch-inference';
17
11
  import {
18
12
  Benchmark,
19
13
  BenchmarkListResponse,
@@ -21,6 +15,13 @@ import {
21
15
  Benchmarks,
22
16
  ListBenchmarksResponse,
23
17
  } from './resources/benchmarks';
18
+ import {
19
+ CompletionCreateParams,
20
+ CompletionCreateParamsNonStreaming,
21
+ CompletionCreateParamsStreaming,
22
+ CompletionCreateResponse,
23
+ Completions,
24
+ } from './resources/completions';
24
25
  import {
25
26
  DatasetIterrowsParams,
26
27
  DatasetIterrowsResponse,
@@ -36,6 +37,9 @@ import {
36
37
  CompletionResponse,
37
38
  EmbeddingsResponse,
38
39
  Inference,
40
+ InferenceBatchChatCompletionParams,
41
+ InferenceBatchChatCompletionResponse,
42
+ InferenceBatchCompletionParams,
39
43
  InferenceChatCompletionParams,
40
44
  InferenceChatCompletionParamsNonStreaming,
41
45
  InferenceChatCompletionParamsStreaming,
@@ -132,6 +136,7 @@ import {
132
136
  ToolExecutionStep,
133
137
  ToolResponse,
134
138
  } from './resources/agents/agents';
139
+ import { Chat, ChatCompletionChunk } from './resources/chat/chat';
135
140
  import {
136
141
  BenchmarkConfig,
137
142
  Eval,
@@ -157,6 +162,7 @@ import {
157
162
  ToolRuntime,
158
163
  ToolRuntimeInvokeToolParams,
159
164
  ToolRuntimeListToolsParams,
165
+ ToolRuntimeListToolsResponse,
160
166
  } from './resources/tool-runtime/tool-runtime';
161
167
 
162
168
  export interface ClientOptions {
@@ -270,11 +276,12 @@ export class LlamaStackClient extends Core.APIClient {
270
276
  tools: API.Tools = new API.Tools(this);
271
277
  toolRuntime: API.ToolRuntime = new API.ToolRuntime(this);
272
278
  agents: API.Agents = new API.Agents(this);
273
- batchInference: API.BatchInference = new API.BatchInference(this);
274
279
  datasets: API.Datasets = new API.Datasets(this);
275
280
  eval: API.Eval = new API.Eval(this);
276
281
  inspect: API.Inspect = new API.Inspect(this);
277
282
  inference: API.Inference = new API.Inference(this);
283
+ chat: API.Chat = new API.Chat(this);
284
+ completions: API.Completions = new API.Completions(this);
278
285
  vectorIo: API.VectorIo = new API.VectorIo(this);
279
286
  vectorDBs: API.VectorDBs = new API.VectorDBs(this);
280
287
  models: API.Models = new API.Models(this);
@@ -336,11 +343,12 @@ LlamaStackClient.Toolgroups = Toolgroups;
336
343
  LlamaStackClient.Tools = Tools;
337
344
  LlamaStackClient.ToolRuntime = ToolRuntime;
338
345
  LlamaStackClient.Agents = Agents;
339
- LlamaStackClient.BatchInference = BatchInference;
340
346
  LlamaStackClient.Datasets = Datasets;
341
347
  LlamaStackClient.Eval = Eval;
342
348
  LlamaStackClient.Inspect = Inspect;
343
349
  LlamaStackClient.Inference = Inference;
350
+ LlamaStackClient.Chat = Chat;
351
+ LlamaStackClient.Completions = Completions;
344
352
  LlamaStackClient.VectorIo = VectorIo;
345
353
  LlamaStackClient.VectorDBs = VectorDBs;
346
354
  LlamaStackClient.Models = Models;
@@ -383,6 +391,7 @@ export declare namespace LlamaStackClient {
383
391
  ToolRuntime as ToolRuntime,
384
392
  type ToolDef as ToolDef,
385
393
  type ToolInvocationResult as ToolInvocationResult,
394
+ type ToolRuntimeListToolsResponse as ToolRuntimeListToolsResponse,
386
395
  type ToolRuntimeInvokeToolParams as ToolRuntimeInvokeToolParams,
387
396
  type ToolRuntimeListToolsParams as ToolRuntimeListToolsParams,
388
397
  };
@@ -398,13 +407,6 @@ export declare namespace LlamaStackClient {
398
407
  type AgentCreateParams as AgentCreateParams,
399
408
  };
400
409
 
401
- export {
402
- BatchInference as BatchInference,
403
- type BatchInferenceChatCompletionResponse as BatchInferenceChatCompletionResponse,
404
- type BatchInferenceChatCompletionParams as BatchInferenceChatCompletionParams,
405
- type BatchInferenceCompletionParams as BatchInferenceCompletionParams,
406
- };
407
-
408
410
  export {
409
411
  Datasets as Datasets,
410
412
  type ListDatasetsResponse as ListDatasetsResponse,
@@ -442,6 +444,9 @@ export declare namespace LlamaStackClient {
442
444
  type CompletionResponse as CompletionResponse,
443
445
  type EmbeddingsResponse as EmbeddingsResponse,
444
446
  type TokenLogProbs as TokenLogProbs,
447
+ type InferenceBatchChatCompletionResponse as InferenceBatchChatCompletionResponse,
448
+ type InferenceBatchChatCompletionParams as InferenceBatchChatCompletionParams,
449
+ type InferenceBatchCompletionParams as InferenceBatchCompletionParams,
445
450
  type InferenceChatCompletionParams as InferenceChatCompletionParams,
446
451
  type InferenceChatCompletionParamsNonStreaming as InferenceChatCompletionParamsNonStreaming,
447
452
  type InferenceChatCompletionParamsStreaming as InferenceChatCompletionParamsStreaming,
@@ -451,6 +456,16 @@ export declare namespace LlamaStackClient {
451
456
  type InferenceEmbeddingsParams as InferenceEmbeddingsParams,
452
457
  };
453
458
 
459
+ export { Chat as Chat, type ChatCompletionChunk as ChatCompletionChunk };
460
+
461
+ export {
462
+ Completions as Completions,
463
+ type CompletionCreateResponse as CompletionCreateResponse,
464
+ type CompletionCreateParams as CompletionCreateParams,
465
+ type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
466
+ type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
467
+ };
468
+
454
469
  export {
455
470
  VectorIo as VectorIo,
456
471
  type QueryChunksResponse as QueryChunksResponse,
@@ -0,0 +1,206 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../resource';
4
+ import * as CompletionsAPI from './completions';
5
+ import {
6
+ CompletionCreateParams,
7
+ CompletionCreateParamsNonStreaming,
8
+ CompletionCreateParamsStreaming,
9
+ CompletionCreateResponse,
10
+ Completions,
11
+ } from './completions';
12
+
13
+ export class Chat extends APIResource {
14
+ completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
15
+ }
16
+
17
+ /**
18
+ * Chunk from a streaming response to an OpenAI-compatible chat completion request.
19
+ */
20
+ export interface ChatCompletionChunk {
21
+ /**
22
+ * The ID of the chat completion
23
+ */
24
+ id: string;
25
+
26
+ /**
27
+ * List of choices
28
+ */
29
+ choices: Array<ChatCompletionChunk.Choice>;
30
+
31
+ /**
32
+ * The Unix timestamp in seconds when the chat completion was created
33
+ */
34
+ created: number;
35
+
36
+ /**
37
+ * The model that was used to generate the chat completion
38
+ */
39
+ model: string;
40
+
41
+ /**
42
+ * The object type, which will be "chat.completion.chunk"
43
+ */
44
+ object: 'chat.completion.chunk';
45
+ }
46
+
47
+ export namespace ChatCompletionChunk {
48
+ /**
49
+ * A chunk choice from an OpenAI-compatible chat completion streaming response.
50
+ */
51
+ export interface Choice {
52
+ /**
53
+ * The delta from the chunk
54
+ */
55
+ delta: Choice.Delta;
56
+
57
+ /**
58
+ * The reason the model stopped generating
59
+ */
60
+ finish_reason: string;
61
+
62
+ /**
63
+ * The index of the choice
64
+ */
65
+ index: number;
66
+
67
+ /**
68
+ * (Optional) The log probabilities for the tokens in the message
69
+ */
70
+ logprobs?: Choice.Logprobs;
71
+ }
72
+
73
+ export namespace Choice {
74
+ /**
75
+ * The delta from the chunk
76
+ */
77
+ export interface Delta {
78
+ /**
79
+ * (Optional) The content of the delta
80
+ */
81
+ content?: string;
82
+
83
+ /**
84
+ * (Optional) The refusal of the delta
85
+ */
86
+ refusal?: string;
87
+
88
+ /**
89
+ * (Optional) The role of the delta
90
+ */
91
+ role?: string;
92
+
93
+ /**
94
+ * (Optional) The tool calls of the delta
95
+ */
96
+ tool_calls?: Array<Delta.ToolCall>;
97
+ }
98
+
99
+ export namespace Delta {
100
+ export interface ToolCall {
101
+ type: 'function';
102
+
103
+ id?: string;
104
+
105
+ function?: ToolCall.Function;
106
+
107
+ index?: number;
108
+ }
109
+
110
+ export namespace ToolCall {
111
+ export interface Function {
112
+ arguments?: string;
113
+
114
+ name?: string;
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * (Optional) The log probabilities for the tokens in the message
121
+ */
122
+ export interface Logprobs {
123
+ /**
124
+ * (Optional) The log probabilities for the tokens in the message
125
+ */
126
+ content?: Array<Logprobs.Content>;
127
+
128
+ /**
129
+ * (Optional) The log probabilities for the tokens in the message
130
+ */
131
+ refusal?: Array<Logprobs.Refusal>;
132
+ }
133
+
134
+ export namespace Logprobs {
135
+ /**
136
+ * The log probability for a token from an OpenAI-compatible chat completion
137
+ * response.
138
+ */
139
+ export interface Content {
140
+ token: string;
141
+
142
+ logprob: number;
143
+
144
+ top_logprobs: Array<Content.TopLogprob>;
145
+
146
+ bytes?: Array<number>;
147
+ }
148
+
149
+ export namespace Content {
150
+ /**
151
+ * The top log probability for a token from an OpenAI-compatible chat completion
152
+ * response.
153
+ */
154
+ export interface TopLogprob {
155
+ token: string;
156
+
157
+ logprob: number;
158
+
159
+ bytes?: Array<number>;
160
+ }
161
+ }
162
+
163
+ /**
164
+ * The log probability for a token from an OpenAI-compatible chat completion
165
+ * response.
166
+ */
167
+ export interface Refusal {
168
+ token: string;
169
+
170
+ logprob: number;
171
+
172
+ top_logprobs: Array<Refusal.TopLogprob>;
173
+
174
+ bytes?: Array<number>;
175
+ }
176
+
177
+ export namespace Refusal {
178
+ /**
179
+ * The top log probability for a token from an OpenAI-compatible chat completion
180
+ * response.
181
+ */
182
+ export interface TopLogprob {
183
+ token: string;
184
+
185
+ logprob: number;
186
+
187
+ bytes?: Array<number>;
188
+ }
189
+ }
190
+ }
191
+ }
192
+ }
193
+
194
+ Chat.Completions = Completions;
195
+
196
+ export declare namespace Chat {
197
+ export { type ChatCompletionChunk as ChatCompletionChunk };
198
+
199
+ export {
200
+ Completions as Completions,
201
+ type CompletionCreateResponse as CompletionCreateResponse,
202
+ type CompletionCreateParams as CompletionCreateParams,
203
+ type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
204
+ type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
205
+ };
206
+ }