openai 4.28.4 → 4.29.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +7 -10
  3. package/index.d.mts +1 -0
  4. package/index.d.ts +1 -0
  5. package/index.d.ts.map +1 -1
  6. package/index.js.map +1 -1
  7. package/index.mjs.map +1 -1
  8. package/lib/AbstractAssistantStreamRunner.d.ts +74 -0
  9. package/lib/AbstractAssistantStreamRunner.d.ts.map +1 -0
  10. package/lib/AbstractAssistantStreamRunner.js +246 -0
  11. package/lib/AbstractAssistantStreamRunner.js.map +1 -0
  12. package/lib/AbstractAssistantStreamRunner.mjs +242 -0
  13. package/lib/AbstractAssistantStreamRunner.mjs.map +1 -0
  14. package/lib/AssistantStream.d.ts +56 -0
  15. package/lib/AssistantStream.d.ts.map +1 -0
  16. package/lib/AssistantStream.js +526 -0
  17. package/lib/AssistantStream.js.map +1 -0
  18. package/lib/AssistantStream.mjs +499 -0
  19. package/lib/AssistantStream.mjs.map +1 -0
  20. package/lib/ChatCompletionRunFunctions.test.js +35 -0
  21. package/lib/ChatCompletionRunFunctions.test.js.map +1 -1
  22. package/lib/ChatCompletionRunFunctions.test.mjs +35 -0
  23. package/lib/ChatCompletionRunFunctions.test.mjs.map +1 -1
  24. package/lib/ChatCompletionStream.d.ts.map +1 -1
  25. package/lib/ChatCompletionStream.js +21 -3
  26. package/lib/ChatCompletionStream.js.map +1 -1
  27. package/lib/ChatCompletionStream.mjs +21 -3
  28. package/lib/ChatCompletionStream.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/resources/audio/speech.d.ts +3 -6
  31. package/resources/audio/speech.d.ts.map +1 -1
  32. package/resources/audio/speech.js.map +1 -1
  33. package/resources/audio/speech.mjs.map +1 -1
  34. package/resources/audio/transcriptions.d.ts +14 -4
  35. package/resources/audio/transcriptions.d.ts.map +1 -1
  36. package/resources/audio/transcriptions.js.map +1 -1
  37. package/resources/audio/transcriptions.mjs.map +1 -1
  38. package/resources/audio/translations.d.ts +2 -1
  39. package/resources/audio/translations.d.ts.map +1 -1
  40. package/resources/audio/translations.js.map +1 -1
  41. package/resources/audio/translations.mjs.map +1 -1
  42. package/resources/beta/assistants/assistants.d.ts +629 -60
  43. package/resources/beta/assistants/assistants.d.ts.map +1 -1
  44. package/resources/beta/assistants/assistants.js.map +1 -1
  45. package/resources/beta/assistants/assistants.mjs.map +1 -1
  46. package/resources/beta/assistants/index.d.ts +1 -1
  47. package/resources/beta/assistants/index.d.ts.map +1 -1
  48. package/resources/beta/assistants/index.js.map +1 -1
  49. package/resources/beta/assistants/index.mjs.map +1 -1
  50. package/resources/beta/beta.d.ts +12 -0
  51. package/resources/beta/beta.d.ts.map +1 -1
  52. package/resources/beta/beta.js.map +1 -1
  53. package/resources/beta/beta.mjs.map +1 -1
  54. package/resources/beta/index.d.ts +2 -2
  55. package/resources/beta/index.d.ts.map +1 -1
  56. package/resources/beta/index.js.map +1 -1
  57. package/resources/beta/index.mjs.map +1 -1
  58. package/resources/beta/threads/index.d.ts +3 -3
  59. package/resources/beta/threads/index.d.ts.map +1 -1
  60. package/resources/beta/threads/index.js +2 -2
  61. package/resources/beta/threads/index.js.map +1 -1
  62. package/resources/beta/threads/index.mjs +1 -1
  63. package/resources/beta/threads/index.mjs.map +1 -1
  64. package/resources/beta/threads/messages/index.d.ts +1 -1
  65. package/resources/beta/threads/messages/index.d.ts.map +1 -1
  66. package/resources/beta/threads/messages/index.js +2 -2
  67. package/resources/beta/threads/messages/index.js.map +1 -1
  68. package/resources/beta/threads/messages/index.mjs +1 -1
  69. package/resources/beta/threads/messages/index.mjs.map +1 -1
  70. package/resources/beta/threads/messages/messages.d.ts +289 -86
  71. package/resources/beta/threads/messages/messages.d.ts.map +1 -1
  72. package/resources/beta/threads/messages/messages.js +5 -5
  73. package/resources/beta/threads/messages/messages.js.map +1 -1
  74. package/resources/beta/threads/messages/messages.mjs +3 -3
  75. package/resources/beta/threads/messages/messages.mjs.map +1 -1
  76. package/resources/beta/threads/runs/index.d.ts +2 -2
  77. package/resources/beta/threads/runs/index.d.ts.map +1 -1
  78. package/resources/beta/threads/runs/index.js.map +1 -1
  79. package/resources/beta/threads/runs/index.mjs.map +1 -1
  80. package/resources/beta/threads/runs/runs.d.ts +153 -49
  81. package/resources/beta/threads/runs/runs.d.ts.map +1 -1
  82. package/resources/beta/threads/runs/runs.js +14 -7
  83. package/resources/beta/threads/runs/runs.js.map +1 -1
  84. package/resources/beta/threads/runs/runs.mjs +14 -7
  85. package/resources/beta/threads/runs/runs.mjs.map +1 -1
  86. package/resources/beta/threads/runs/steps.d.ts +219 -5
  87. package/resources/beta/threads/runs/steps.d.ts.map +1 -1
  88. package/resources/beta/threads/runs/steps.js.map +1 -1
  89. package/resources/beta/threads/runs/steps.mjs.map +1 -1
  90. package/resources/beta/threads/threads.d.ts +144 -22
  91. package/resources/beta/threads/threads.d.ts.map +1 -1
  92. package/resources/beta/threads/threads.js +9 -4
  93. package/resources/beta/threads/threads.js.map +1 -1
  94. package/resources/beta/threads/threads.mjs +9 -4
  95. package/resources/beta/threads/threads.mjs.map +1 -1
  96. package/resources/chat/completions.d.ts +28 -18
  97. package/resources/chat/completions.d.ts.map +1 -1
  98. package/resources/chat/completions.js.map +1 -1
  99. package/resources/chat/completions.mjs.map +1 -1
  100. package/resources/completions.d.ts +2 -0
  101. package/resources/completions.d.ts.map +1 -1
  102. package/resources/completions.js.map +1 -1
  103. package/resources/completions.mjs.map +1 -1
  104. package/resources/files.d.ts +4 -4
  105. package/resources/images.d.ts +6 -3
  106. package/resources/images.d.ts.map +1 -1
  107. package/resources/images.js.map +1 -1
  108. package/resources/images.mjs.map +1 -1
  109. package/resources/moderations.d.ts +3 -5
  110. package/resources/moderations.d.ts.map +1 -1
  111. package/resources/moderations.js +1 -1
  112. package/resources/moderations.js.map +1 -1
  113. package/resources/moderations.mjs +1 -1
  114. package/resources/moderations.mjs.map +1 -1
  115. package/resources/shared.d.ts +6 -0
  116. package/resources/shared.d.ts.map +1 -1
  117. package/src/index.ts +1 -0
  118. package/src/lib/AbstractAssistantStreamRunner.ts +340 -0
  119. package/src/lib/AssistantStream.ts +698 -0
  120. package/src/lib/ChatCompletionRunFunctions.test.ts +52 -1
  121. package/src/lib/ChatCompletionStream.ts +29 -6
  122. package/src/resources/audio/speech.ts +3 -6
  123. package/src/resources/audio/transcriptions.ts +14 -4
  124. package/src/resources/audio/translations.ts +2 -1
  125. package/src/resources/beta/assistants/assistants.ts +768 -76
  126. package/src/resources/beta/assistants/index.ts +9 -0
  127. package/src/resources/beta/beta.ts +12 -0
  128. package/src/resources/beta/index.ts +12 -0
  129. package/src/resources/beta/threads/index.ts +30 -5
  130. package/src/resources/beta/threads/messages/index.ts +21 -5
  131. package/src/resources/beta/threads/messages/messages.ts +332 -94
  132. package/src/resources/beta/threads/runs/index.ts +18 -1
  133. package/src/resources/beta/threads/runs/runs.ts +225 -60
  134. package/src/resources/beta/threads/runs/steps.ts +254 -5
  135. package/src/resources/beta/threads/threads.ts +182 -25
  136. package/src/resources/chat/completions.ts +28 -18
  137. package/src/resources/completions.ts +2 -0
  138. package/src/resources/files.ts +4 -4
  139. package/src/resources/images.ts +6 -3
  140. package/src/resources/moderations.ts +3 -5
  141. package/src/resources/shared.ts +10 -0
  142. package/src/streaming.ts +31 -0
  143. package/src/version.ts +1 -1
  144. package/streaming.d.ts +2 -0
  145. package/streaming.d.ts.map +1 -1
  146. package/streaming.js +32 -1
  147. package/streaming.js.map +1 -1
  148. package/streaming.mjs +30 -0
  149. package/streaming.mjs.map +1 -1
  150. package/version.d.ts +1 -1
  151. package/version.js +1 -1
  152. package/version.mjs +1 -1
@@ -55,10 +55,54 @@ export class Steps extends APIResource {
55
55
 
56
56
  export class RunStepsPage extends CursorPage<RunStep> {}
57
57
 
58
+ /**
59
+ * Text output from the Code Interpreter tool call as part of a run step.
60
+ */
61
+ export interface CodeInterpreterLogs {
62
+ /**
63
+ * The index of the output in the outputs array.
64
+ */
65
+ index: number;
66
+
67
+ /**
68
+ * Always `logs`.
69
+ */
70
+ type: 'logs';
71
+
72
+ /**
73
+ * The text output from the Code Interpreter tool call.
74
+ */
75
+ logs?: string;
76
+ }
77
+
78
+ export interface CodeInterpreterOutputImage {
79
+ /**
80
+ * The index of the output in the outputs array.
81
+ */
82
+ index: number;
83
+
84
+ /**
85
+ * Always `image`.
86
+ */
87
+ type: 'image';
88
+
89
+ image?: CodeInterpreterOutputImage.Image;
90
+ }
91
+
92
+ export namespace CodeInterpreterOutputImage {
93
+ export interface Image {
94
+ /**
95
+ * The [file](https://platform.openai.com/docs/api-reference/files) ID of the
96
+ * image.
97
+ */
98
+ file_id?: string;
99
+ }
100
+ }
101
+
58
102
  /**
59
103
  * Details of the Code Interpreter tool call the run step was involved in.
60
104
  */
61
- export interface CodeToolCall {
105
+ export interface CodeInterpreterToolCall {
62
106
  /**
63
107
  * The ID of the tool call.
64
108
  */
@@ -67,7 +111,7 @@ export interface CodeToolCall {
67
111
  /**
68
112
  * The Code Interpreter tool call definition.
69
113
  */
70
- code_interpreter: CodeToolCall.CodeInterpreter;
114
+ code_interpreter: CodeInterpreterToolCall.CodeInterpreter;
71
115
 
72
116
  /**
73
117
  * The type of tool call. This is always going to be `code_interpreter` for this
@@ -76,7 +120,7 @@ export interface CodeToolCall {
76
120
  type: 'code_interpreter';
77
121
  }
78
122
 
79
- export namespace CodeToolCall {
123
+ export namespace CodeInterpreterToolCall {
80
124
  /**
81
125
  * The Code Interpreter tool call definition.
82
126
  */
@@ -131,6 +175,51 @@ export namespace CodeToolCall {
131
175
  }
132
176
  }
133
177
 
178
+ /**
179
+ * Details of the Code Interpreter tool call the run step was involved in.
180
+ */
181
+ export interface CodeInterpreterToolCallDelta {
182
+ /**
183
+ * The index of the tool call in the tool calls array.
184
+ */
185
+ index: number;
186
+
187
+ /**
188
+ * The type of tool call. This is always going to be `code_interpreter` for this
189
+ * type of tool call.
190
+ */
191
+ type: 'code_interpreter';
192
+
193
+ /**
194
+ * The ID of the tool call.
195
+ */
196
+ id?: string;
197
+
198
+ /**
199
+ * The Code Interpreter tool call definition.
200
+ */
201
+ code_interpreter?: CodeInterpreterToolCallDelta.CodeInterpreter;
202
+ }
203
+
204
+ export namespace CodeInterpreterToolCallDelta {
205
+ /**
206
+ * The Code Interpreter tool call definition.
207
+ */
208
+ export interface CodeInterpreter {
209
+ /**
210
+ * The input to the Code Interpreter tool call.
211
+ */
212
+ input?: string;
213
+
214
+ /**
215
+ * The outputs from the Code Interpreter tool call. Code Interpreter can output one
216
+ * or more items, including text (`logs`) or images (`image`). Each of these are
217
+ * represented by a different object type.
218
+ */
219
+ outputs?: Array<StepsAPI.CodeInterpreterLogs | StepsAPI.CodeInterpreterOutputImage>;
220
+ }
221
+ }
222
+
134
223
  export interface FunctionToolCall {
135
224
  /**
136
225
  * The ID of the tool call object.
@@ -173,6 +262,53 @@ export namespace FunctionToolCall {
173
262
  }
174
263
  }
175
264
 
265
+ export interface FunctionToolCallDelta {
266
+ /**
267
+ * The index of the tool call in the tool calls array.
268
+ */
269
+ index: number;
270
+
271
+ /**
272
+ * The type of tool call. This is always going to be `function` for this type of
273
+ * tool call.
274
+ */
275
+ type: 'function';
276
+
277
+ /**
278
+ * The ID of the tool call object.
279
+ */
280
+ id?: string;
281
+
282
+ /**
283
+ * The definition of the function that was called.
284
+ */
285
+ function?: FunctionToolCallDelta.Function;
286
+ }
287
+
288
+ export namespace FunctionToolCallDelta {
289
+ /**
290
+ * The definition of the function that was called.
291
+ */
292
+ export interface Function {
293
+ /**
294
+ * The arguments passed to the function.
295
+ */
296
+ arguments?: string;
297
+
298
+ /**
299
+ * The name of the function.
300
+ */
301
+ name?: string;
302
+
303
+ /**
304
+ * The output of the function. This will be `null` if the outputs have not been
305
+ * [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
306
+ * yet.
307
+ */
308
+ output?: string | null;
309
+ }
310
+ }
311
+
176
312
  /**
177
313
  * Details of the message creation by the run step.
178
314
  */
@@ -212,6 +348,29 @@ export interface RetrievalToolCall {
212
348
  type: 'retrieval';
213
349
  }
214
350
 
351
+ export interface RetrievalToolCallDelta {
352
+ /**
353
+ * The index of the tool call in the tool calls array.
354
+ */
355
+ index: number;
356
+
357
+ /**
358
+ * The type of tool call. This is always going to be `retrieval` for this type of
359
+ * tool call.
360
+ */
361
+ type: 'retrieval';
362
+
363
+ /**
364
+ * The ID of the tool call object.
365
+ */
366
+ id?: string;
367
+
368
+ /**
369
+ * For now, this is always going to be an empty object.
370
+ */
371
+ retrieval?: unknown;
372
+ }
373
+
215
374
  /**
216
375
  * Represents a step in execution of a run.
217
376
  */
@@ -347,6 +506,85 @@ export namespace RunStep {
347
506
  }
348
507
  }
349
508
 
509
+ /**
510
+ * The delta containing the fields that have changed on the run step.
511
+ */
512
+ export interface RunStepDelta {
513
+ /**
514
+ * The details of the run step.
515
+ */
516
+ step_details?: RunStepDeltaMessageDelta | ToolCallDeltaObject;
517
+ }
518
+
519
+ /**
520
+ * Represents a run step delta i.e. any changed fields on a run step during
521
+ * streaming.
522
+ */
523
+ export interface RunStepDeltaEvent {
524
+ /**
525
+ * The identifier of the run step, which can be referenced in API endpoints.
526
+ */
527
+ id: string;
528
+
529
+ /**
530
+ * The delta containing the fields that have changed on the run step.
531
+ */
532
+ delta: RunStepDelta;
533
+
534
+ /**
535
+ * The object type, which is always `thread.run.step.delta`.
536
+ */
537
+ object: 'thread.run.step.delta';
538
+ }
539
+
540
+ /**
541
+ * Details of the message creation by the run step.
542
+ */
543
+ export interface RunStepDeltaMessageDelta {
544
+ /**
545
+ * Always `message_creation`.
546
+ */
547
+ type: 'message_creation';
548
+
549
+ message_creation?: RunStepDeltaMessageDelta.MessageCreation;
550
+ }
551
+
552
+ export namespace RunStepDeltaMessageDelta {
553
+ export interface MessageCreation {
554
+ /**
555
+ * The ID of the message that was created by this run step.
556
+ */
557
+ message_id?: string;
558
+ }
559
+ }
560
+
561
+ /**
562
+ * Details of the Code Interpreter tool call the run step was involved in.
563
+ */
564
+ export type ToolCall = CodeInterpreterToolCall | RetrievalToolCall | FunctionToolCall;
565
+
566
+ /**
567
+ * Details of the Code Interpreter tool call the run step was involved in.
568
+ */
569
+ export type ToolCallDelta = CodeInterpreterToolCallDelta | RetrievalToolCallDelta | FunctionToolCallDelta;
570
+
571
+ /**
572
+ * Details of the tool call.
573
+ */
574
+ export interface ToolCallDeltaObject {
575
+ /**
576
+ * Always `tool_calls`.
577
+ */
578
+ type: 'tool_calls';
579
+
580
+ /**
581
+ * An array of tool calls the run step was involved in. These can be associated
582
+ * with one of three types of tools: `code_interpreter`, `retrieval`, or
583
+ * `function`.
584
+ */
585
+ tool_calls?: Array<ToolCallDelta>;
586
+ }
587
+
350
588
  /**
351
589
  * Details of the tool call.
352
590
  */
@@ -356,7 +594,7 @@ export interface ToolCallsStepDetails {
356
594
  * with one of three types of tools: `code_interpreter`, `retrieval`, or
357
595
  * `function`.
358
596
  */
359
- tool_calls: Array<CodeToolCall | RetrievalToolCall | FunctionToolCall>;
597
+ tool_calls: Array<ToolCall>;
360
598
 
361
599
  /**
362
600
  * Always `tool_calls`.
@@ -381,11 +619,22 @@ export interface StepListParams extends CursorPageParams {
381
619
  }
382
620
 
383
621
  export namespace Steps {
384
- export import CodeToolCall = StepsAPI.CodeToolCall;
622
+ export import CodeInterpreterLogs = StepsAPI.CodeInterpreterLogs;
623
+ export import CodeInterpreterOutputImage = StepsAPI.CodeInterpreterOutputImage;
624
+ export import CodeInterpreterToolCall = StepsAPI.CodeInterpreterToolCall;
625
+ export import CodeInterpreterToolCallDelta = StepsAPI.CodeInterpreterToolCallDelta;
385
626
  export import FunctionToolCall = StepsAPI.FunctionToolCall;
627
+ export import FunctionToolCallDelta = StepsAPI.FunctionToolCallDelta;
386
628
  export import MessageCreationStepDetails = StepsAPI.MessageCreationStepDetails;
387
629
  export import RetrievalToolCall = StepsAPI.RetrievalToolCall;
630
+ export import RetrievalToolCallDelta = StepsAPI.RetrievalToolCallDelta;
388
631
  export import RunStep = StepsAPI.RunStep;
632
+ export import RunStepDelta = StepsAPI.RunStepDelta;
633
+ export import RunStepDeltaEvent = StepsAPI.RunStepDeltaEvent;
634
+ export import RunStepDeltaMessageDelta = StepsAPI.RunStepDeltaMessageDelta;
635
+ export import ToolCall = StepsAPI.ToolCall;
636
+ export import ToolCallDelta = StepsAPI.ToolCallDelta;
637
+ export import ToolCallDeltaObject = StepsAPI.ToolCallDeltaObject;
389
638
  export import ToolCallsStepDetails = StepsAPI.ToolCallsStepDetails;
390
639
  export import RunStepsPage = StepsAPI.RunStepsPage;
391
640
  export import StepListParams = StepsAPI.StepListParams;
@@ -1,12 +1,15 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
3
  import * as Core from "../../../core";
4
+ import { APIPromise } from "../../../core";
4
5
  import { APIResource } from "../../../resource";
5
6
  import { isRequestOptions } from "../../../core";
7
+ import { AssistantStream, ThreadCreateAndRunParamsBaseStream } from "../../../lib/AssistantStream";
6
8
  import * as ThreadsAPI from "./threads";
7
- import * as Shared from "../../shared";
9
+ import * as AssistantsAPI from "../assistants/assistants";
8
10
  import * as MessagesAPI from "./messages/messages";
9
11
  import * as RunsAPI from "./runs/runs";
12
+ import { Stream } from "../../../streaming";
10
13
 
11
14
  export class Threads extends APIResource {
12
15
  runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
@@ -65,12 +68,38 @@ export class Threads extends APIResource {
65
68
  /**
66
69
  * Create a thread and run it in one request.
67
70
  */
68
- createAndRun(body: ThreadCreateAndRunParams, options?: Core.RequestOptions): Core.APIPromise<RunsAPI.Run> {
71
+ createAndRun(
72
+ body: ThreadCreateAndRunParamsNonStreaming,
73
+ options?: Core.RequestOptions,
74
+ ): APIPromise<RunsAPI.Run>;
75
+ createAndRun(
76
+ body: ThreadCreateAndRunParamsStreaming,
77
+ options?: Core.RequestOptions,
78
+ ): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
79
+ createAndRun(
80
+ body: ThreadCreateAndRunParamsBase,
81
+ options?: Core.RequestOptions,
82
+ ): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | RunsAPI.Run>;
83
+ createAndRun(
84
+ body: ThreadCreateAndRunParams,
85
+ options?: Core.RequestOptions,
86
+ ): APIPromise<RunsAPI.Run> | APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>> {
69
87
  return this._client.post('/threads/runs', {
70
88
  body,
71
89
  ...options,
72
90
  headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
73
- });
91
+ stream: body.stream ?? false,
92
+ }) as APIPromise<RunsAPI.Run> | APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
93
+ }
94
+
95
+ /**
96
+ * Create a thread and stream the run back
97
+ */
98
+ createAndRunStream(
99
+ body: ThreadCreateAndRunParamsBaseStream,
100
+ options?: Core.RequestOptions,
101
+ ): AssistantStream {
102
+ return AssistantStream.createThreadAssistantStream(body, this._client.beta.threads, options);
74
103
  }
75
104
  }
76
105
 
@@ -168,7 +197,11 @@ export interface ThreadUpdateParams {
168
197
  metadata?: unknown | null;
169
198
  }
170
199
 
171
- export interface ThreadCreateAndRunParams {
200
+ export type ThreadCreateAndRunParams =
201
+ | ThreadCreateAndRunParamsNonStreaming
202
+ | ThreadCreateAndRunParamsStreaming;
203
+
204
+ export interface ThreadCreateAndRunParamsBase {
172
205
  /**
173
206
  * The ID of the
174
207
  * [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
@@ -198,6 +231,13 @@ export interface ThreadCreateAndRunParams {
198
231
  */
199
232
  model?: string | null;
200
233
 
234
+ /**
235
+ * If `true`, returns a stream of events that happen during the Run as server-sent
236
+ * events, terminating when the Run enters a terminal state with a `data: [DONE]`
237
+ * message.
238
+ */
239
+ stream?: boolean | null;
240
+
201
241
  /**
202
242
  * If no thread is provided, an empty thread will be created.
203
243
  */
@@ -208,9 +248,7 @@ export interface ThreadCreateAndRunParams {
208
248
  * modifying the behavior on a per-run basis.
209
249
  */
210
250
  tools?: Array<
211
- | ThreadCreateAndRunParams.AssistantToolsCode
212
- | ThreadCreateAndRunParams.AssistantToolsRetrieval
213
- | ThreadCreateAndRunParams.AssistantToolsFunction
251
+ AssistantsAPI.CodeInterpreterTool | AssistantsAPI.RetrievalTool | AssistantsAPI.FunctionTool
214
252
  > | null;
215
253
  }
216
254
 
@@ -265,27 +303,121 @@ export namespace ThreadCreateAndRunParams {
265
303
  }
266
304
  }
267
305
 
268
- export interface AssistantToolsCode {
306
+ export type ThreadCreateAndRunParamsNonStreaming = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
307
+ export type ThreadCreateAndRunParamsStreaming = ThreadsAPI.ThreadCreateAndRunParamsStreaming;
308
+ }
309
+
310
+ export interface ThreadCreateAndRunParamsNonStreaming extends ThreadCreateAndRunParamsBase {
311
+ /**
312
+ * If `true`, returns a stream of events that happen during the Run as server-sent
313
+ * events, terminating when the Run enters a terminal state with a `data: [DONE]`
314
+ * message.
315
+ */
316
+ stream?: false | null;
317
+ }
318
+
319
+ export interface ThreadCreateAndRunParamsStreaming extends ThreadCreateAndRunParamsBase {
320
+ /**
321
+ * If `true`, returns a stream of events that happen during the Run as server-sent
322
+ * events, terminating when the Run enters a terminal state with a `data: [DONE]`
323
+ * message.
324
+ */
325
+ stream: true;
326
+ }
327
+
328
+ export interface ThreadCreateAndRunStreamParams {
329
+ /**
330
+ * The ID of the
331
+ * [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
332
+ * execute this run.
333
+ */
334
+ assistant_id: string;
335
+
336
+ /**
337
+ * Override the default system message of the assistant. This is useful for
338
+ * modifying the behavior on a per-run basis.
339
+ */
340
+ instructions?: string | null;
341
+
342
+ /**
343
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful
344
+ * for storing additional information about the object in a structured format. Keys
345
+ * can be a maximum of 64 characters long and values can be a maxium of 512
346
+ * characters long.
347
+ */
348
+ metadata?: unknown | null;
349
+
350
+ /**
351
+ * The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
352
+ * be used to execute this run. If a value is provided here, it will override the
353
+ * model associated with the assistant. If not, the model associated with the
354
+ * assistant will be used.
355
+ */
356
+ model?: string | null;
357
+
358
+ /**
359
+ * If no thread is provided, an empty thread will be created.
360
+ */
361
+ thread?: ThreadCreateAndRunStreamParams.Thread;
362
+
363
+ /**
364
+ * Override the tools the assistant can use for this run. This is useful for
365
+ * modifying the behavior on a per-run basis.
366
+ */
367
+ tools?: Array<
368
+ AssistantsAPI.CodeInterpreterTool | AssistantsAPI.RetrievalTool | AssistantsAPI.FunctionTool
369
+ > | null;
370
+ }
371
+
372
+ export namespace ThreadCreateAndRunStreamParams {
373
+ /**
374
+ * If no thread is provided, an empty thread will be created.
375
+ */
376
+ export interface Thread {
269
377
  /**
270
- * The type of tool being defined: `code_interpreter`
378
+ * A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
379
+ * start the thread with.
271
380
  */
272
- type: 'code_interpreter';
273
- }
381
+ messages?: Array<Thread.Message>;
274
382
 
275
- export interface AssistantToolsRetrieval {
276
383
  /**
277
- * The type of tool being defined: `retrieval`
384
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful
385
+ * for storing additional information about the object in a structured format. Keys
386
+ * can be a maximum of 64 characters long and values can be a maxium of 512
387
+ * characters long.
278
388
  */
279
- type: 'retrieval';
389
+ metadata?: unknown | null;
280
390
  }
281
391
 
282
- export interface AssistantToolsFunction {
283
- function: Shared.FunctionDefinition;
392
+ export namespace Thread {
393
+ export interface Message {
394
+ /**
395
+ * The content of the message.
396
+ */
397
+ content: string;
398
+
399
+ /**
400
+ * The role of the entity that is creating the message. Currently only `user` is
401
+ * supported.
402
+ */
403
+ role: 'user';
284
404
 
285
- /**
286
- * The type of tool being defined: `function`
287
- */
288
- type: 'function';
405
+ /**
406
+ * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
407
+ * the message should use. There can be a maximum of 10 files attached to a
408
+ * message. Useful for tools like `retrieval` and `code_interpreter` that can
409
+ * access and use files.
410
+ */
411
+ file_ids?: Array<string>;
412
+
413
+ /**
414
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful
415
+ * for storing additional information about the object in a structured format. Keys
416
+ * can be a maximum of 64 characters long and values can be a maxium of 512
417
+ * characters long.
418
+ */
419
+ metadata?: unknown | null;
420
+ }
289
421
  }
290
422
  }
291
423
 
@@ -295,21 +427,46 @@ export namespace Threads {
295
427
  export import ThreadCreateParams = ThreadsAPI.ThreadCreateParams;
296
428
  export import ThreadUpdateParams = ThreadsAPI.ThreadUpdateParams;
297
429
  export import ThreadCreateAndRunParams = ThreadsAPI.ThreadCreateAndRunParams;
430
+ export import ThreadCreateAndRunParamsNonStreaming = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
431
+ export import ThreadCreateAndRunParamsStreaming = ThreadsAPI.ThreadCreateAndRunParamsStreaming;
432
+ export import ThreadCreateAndRunStreamParams = ThreadsAPI.ThreadCreateAndRunStreamParams;
298
433
  export import Runs = RunsAPI.Runs;
299
434
  export import RequiredActionFunctionToolCall = RunsAPI.RequiredActionFunctionToolCall;
300
435
  export import Run = RunsAPI.Run;
301
436
  export import RunStatus = RunsAPI.RunStatus;
302
437
  export import RunsPage = RunsAPI.RunsPage;
303
438
  export import RunCreateParams = RunsAPI.RunCreateParams;
439
+ export import RunCreateParamsNonStreaming = RunsAPI.RunCreateParamsNonStreaming;
440
+ export import RunCreateParamsStreaming = RunsAPI.RunCreateParamsStreaming;
304
441
  export import RunUpdateParams = RunsAPI.RunUpdateParams;
305
442
  export import RunListParams = RunsAPI.RunListParams;
443
+ export import RunCreateAndStreamParams = RunsAPI.RunCreateAndStreamParams;
306
444
  export import RunSubmitToolOutputsParams = RunsAPI.RunSubmitToolOutputsParams;
445
+ export import RunSubmitToolOutputsParamsNonStreaming = RunsAPI.RunSubmitToolOutputsParamsNonStreaming;
446
+ export import RunSubmitToolOutputsParamsStreaming = RunsAPI.RunSubmitToolOutputsParamsStreaming;
447
+ export import RunSubmitToolOutputsStreamParams = RunsAPI.RunSubmitToolOutputsStreamParams;
307
448
  export import Messages = MessagesAPI.Messages;
308
- export import MessageContentImageFile = MessagesAPI.MessageContentImageFile;
309
- export import MessageContentText = MessagesAPI.MessageContentText;
310
- export import ThreadMessage = MessagesAPI.ThreadMessage;
311
- export import ThreadMessageDeleted = MessagesAPI.ThreadMessageDeleted;
312
- export import ThreadMessagesPage = MessagesAPI.ThreadMessagesPage;
449
+ export import Annotation = MessagesAPI.Annotation;
450
+ export import AnnotationDelta = MessagesAPI.AnnotationDelta;
451
+ export import FileCitationAnnotation = MessagesAPI.FileCitationAnnotation;
452
+ export import FileCitationDeltaAnnotation = MessagesAPI.FileCitationDeltaAnnotation;
453
+ export import FilePathAnnotation = MessagesAPI.FilePathAnnotation;
454
+ export import FilePathDeltaAnnotation = MessagesAPI.FilePathDeltaAnnotation;
455
+ export import ImageFile = MessagesAPI.ImageFile;
456
+ export import ImageFileContentBlock = MessagesAPI.ImageFileContentBlock;
457
+ export import ImageFileDelta = MessagesAPI.ImageFileDelta;
458
+ export import ImageFileDeltaBlock = MessagesAPI.ImageFileDeltaBlock;
459
+ export import Message = MessagesAPI.Message;
460
+ export import MessageContent = MessagesAPI.MessageContent;
461
+ export import MessageContentDelta = MessagesAPI.MessageContentDelta;
462
+ export import MessageDeleted = MessagesAPI.MessageDeleted;
463
+ export import MessageDelta = MessagesAPI.MessageDelta;
464
+ export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
465
+ export import Text = MessagesAPI.Text;
466
+ export import TextContentBlock = MessagesAPI.TextContentBlock;
467
+ export import TextDelta = MessagesAPI.TextDelta;
468
+ export import TextDeltaBlock = MessagesAPI.TextDeltaBlock;
469
+ export import MessagesPage = MessagesAPI.MessagesPage;
313
470
  export import MessageCreateParams = MessagesAPI.MessageCreateParams;
314
471
  export import MessageUpdateParams = MessagesAPI.MessageUpdateParams;
315
472
  export import MessageListParams = MessagesAPI.MessageListParams;