openai 4.35.0 → 4.37.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 (162) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +16 -2
  3. package/index.d.mts +8 -1
  4. package/index.d.ts +8 -1
  5. package/index.d.ts.map +1 -1
  6. package/index.js +5 -1
  7. package/index.js.map +1 -1
  8. package/index.mjs +5 -1
  9. package/index.mjs.map +1 -1
  10. package/lib/AssistantStream.d.ts +2 -2
  11. package/lib/AssistantStream.d.ts.map +1 -1
  12. package/lib/Util.d.ts +5 -0
  13. package/lib/Util.d.ts.map +1 -0
  14. package/lib/Util.js +26 -0
  15. package/lib/Util.js.map +1 -0
  16. package/lib/Util.mjs +22 -0
  17. package/lib/Util.mjs.map +1 -0
  18. package/package.json +1 -1
  19. package/resources/beta/{assistants/assistants.d.ts → assistants.d.ts} +217 -41
  20. package/resources/beta/assistants.d.ts.map +1 -0
  21. package/resources/beta/{assistants/assistants.js → assistants.js} +6 -13
  22. package/resources/beta/assistants.js.map +1 -0
  23. package/resources/beta/{assistants/assistants.mjs → assistants.mjs} +6 -13
  24. package/resources/beta/assistants.mjs.map +1 -0
  25. package/resources/beta/beta.d.ts +11 -2
  26. package/resources/beta/beta.d.ts.map +1 -1
  27. package/resources/beta/beta.js +5 -1
  28. package/resources/beta/beta.js.map +1 -1
  29. package/resources/beta/beta.mjs +5 -1
  30. package/resources/beta/beta.mjs.map +1 -1
  31. package/resources/beta/index.d.ts +2 -1
  32. package/resources/beta/index.d.ts.map +1 -1
  33. package/resources/beta/index.js +11 -8
  34. package/resources/beta/index.js.map +1 -1
  35. package/resources/beta/index.mjs +2 -1
  36. package/resources/beta/index.mjs.map +1 -1
  37. package/resources/beta/threads/index.d.ts +1 -1
  38. package/resources/beta/threads/index.d.ts.map +1 -1
  39. package/resources/beta/threads/index.js +6 -6
  40. package/resources/beta/threads/index.js.map +1 -1
  41. package/resources/beta/threads/index.mjs +1 -1
  42. package/resources/beta/threads/{messages/messages.d.ts → messages.d.ts} +27 -28
  43. package/resources/beta/threads/messages.d.ts.map +1 -0
  44. package/resources/beta/threads/{messages/messages.js → messages.js} +5 -12
  45. package/resources/beta/threads/messages.js.map +1 -0
  46. package/resources/beta/threads/{messages/messages.mjs → messages.mjs} +5 -12
  47. package/resources/beta/threads/messages.mjs.map +1 -0
  48. package/resources/beta/threads/runs/index.d.ts +1 -1
  49. package/resources/beta/threads/runs/index.d.ts.map +1 -1
  50. package/resources/beta/threads/runs/runs.d.ts +75 -29
  51. package/resources/beta/threads/runs/runs.d.ts.map +1 -1
  52. package/resources/beta/threads/runs/runs.js +6 -6
  53. package/resources/beta/threads/runs/runs.js.map +1 -1
  54. package/resources/beta/threads/runs/runs.mjs +6 -6
  55. package/resources/beta/threads/runs/runs.mjs.map +1 -1
  56. package/resources/beta/threads/runs/steps.d.ts +40 -40
  57. package/resources/beta/threads/runs/steps.d.ts.map +1 -1
  58. package/resources/beta/threads/runs/steps.js +2 -2
  59. package/resources/beta/threads/runs/steps.mjs +2 -2
  60. package/resources/beta/threads/threads.d.ts +498 -32
  61. package/resources/beta/threads/threads.d.ts.map +1 -1
  62. package/resources/beta/threads/threads.js +6 -6
  63. package/resources/beta/threads/threads.js.map +1 -1
  64. package/resources/beta/threads/threads.mjs +6 -6
  65. package/resources/beta/threads/threads.mjs.map +1 -1
  66. package/resources/beta/vector-stores/file-batches.d.ts +142 -0
  67. package/resources/beta/vector-stores/file-batches.d.ts.map +1 -0
  68. package/resources/beta/vector-stores/file-batches.js +128 -0
  69. package/resources/beta/vector-stores/file-batches.js.map +1 -0
  70. package/resources/beta/vector-stores/file-batches.mjs +124 -0
  71. package/resources/beta/vector-stores/file-batches.mjs.map +1 -0
  72. package/resources/beta/vector-stores/files.d.ts +148 -0
  73. package/resources/beta/vector-stores/files.d.ts.map +1 -0
  74. package/resources/beta/vector-stores/files.js +148 -0
  75. package/resources/beta/vector-stores/files.js.map +1 -0
  76. package/resources/beta/vector-stores/files.mjs +120 -0
  77. package/resources/beta/vector-stores/files.mjs.map +1 -0
  78. package/resources/beta/vector-stores/index.d.ts +4 -0
  79. package/resources/beta/vector-stores/index.d.ts.map +1 -0
  80. package/resources/beta/vector-stores/index.js +13 -0
  81. package/resources/beta/vector-stores/index.js.map +1 -0
  82. package/resources/beta/vector-stores/index.mjs +5 -0
  83. package/resources/beta/vector-stores/index.mjs.map +1 -0
  84. package/resources/beta/vector-stores/vector-stores.d.ts +233 -0
  85. package/resources/beta/vector-stores/vector-stores.d.ts.map +1 -0
  86. package/resources/beta/vector-stores/vector-stores.js +99 -0
  87. package/resources/beta/vector-stores/vector-stores.js.map +1 -0
  88. package/resources/beta/vector-stores/vector-stores.mjs +71 -0
  89. package/resources/beta/vector-stores/vector-stores.mjs.map +1 -0
  90. package/resources/chat/chat.d.ts +3 -0
  91. package/resources/chat/chat.d.ts.map +1 -1
  92. package/resources/chat/chat.js.map +1 -1
  93. package/resources/chat/chat.mjs.map +1 -1
  94. package/resources/chat/completions.d.ts +2 -1
  95. package/resources/chat/completions.d.ts.map +1 -1
  96. package/resources/chat/completions.js.map +1 -1
  97. package/resources/chat/completions.mjs.map +1 -1
  98. package/resources/chat/index.d.ts +1 -1
  99. package/resources/chat/index.d.ts.map +1 -1
  100. package/resources/chat/index.js +3 -3
  101. package/resources/chat/index.js.map +1 -1
  102. package/resources/chat/index.mjs +1 -1
  103. package/resources/chat/index.mjs.map +1 -1
  104. package/resources/fine-tuning/jobs/jobs.d.ts +1 -1
  105. package/src/index.ts +12 -0
  106. package/src/lib/AssistantStream.ts +2 -2
  107. package/src/lib/Util.ts +23 -0
  108. package/src/resources/beta/{assistants/assistants.ts → assistants.ts} +254 -58
  109. package/src/resources/beta/beta.ts +11 -2
  110. package/src/resources/beta/index.ts +11 -2
  111. package/src/resources/beta/threads/index.ts +1 -1
  112. package/src/resources/beta/threads/{messages/messages.ts → messages.ts} +39 -38
  113. package/src/resources/beta/threads/runs/index.ts +2 -2
  114. package/src/resources/beta/threads/runs/runs.ts +94 -36
  115. package/src/resources/beta/threads/runs/steps.ts +49 -49
  116. package/src/resources/beta/threads/threads.ts +571 -37
  117. package/src/resources/beta/vector-stores/file-batches.ts +292 -0
  118. package/src/resources/beta/vector-stores/files.ts +277 -0
  119. package/src/resources/beta/vector-stores/index.ts +25 -0
  120. package/src/resources/beta/vector-stores/vector-stores.ts +318 -0
  121. package/src/resources/chat/chat.ts +23 -0
  122. package/src/resources/chat/completions.ts +2 -21
  123. package/src/resources/chat/index.ts +1 -1
  124. package/src/resources/fine-tuning/jobs/jobs.ts +1 -1
  125. package/src/version.ts +1 -1
  126. package/version.d.ts +1 -1
  127. package/version.js +1 -1
  128. package/version.mjs +1 -1
  129. package/resources/beta/assistants/assistants.d.ts.map +0 -1
  130. package/resources/beta/assistants/assistants.js.map +0 -1
  131. package/resources/beta/assistants/assistants.mjs.map +0 -1
  132. package/resources/beta/assistants/files.d.ts +0 -88
  133. package/resources/beta/assistants/files.d.ts.map +0 -1
  134. package/resources/beta/assistants/files.js +0 -81
  135. package/resources/beta/assistants/files.js.map +0 -1
  136. package/resources/beta/assistants/files.mjs +0 -53
  137. package/resources/beta/assistants/files.mjs.map +0 -1
  138. package/resources/beta/assistants/index.d.ts +0 -3
  139. package/resources/beta/assistants/index.d.ts.map +0 -1
  140. package/resources/beta/assistants/index.js +0 -11
  141. package/resources/beta/assistants/index.js.map +0 -1
  142. package/resources/beta/assistants/index.mjs +0 -4
  143. package/resources/beta/assistants/index.mjs.map +0 -1
  144. package/resources/beta/threads/messages/files.d.ts +0 -60
  145. package/resources/beta/threads/messages/files.d.ts.map +0 -1
  146. package/resources/beta/threads/messages/files.js +0 -60
  147. package/resources/beta/threads/messages/files.js.map +0 -1
  148. package/resources/beta/threads/messages/files.mjs +0 -32
  149. package/resources/beta/threads/messages/files.mjs.map +0 -1
  150. package/resources/beta/threads/messages/index.d.ts +0 -3
  151. package/resources/beta/threads/messages/index.d.ts.map +0 -1
  152. package/resources/beta/threads/messages/index.js +0 -11
  153. package/resources/beta/threads/messages/index.js.map +0 -1
  154. package/resources/beta/threads/messages/index.mjs +0 -4
  155. package/resources/beta/threads/messages/index.mjs.map +0 -1
  156. package/resources/beta/threads/messages/messages.d.ts.map +0 -1
  157. package/resources/beta/threads/messages/messages.js.map +0 -1
  158. package/resources/beta/threads/messages/messages.mjs.map +0 -1
  159. package/src/resources/beta/assistants/files.ts +0 -154
  160. package/src/resources/beta/assistants/index.ts +0 -28
  161. package/src/resources/beta/threads/messages/files.ts +0 -105
  162. package/src/resources/beta/threads/messages/index.ts +0 -30
package/src/index.ts CHANGED
@@ -18,6 +18,11 @@ export interface ClientOptions {
18
18
  */
19
19
  organization?: string | null | undefined;
20
20
 
21
+ /**
22
+ * Defaults to process.env['OPENAI_PROJECT_ID'].
23
+ */
24
+ project?: string | null | undefined;
25
+
21
26
  /**
22
27
  * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
23
28
  *
@@ -85,6 +90,7 @@ export interface ClientOptions {
85
90
  export class OpenAI extends Core.APIClient {
86
91
  apiKey: string;
87
92
  organization: string | null;
93
+ project: string | null;
88
94
 
89
95
  private _options: ClientOptions;
90
96
 
@@ -93,6 +99,7 @@ export class OpenAI extends Core.APIClient {
93
99
  *
94
100
  * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
95
101
  * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
102
+ * @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
96
103
  * @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL'] ?? https://api.openai.com/v1] - Override the default base URL for the API.
97
104
  * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
98
105
  * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
@@ -106,6 +113,7 @@ export class OpenAI extends Core.APIClient {
106
113
  baseURL = Core.readEnv('OPENAI_BASE_URL'),
107
114
  apiKey = Core.readEnv('OPENAI_API_KEY'),
108
115
  organization = Core.readEnv('OPENAI_ORG_ID') ?? null,
116
+ project = Core.readEnv('OPENAI_PROJECT_ID') ?? null,
109
117
  ...opts
110
118
  }: ClientOptions = {}) {
111
119
  if (apiKey === undefined) {
@@ -117,6 +125,7 @@ export class OpenAI extends Core.APIClient {
117
125
  const options: ClientOptions = {
118
126
  apiKey,
119
127
  organization,
128
+ project,
120
129
  ...opts,
121
130
  baseURL: baseURL || `https://api.openai.com/v1`,
122
131
  };
@@ -138,6 +147,7 @@ export class OpenAI extends Core.APIClient {
138
147
 
139
148
  this.apiKey = apiKey;
140
149
  this.organization = organization;
150
+ this.project = project;
141
151
  }
142
152
 
143
153
  completions: API.Completions = new API.Completions(this);
@@ -160,6 +170,7 @@ export class OpenAI extends Core.APIClient {
160
170
  return {
161
171
  ...super.defaultHeaders(opts),
162
172
  'OpenAI-Organization': this.organization,
173
+ 'OpenAI-Project': this.project,
163
174
  ...this._options.defaultHeaders,
164
175
  };
165
176
  }
@@ -227,6 +238,7 @@ export namespace OpenAI {
227
238
  export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
228
239
 
229
240
  export import Chat = API.Chat;
241
+ export import ChatModel = API.ChatModel;
230
242
  export import ChatCompletion = API.ChatCompletion;
231
243
  export import ChatCompletionAssistantMessageParam = API.ChatCompletionAssistantMessageParam;
232
244
  export import ChatCompletionChunk = API.ChatCompletionChunk;
@@ -7,7 +7,7 @@ import {
7
7
  ImageFile,
8
8
  TextDelta,
9
9
  Messages,
10
- } from "../resources/beta/threads/messages/messages";
10
+ } from "../resources/beta/threads/messages";
11
11
  import * as Core from "../core";
12
12
  import { RequestOptions } from "../core";
13
13
  import {
@@ -30,7 +30,7 @@ import {
30
30
  MessageStreamEvent,
31
31
  RunStepStreamEvent,
32
32
  RunStreamEvent,
33
- } from "../resources/beta/assistants/assistants";
33
+ } from "../resources/beta/assistants";
34
34
  import { RunStep, RunStepDelta, ToolCall, ToolCallDelta } from "../resources/beta/threads/runs/steps";
35
35
  import { ThreadCreateAndRunParamsBase, Threads } from "../resources/beta/threads/threads";
36
36
  import MessageDelta = Messages.MessageDelta;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Like `Promise.allSettled()` but throws an error if any promises are rejected.
3
+ */
4
+ export const allSettledWithThrow = async <R>(promises: Promise<R>[]): Promise<R[]> => {
5
+ const results = await Promise.allSettled(promises);
6
+ const rejected = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected');
7
+ if (rejected.length) {
8
+ for (const result of rejected) {
9
+ console.error(result.reason);
10
+ }
11
+
12
+ throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
13
+ }
14
+
15
+ // Note: TS was complaining about using `.filter().map()` here for some reason
16
+ const values: R[] = [];
17
+ for (const result of results) {
18
+ if (result.status === 'fulfilled') {
19
+ values.push(result.value);
20
+ }
21
+ }
22
+ return values;
23
+ };
@@ -1,20 +1,17 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Core from "../../../core";
4
- import { APIResource } from "../../../resource";
5
- import { isRequestOptions } from "../../../core";
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import { isRequestOptions } from "../../core";
6
6
  import * as AssistantsAPI from "./assistants";
7
- import * as Shared from "../../shared";
8
- import * as FilesAPI from "./files";
9
- import * as ThreadsAPI from "../threads/threads";
10
- import * as MessagesAPI from "../threads/messages/messages";
11
- import * as RunsAPI from "../threads/runs/runs";
12
- import * as StepsAPI from "../threads/runs/steps";
13
- import { CursorPage, type CursorPageParams } from "../../../pagination";
7
+ import * as Shared from "../shared";
8
+ import * as MessagesAPI from "./threads/messages";
9
+ import * as ThreadsAPI from "./threads/threads";
10
+ import * as RunsAPI from "./threads/runs/runs";
11
+ import * as StepsAPI from "./threads/runs/steps";
12
+ import { CursorPage, type CursorPageParams } from "../../pagination";
14
13
 
15
14
  export class Assistants extends APIResource {
16
- files: FilesAPI.Files = new FilesAPI.Files(this._client);
17
-
18
15
  /**
19
16
  * Create an assistant with a model and instructions.
20
17
  */
@@ -22,7 +19,7 @@ export class Assistants extends APIResource {
22
19
  return this._client.post('/assistants', {
23
20
  body,
24
21
  ...options,
25
- headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
22
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
26
23
  });
27
24
  }
28
25
 
@@ -32,7 +29,7 @@ export class Assistants extends APIResource {
32
29
  retrieve(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<Assistant> {
33
30
  return this._client.get(`/assistants/${assistantId}`, {
34
31
  ...options,
35
- headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
32
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
36
33
  });
37
34
  }
38
35
 
@@ -47,7 +44,7 @@ export class Assistants extends APIResource {
47
44
  return this._client.post(`/assistants/${assistantId}`, {
48
45
  body,
49
46
  ...options,
50
- headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
47
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
51
48
  });
52
49
  }
53
50
 
@@ -69,7 +66,7 @@ export class Assistants extends APIResource {
69
66
  return this._client.getAPIList('/assistants', AssistantsPage, {
70
67
  query,
71
68
  ...options,
72
- headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
69
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
73
70
  });
74
71
  }
75
72
 
@@ -79,7 +76,7 @@ export class Assistants extends APIResource {
79
76
  del(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<AssistantDeleted> {
80
77
  return this._client.delete(`/assistants/${assistantId}`, {
81
78
  ...options,
82
- headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
79
+ headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
83
80
  });
84
81
  }
85
82
  }
@@ -105,13 +102,6 @@ export interface Assistant {
105
102
  */
106
103
  description: string | null;
107
104
 
108
- /**
109
- * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs
110
- * attached to this assistant. There can be a maximum of 20 files attached to the
111
- * assistant. Files are ordered by their creation date in ascending order.
112
- */
113
- file_ids: Array<string>;
114
-
115
105
  /**
116
106
  * The system instructions that the assistant uses. The maximum length is 256,000
117
107
  * characters.
@@ -147,9 +137,53 @@ export interface Assistant {
147
137
 
148
138
  /**
149
139
  * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
150
- * assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.
140
+ * assistant. Tools can be of types `code_interpreter`, `file_search`, or
141
+ * `function`.
151
142
  */
152
143
  tools: Array<AssistantTool>;
144
+
145
+ /**
146
+ * A set of resources that are used by the assistant's tools. The resources are
147
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
148
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
149
+ * IDs.
150
+ */
151
+ tool_resources?: Assistant.ToolResources | null;
152
+ }
153
+
154
+ export namespace Assistant {
155
+ /**
156
+ * A set of resources that are used by the assistant's tools. The resources are
157
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
158
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
159
+ * IDs.
160
+ */
161
+ export interface ToolResources {
162
+ code_interpreter?: ToolResources.CodeInterpreter;
163
+
164
+ file_search?: ToolResources.FileSearch;
165
+ }
166
+
167
+ export namespace ToolResources {
168
+ export interface CodeInterpreter {
169
+ /**
170
+ * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
171
+ * available to the `code_interpreter`` tool. There can be a maximum of 20 files
172
+ * associated with the tool.
173
+ */
174
+ file_ids?: Array<string>;
175
+ }
176
+
177
+ export interface FileSearch {
178
+ /**
179
+ * The ID of the
180
+ * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
181
+ * attached to this assistant. There can be a maximum of 1 vector store attached to
182
+ * the assistant.
183
+ */
184
+ vector_store_ids?: Array<string>;
185
+ }
186
+ }
153
187
  }
154
188
 
155
189
  export interface AssistantDeleted {
@@ -535,7 +569,7 @@ export namespace AssistantStreamEvent {
535
569
  }
536
570
  }
537
571
 
538
- export type AssistantTool = CodeInterpreterTool | RetrievalTool | FunctionTool;
572
+ export type AssistantTool = CodeInterpreterTool | FileSearchTool | FunctionTool;
539
573
 
540
574
  export interface CodeInterpreterTool {
541
575
  /**
@@ -544,6 +578,13 @@ export interface CodeInterpreterTool {
544
578
  type: 'code_interpreter';
545
579
  }
546
580
 
581
+ export interface FileSearchTool {
582
+ /**
583
+ * The type of tool being defined: `file_search`
584
+ */
585
+ type: 'file_search';
586
+ }
587
+
547
588
  export interface FunctionTool {
548
589
  function: Shared.FunctionDefinition;
549
590
 
@@ -642,13 +683,6 @@ export namespace MessageStreamEvent {
642
683
  }
643
684
  }
644
685
 
645
- export interface RetrievalTool {
646
- /**
647
- * The type of tool being defined: `retrieval`
648
- */
649
- type: 'retrieval';
650
- }
651
-
652
686
  /**
653
687
  * Occurs when a
654
688
  * [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is
@@ -956,13 +990,6 @@ export interface AssistantCreateParams {
956
990
  */
957
991
  description?: string | null;
958
992
 
959
- /**
960
- * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs
961
- * attached to this assistant. There can be a maximum of 20 files attached to the
962
- * assistant. Files are ordered by their creation date in ascending order.
963
- */
964
- file_ids?: Array<string>;
965
-
966
993
  /**
967
994
  * The system instructions that the assistant uses. The maximum length is 256,000
968
995
  * characters.
@@ -982,27 +1009,123 @@ export interface AssistantCreateParams {
982
1009
  */
983
1010
  name?: string | null;
984
1011
 
1012
+ /**
1013
+ * Specifies the format that the model must output. Compatible with
1014
+ * [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
1015
+ * all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1016
+ *
1017
+ * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
1018
+ * message the model generates is valid JSON.
1019
+ *
1020
+ * **Important:** when using JSON mode, you **must** also instruct the model to
1021
+ * produce JSON yourself via a system or user message. Without this, the model may
1022
+ * generate an unending stream of whitespace until the generation reaches the token
1023
+ * limit, resulting in a long-running and seemingly "stuck" request. Also note that
1024
+ * the message content may be partially cut off if `finish_reason="length"`, which
1025
+ * indicates the generation exceeded `max_tokens` or the conversation exceeded the
1026
+ * max context length.
1027
+ */
1028
+ response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
1029
+
1030
+ /**
1031
+ * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1032
+ * make the output more random, while lower values like 0.2 will make it more
1033
+ * focused and deterministic.
1034
+ */
1035
+ temperature?: number | null;
1036
+
1037
+ /**
1038
+ * A set of resources that are used by the assistant's tools. The resources are
1039
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
1040
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
1041
+ * IDs.
1042
+ */
1043
+ tool_resources?: AssistantCreateParams.ToolResources | null;
1044
+
985
1045
  /**
986
1046
  * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
987
- * assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.
1047
+ * assistant. Tools can be of types `code_interpreter`, `file_search`, or
1048
+ * `function`.
988
1049
  */
989
1050
  tools?: Array<AssistantTool>;
1051
+
1052
+ /**
1053
+ * An alternative to sampling with temperature, called nucleus sampling, where the
1054
+ * model considers the results of the tokens with top_p probability mass. So 0.1
1055
+ * means only the tokens comprising the top 10% probability mass are considered.
1056
+ *
1057
+ * We generally recommend altering this or temperature but not both.
1058
+ */
1059
+ top_p?: number | null;
990
1060
  }
991
1061
 
992
- export interface AssistantUpdateParams {
1062
+ export namespace AssistantCreateParams {
993
1063
  /**
994
- * The description of the assistant. The maximum length is 512 characters.
1064
+ * A set of resources that are used by the assistant's tools. The resources are
1065
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
1066
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
1067
+ * IDs.
995
1068
  */
996
- description?: string | null;
1069
+ export interface ToolResources {
1070
+ code_interpreter?: ToolResources.CodeInterpreter;
1071
+
1072
+ file_search?: ToolResources.FileSearch;
1073
+ }
1074
+
1075
+ export namespace ToolResources {
1076
+ export interface CodeInterpreter {
1077
+ /**
1078
+ * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
1079
+ * available to the `code_interpreter` tool. There can be a maximum of 20 files
1080
+ * associated with the tool.
1081
+ */
1082
+ file_ids?: Array<string>;
1083
+ }
1084
+
1085
+ export interface FileSearch {
1086
+ /**
1087
+ * The
1088
+ * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1089
+ * attached to this assistant. There can be a maximum of 1 vector store attached to
1090
+ * the assistant.
1091
+ */
1092
+ vector_store_ids?: Array<string>;
1093
+
1094
+ /**
1095
+ * A helper to create a
1096
+ * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1097
+ * with file_ids and attach it to this assistant. There can be a maximum of 1
1098
+ * vector store attached to the assistant.
1099
+ */
1100
+ vector_stores?: Array<FileSearch.VectorStore>;
1101
+ }
997
1102
 
1103
+ export namespace FileSearch {
1104
+ export interface VectorStore {
1105
+ /**
1106
+ * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
1107
+ * add to the vector store. There can be a maximum of 10000 files in a vector
1108
+ * store.
1109
+ */
1110
+ file_ids?: Array<string>;
1111
+
1112
+ /**
1113
+ * Set of 16 key-value pairs that can be attached to a vector store. This can be
1114
+ * useful for storing additional information about the vector store in a structured
1115
+ * format. Keys can be a maximum of 64 characters long and values can be a maxium
1116
+ * of 512 characters long.
1117
+ */
1118
+ metadata?: unknown;
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+
1124
+ export interface AssistantUpdateParams {
998
1125
  /**
999
- * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs
1000
- * attached to this assistant. There can be a maximum of 20 files attached to the
1001
- * assistant. Files are ordered by their creation date in ascending order. If a
1002
- * file was previously attached to the list but does not show up in the list, it
1003
- * will be deleted from the assistant.
1126
+ * The description of the assistant. The maximum length is 512 characters.
1004
1127
  */
1005
- file_ids?: Array<string>;
1128
+ description?: string | null;
1006
1129
 
1007
1130
  /**
1008
1131
  * The system instructions that the assistant uses. The maximum length is 256,000
@@ -1032,11 +1155,90 @@ export interface AssistantUpdateParams {
1032
1155
  */
1033
1156
  name?: string | null;
1034
1157
 
1158
+ /**
1159
+ * Specifies the format that the model must output. Compatible with
1160
+ * [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
1161
+ * all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1162
+ *
1163
+ * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
1164
+ * message the model generates is valid JSON.
1165
+ *
1166
+ * **Important:** when using JSON mode, you **must** also instruct the model to
1167
+ * produce JSON yourself via a system or user message. Without this, the model may
1168
+ * generate an unending stream of whitespace until the generation reaches the token
1169
+ * limit, resulting in a long-running and seemingly "stuck" request. Also note that
1170
+ * the message content may be partially cut off if `finish_reason="length"`, which
1171
+ * indicates the generation exceeded `max_tokens` or the conversation exceeded the
1172
+ * max context length.
1173
+ */
1174
+ response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
1175
+
1176
+ /**
1177
+ * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1178
+ * make the output more random, while lower values like 0.2 will make it more
1179
+ * focused and deterministic.
1180
+ */
1181
+ temperature?: number | null;
1182
+
1183
+ /**
1184
+ * A set of resources that are used by the assistant's tools. The resources are
1185
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
1186
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
1187
+ * IDs.
1188
+ */
1189
+ tool_resources?: AssistantUpdateParams.ToolResources | null;
1190
+
1035
1191
  /**
1036
1192
  * A list of tool enabled on the assistant. There can be a maximum of 128 tools per
1037
- * assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.
1193
+ * assistant. Tools can be of types `code_interpreter`, `file_search`, or
1194
+ * `function`.
1038
1195
  */
1039
1196
  tools?: Array<AssistantTool>;
1197
+
1198
+ /**
1199
+ * An alternative to sampling with temperature, called nucleus sampling, where the
1200
+ * model considers the results of the tokens with top_p probability mass. So 0.1
1201
+ * means only the tokens comprising the top 10% probability mass are considered.
1202
+ *
1203
+ * We generally recommend altering this or temperature but not both.
1204
+ */
1205
+ top_p?: number | null;
1206
+ }
1207
+
1208
+ export namespace AssistantUpdateParams {
1209
+ /**
1210
+ * A set of resources that are used by the assistant's tools. The resources are
1211
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
1212
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
1213
+ * IDs.
1214
+ */
1215
+ export interface ToolResources {
1216
+ code_interpreter?: ToolResources.CodeInterpreter;
1217
+
1218
+ file_search?: ToolResources.FileSearch;
1219
+ }
1220
+
1221
+ export namespace ToolResources {
1222
+ export interface CodeInterpreter {
1223
+ /**
1224
+ * Overrides the list of
1225
+ * [file](https://platform.openai.com/docs/api-reference/files) IDs made available
1226
+ * to the `code_interpreter` tool. There can be a maximum of 20 files associated
1227
+ * with the tool.
1228
+ */
1229
+ file_ids?: Array<string>;
1230
+ }
1231
+
1232
+ export interface FileSearch {
1233
+ /**
1234
+ * Overrides the
1235
+ * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1236
+ * attached to this assistant. There can be a maximum of 1 vector store attached to
1237
+ * the assistant.
1238
+ */
1239
+ vector_store_ids?: Array<string>;
1240
+ }
1241
+ }
1040
1242
  }
1041
1243
 
1042
1244
  export interface AssistantListParams extends CursorPageParams {
@@ -1061,9 +1263,9 @@ export namespace Assistants {
1061
1263
  export import AssistantStreamEvent = AssistantsAPI.AssistantStreamEvent;
1062
1264
  export import AssistantTool = AssistantsAPI.AssistantTool;
1063
1265
  export import CodeInterpreterTool = AssistantsAPI.CodeInterpreterTool;
1266
+ export import FileSearchTool = AssistantsAPI.FileSearchTool;
1064
1267
  export import FunctionTool = AssistantsAPI.FunctionTool;
1065
1268
  export import MessageStreamEvent = AssistantsAPI.MessageStreamEvent;
1066
- export import RetrievalTool = AssistantsAPI.RetrievalTool;
1067
1269
  export import RunStepStreamEvent = AssistantsAPI.RunStepStreamEvent;
1068
1270
  export import RunStreamEvent = AssistantsAPI.RunStreamEvent;
1069
1271
  export import ThreadStreamEvent = AssistantsAPI.ThreadStreamEvent;
@@ -1071,10 +1273,4 @@ export namespace Assistants {
1071
1273
  export import AssistantCreateParams = AssistantsAPI.AssistantCreateParams;
1072
1274
  export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
1073
1275
  export import AssistantListParams = AssistantsAPI.AssistantListParams;
1074
- export import Files = FilesAPI.Files;
1075
- export import AssistantFile = FilesAPI.AssistantFile;
1076
- export import FileDeleteResponse = FilesAPI.FileDeleteResponse;
1077
- export import AssistantFilesPage = FilesAPI.AssistantFilesPage;
1078
- export import FileCreateParams = FilesAPI.FileCreateParams;
1079
- export import FileListParams = FilesAPI.FileListParams;
1080
1276
  }
@@ -1,17 +1,26 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from "../../resource";
4
- import * as AssistantsAPI from "./assistants/assistants";
4
+ import * as AssistantsAPI from "./assistants";
5
5
  import * as ChatAPI from "./chat/chat";
6
6
  import * as ThreadsAPI from "./threads/threads";
7
+ import * as VectorStoresAPI from "./vector-stores/vector-stores";
7
8
 
8
9
  export class Beta extends APIResource {
10
+ vectorStores: VectorStoresAPI.VectorStores = new VectorStoresAPI.VectorStores(this._client);
9
11
  chat: ChatAPI.Chat = new ChatAPI.Chat(this._client);
10
12
  assistants: AssistantsAPI.Assistants = new AssistantsAPI.Assistants(this._client);
11
13
  threads: ThreadsAPI.Threads = new ThreadsAPI.Threads(this._client);
12
14
  }
13
15
 
14
16
  export namespace Beta {
17
+ export import VectorStores = VectorStoresAPI.VectorStores;
18
+ export import VectorStore = VectorStoresAPI.VectorStore;
19
+ export import VectorStoreDeleted = VectorStoresAPI.VectorStoreDeleted;
20
+ export import VectorStoresPage = VectorStoresAPI.VectorStoresPage;
21
+ export import VectorStoreCreateParams = VectorStoresAPI.VectorStoreCreateParams;
22
+ export import VectorStoreUpdateParams = VectorStoresAPI.VectorStoreUpdateParams;
23
+ export import VectorStoreListParams = VectorStoresAPI.VectorStoreListParams;
15
24
  export import Chat = ChatAPI.Chat;
16
25
  export import Assistants = AssistantsAPI.Assistants;
17
26
  export import Assistant = AssistantsAPI.Assistant;
@@ -19,9 +28,9 @@ export namespace Beta {
19
28
  export import AssistantStreamEvent = AssistantsAPI.AssistantStreamEvent;
20
29
  export import AssistantTool = AssistantsAPI.AssistantTool;
21
30
  export import CodeInterpreterTool = AssistantsAPI.CodeInterpreterTool;
31
+ export import FileSearchTool = AssistantsAPI.FileSearchTool;
22
32
  export import FunctionTool = AssistantsAPI.FunctionTool;
23
33
  export import MessageStreamEvent = AssistantsAPI.MessageStreamEvent;
24
- export import RetrievalTool = AssistantsAPI.RetrievalTool;
25
34
  export import RunStepStreamEvent = AssistantsAPI.RunStepStreamEvent;
26
35
  export import RunStreamEvent = AssistantsAPI.RunStreamEvent;
27
36
  export import ThreadStreamEvent = AssistantsAPI.ThreadStreamEvent;
@@ -6,9 +6,9 @@ export {
6
6
  AssistantStreamEvent,
7
7
  AssistantTool,
8
8
  CodeInterpreterTool,
9
+ FileSearchTool,
9
10
  FunctionTool,
10
11
  MessageStreamEvent,
11
- RetrievalTool,
12
12
  RunStepStreamEvent,
13
13
  RunStreamEvent,
14
14
  ThreadStreamEvent,
@@ -17,7 +17,7 @@ export {
17
17
  AssistantListParams,
18
18
  AssistantsPage,
19
19
  Assistants,
20
- } from './assistants/index';
20
+ } from './assistants';
21
21
  export {
22
22
  AssistantResponseFormat,
23
23
  AssistantResponseFormatOption,
@@ -37,3 +37,12 @@ export {
37
37
  } from './threads/index';
38
38
  export { Beta } from './beta';
39
39
  export { Chat } from './chat/index';
40
+ export {
41
+ VectorStore,
42
+ VectorStoreDeleted,
43
+ VectorStoreCreateParams,
44
+ VectorStoreUpdateParams,
45
+ VectorStoreListParams,
46
+ VectorStoresPage,
47
+ VectorStores,
48
+ } from './vector-stores/index';
@@ -26,7 +26,7 @@ export {
26
26
  MessageListParams,
27
27
  MessagesPage,
28
28
  Messages,
29
- } from './messages/index';
29
+ } from './messages';
30
30
  export {
31
31
  AssistantResponseFormat,
32
32
  AssistantResponseFormatOption,