@azure/ai-agents 1.0.0-alpha.20250502.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +907 -0
- package/dist/browser/agentsClient.d.ts +110 -0
- package/dist/browser/agentsClient.d.ts.map +1 -0
- package/dist/browser/agentsClient.js +203 -0
- package/dist/browser/agentsClient.js.map +1 -0
- package/dist/browser/api/agentsContext.d.ts +15 -0
- package/dist/browser/api/agentsContext.d.ts.map +1 -0
- package/dist/browser/api/agentsContext.js +55 -0
- package/dist/browser/api/agentsContext.js.map +1 -0
- package/dist/browser/api/index.d.ts +4 -0
- package/dist/browser/api/index.d.ts.map +1 -0
- package/dist/browser/api/index.js +5 -0
- package/dist/browser/api/index.js.map +1 -0
- package/dist/browser/api/operations.d.ts +212 -0
- package/dist/browser/api/operations.d.ts.map +1 -0
- package/dist/browser/api/operations.js +1348 -0
- package/dist/browser/api/operations.js.map +1 -0
- package/dist/browser/api/options.d.ts +456 -0
- package/dist/browser/api/options.d.ts.map +1 -0
- package/dist/browser/api/options.js +4 -0
- package/dist/browser/api/options.js.map +1 -0
- package/dist/browser/api/poller.d.ts +9 -0
- package/dist/browser/api/poller.d.ts.map +1 -0
- package/dist/browser/api/poller.js +137 -0
- package/dist/browser/api/poller.js.map +1 -0
- package/dist/browser/constants.d.ts +9 -0
- package/dist/browser/constants.d.ts.map +1 -0
- package/dist/browser/constants.js +11 -0
- package/dist/browser/constants.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +7 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/logger.js +5 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/models/index.d.ts +3 -0
- package/dist/browser/models/index.d.ts.map +1 -0
- package/dist/browser/models/index.js +5 -0
- package/dist/browser/models/index.js.map +1 -0
- package/dist/browser/models/models.d.ts +1977 -0
- package/dist/browser/models/models.d.ts.map +1 -0
- package/dist/browser/models/models.js +2053 -0
- package/dist/browser/models/models.js.map +1 -0
- package/dist/browser/models/streamingModels.d.ts +108 -0
- package/dist/browser/models/streamingModels.d.ts.map +1 -0
- package/dist/browser/models/streamingModels.js +75 -0
- package/dist/browser/models/streamingModels.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/static-helpers/multipartHelpers.d.ts +6 -0
- package/dist/browser/static-helpers/multipartHelpers.d.ts.map +1 -0
- package/dist/browser/static-helpers/multipartHelpers.js +23 -0
- package/dist/browser/static-helpers/multipartHelpers.js.map +1 -0
- package/dist/browser/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/browser/static-helpers/urlTemplate.d.ts.map +1 -0
- package/dist/browser/static-helpers/urlTemplate.js +169 -0
- package/dist/browser/static-helpers/urlTemplate.js.map +1 -0
- package/dist/browser/utils.d.ts +214 -0
- package/dist/browser/utils.d.ts.map +1 -0
- package/dist/browser/utils.js +311 -0
- package/dist/browser/utils.js.map +1 -0
- package/dist/commonjs/agentsClient.d.ts +110 -0
- package/dist/commonjs/agentsClient.d.ts.map +1 -0
- package/dist/commonjs/agentsClient.js +207 -0
- package/dist/commonjs/agentsClient.js.map +1 -0
- package/dist/commonjs/api/agentsContext.d.ts +15 -0
- package/dist/commonjs/api/agentsContext.d.ts.map +1 -0
- package/dist/commonjs/api/agentsContext.js +58 -0
- package/dist/commonjs/api/agentsContext.js.map +1 -0
- package/dist/commonjs/api/index.d.ts +4 -0
- package/dist/commonjs/api/index.d.ts.map +1 -0
- package/dist/commonjs/api/index.js +51 -0
- package/dist/commonjs/api/index.js.map +1 -0
- package/dist/commonjs/api/operations.d.ts +212 -0
- package/dist/commonjs/api/operations.d.ts.map +1 -0
- package/dist/commonjs/api/operations.js +1484 -0
- package/dist/commonjs/api/operations.js.map +1 -0
- package/dist/commonjs/api/options.d.ts +456 -0
- package/dist/commonjs/api/options.d.ts.map +1 -0
- package/dist/commonjs/api/options.js +5 -0
- package/dist/commonjs/api/options.js.map +1 -0
- package/dist/commonjs/api/poller.d.ts +9 -0
- package/dist/commonjs/api/poller.d.ts.map +1 -0
- package/dist/commonjs/api/poller.js +140 -0
- package/dist/commonjs/api/poller.js.map +1 -0
- package/dist/commonjs/constants.d.ts +9 -0
- package/dist/commonjs/constants.d.ts.map +1 -0
- package/dist/commonjs/constants.js +14 -0
- package/dist/commonjs/constants.js.map +1 -0
- package/dist/commonjs/index.d.ts +8 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +13 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models/index.d.ts +3 -0
- package/dist/commonjs/models/index.d.ts.map +1 -0
- package/dist/commonjs/models/index.js +10 -0
- package/dist/commonjs/models/index.js.map +1 -0
- package/dist/commonjs/models/models.d.ts +1977 -0
- package/dist/commonjs/models/models.d.ts.map +1 -0
- package/dist/commonjs/models/models.js +2340 -0
- package/dist/commonjs/models/models.js.map +1 -0
- package/dist/commonjs/models/streamingModels.d.ts +108 -0
- package/dist/commonjs/models/streamingModels.d.ts.map +1 -0
- package/dist/commonjs/models/streamingModels.js +78 -0
- package/dist/commonjs/models/streamingModels.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/static-helpers/multipartHelpers.d.ts +6 -0
- package/dist/commonjs/static-helpers/multipartHelpers.d.ts.map +1 -0
- package/dist/commonjs/static-helpers/multipartHelpers.js +26 -0
- package/dist/commonjs/static-helpers/multipartHelpers.js.map +1 -0
- package/dist/commonjs/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/commonjs/static-helpers/urlTemplate.d.ts.map +1 -0
- package/dist/commonjs/static-helpers/urlTemplate.js +172 -0
- package/dist/commonjs/static-helpers/urlTemplate.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/utils.d.ts +214 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +317 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/esm/agentsClient.d.ts +110 -0
- package/dist/esm/agentsClient.d.ts.map +1 -0
- package/dist/esm/agentsClient.js +203 -0
- package/dist/esm/agentsClient.js.map +1 -0
- package/dist/esm/api/agentsContext.d.ts +15 -0
- package/dist/esm/api/agentsContext.d.ts.map +1 -0
- package/dist/esm/api/agentsContext.js +55 -0
- package/dist/esm/api/agentsContext.js.map +1 -0
- package/dist/esm/api/index.d.ts +4 -0
- package/dist/esm/api/index.d.ts.map +1 -0
- package/dist/esm/api/index.js +5 -0
- package/dist/esm/api/index.js.map +1 -0
- package/dist/esm/api/operations.d.ts +212 -0
- package/dist/esm/api/operations.d.ts.map +1 -0
- package/dist/esm/api/operations.js +1348 -0
- package/dist/esm/api/operations.js.map +1 -0
- package/dist/esm/api/options.d.ts +456 -0
- package/dist/esm/api/options.d.ts.map +1 -0
- package/dist/esm/api/options.js +4 -0
- package/dist/esm/api/options.js.map +1 -0
- package/dist/esm/api/poller.d.ts +9 -0
- package/dist/esm/api/poller.d.ts.map +1 -0
- package/dist/esm/api/poller.js +137 -0
- package/dist/esm/api/poller.js.map +1 -0
- package/dist/esm/constants.d.ts +9 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +11 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models/index.d.ts +3 -0
- package/dist/esm/models/index.d.ts.map +1 -0
- package/dist/esm/models/index.js +5 -0
- package/dist/esm/models/index.js.map +1 -0
- package/dist/esm/models/models.d.ts +1977 -0
- package/dist/esm/models/models.d.ts.map +1 -0
- package/dist/esm/models/models.js +2053 -0
- package/dist/esm/models/models.js.map +1 -0
- package/dist/esm/models/streamingModels.d.ts +108 -0
- package/dist/esm/models/streamingModels.d.ts.map +1 -0
- package/dist/esm/models/streamingModels.js +75 -0
- package/dist/esm/models/streamingModels.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/static-helpers/multipartHelpers.d.ts +6 -0
- package/dist/esm/static-helpers/multipartHelpers.d.ts.map +1 -0
- package/dist/esm/static-helpers/multipartHelpers.js +23 -0
- package/dist/esm/static-helpers/multipartHelpers.js.map +1 -0
- package/dist/esm/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/esm/static-helpers/urlTemplate.d.ts.map +1 -0
- package/dist/esm/static-helpers/urlTemplate.js +169 -0
- package/dist/esm/static-helpers/urlTemplate.js.map +1 -0
- package/dist/esm/utils.d.ts +214 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +311 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/react-native/agentsClient.d.ts +110 -0
- package/dist/react-native/agentsClient.d.ts.map +1 -0
- package/dist/react-native/agentsClient.js +203 -0
- package/dist/react-native/agentsClient.js.map +1 -0
- package/dist/react-native/api/agentsContext.d.ts +15 -0
- package/dist/react-native/api/agentsContext.d.ts.map +1 -0
- package/dist/react-native/api/agentsContext.js +55 -0
- package/dist/react-native/api/agentsContext.js.map +1 -0
- package/dist/react-native/api/index.d.ts +4 -0
- package/dist/react-native/api/index.d.ts.map +1 -0
- package/dist/react-native/api/index.js +5 -0
- package/dist/react-native/api/index.js.map +1 -0
- package/dist/react-native/api/operations.d.ts +212 -0
- package/dist/react-native/api/operations.d.ts.map +1 -0
- package/dist/react-native/api/operations.js +1348 -0
- package/dist/react-native/api/operations.js.map +1 -0
- package/dist/react-native/api/options.d.ts +456 -0
- package/dist/react-native/api/options.d.ts.map +1 -0
- package/dist/react-native/api/options.js +4 -0
- package/dist/react-native/api/options.js.map +1 -0
- package/dist/react-native/api/poller.d.ts +9 -0
- package/dist/react-native/api/poller.d.ts.map +1 -0
- package/dist/react-native/api/poller.js +137 -0
- package/dist/react-native/api/poller.js.map +1 -0
- package/dist/react-native/constants.d.ts +9 -0
- package/dist/react-native/constants.d.ts.map +1 -0
- package/dist/react-native/constants.js +11 -0
- package/dist/react-native/constants.js.map +1 -0
- package/dist/react-native/index.d.ts +8 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +7 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models/index.d.ts +3 -0
- package/dist/react-native/models/index.d.ts.map +1 -0
- package/dist/react-native/models/index.js +5 -0
- package/dist/react-native/models/index.js.map +1 -0
- package/dist/react-native/models/models.d.ts +1977 -0
- package/dist/react-native/models/models.d.ts.map +1 -0
- package/dist/react-native/models/models.js +2053 -0
- package/dist/react-native/models/models.js.map +1 -0
- package/dist/react-native/models/streamingModels.d.ts +108 -0
- package/dist/react-native/models/streamingModels.d.ts.map +1 -0
- package/dist/react-native/models/streamingModels.js +75 -0
- package/dist/react-native/models/streamingModels.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/static-helpers/multipartHelpers.d.ts +6 -0
- package/dist/react-native/static-helpers/multipartHelpers.d.ts.map +1 -0
- package/dist/react-native/static-helpers/multipartHelpers.js +23 -0
- package/dist/react-native/static-helpers/multipartHelpers.js.map +1 -0
- package/dist/react-native/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/react-native/static-helpers/urlTemplate.d.ts.map +1 -0
- package/dist/react-native/static-helpers/urlTemplate.js +169 -0
- package/dist/react-native/static-helpers/urlTemplate.js.map +1 -0
- package/dist/react-native/utils.d.ts +214 -0
- package/dist/react-native/utils.d.ts.map +1 -0
- package/dist/react-native/utils.js +311 -0
- package/dist/react-native/utils.js.map +1 -0
- package/package.json +159 -0
|
@@ -0,0 +1,1348 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
|
+
import { toolResourcesSerializer, vectorStoreDataSourceArraySerializer, vectorStoreDataSourceSerializer, vectorStoreConfigurationSerializer, toolDefinitionUnionArraySerializer, agentsApiResponseFormatOptionSerializer, agentDeserializer, openAIPageableListOfAgentDeserializer, agentDeletionStatusDeserializer, messageInputContentSerializer, messageAttachmentArraySerializer, threadMessageOptionsArraySerializer, agentThreadDeserializer, threadDeletionStatusDeserializer, openAIPageableListOfAgentThreadDeserializer, threadMessageDeserializer, openAIPageableListOfThreadMessageDeserializer, truncationObjectSerializer, agentsApiToolChoiceOptionSerializer, threadRunDeserializer, updateToolResourcesOptionsSerializer, openAIPageableListOfThreadRunDeserializer, toolOutputArraySerializer, agentThreadCreationOptionsSerializer, runStepDeserializer, openAIPageableListOfRunStepDeserializer, fileListResponseDeserializer, openAIFileDeserializer, _uploadFileRequestSerializer, fileDeletionStatusDeserializer, openAIPageableListOfVectorStoreDeserializer, vectorStoreDeserializer, vectorStoreExpirationPolicySerializer, vectorStoreChunkingStrategyRequestUnionSerializer, vectorStoreDeletionStatusDeserializer, openAIPageableListOfVectorStoreFileDeserializer, vectorStoreFileDeserializer, vectorStoreFileDeletionStatusDeserializer, vectorStoreFileBatchDeserializer, } from "../models/models.js";
|
|
5
|
+
import { expandUrlTemplate } from "../static-helpers/urlTemplate.js";
|
|
6
|
+
import { createRestError, operationOptionsToRequestParameters, } from "@azure-rest/core-client";
|
|
7
|
+
import { createPoller } from "./poller.js";
|
|
8
|
+
import { createSseStream } from "@azure/core-sse";
|
|
9
|
+
import { isNodeLike } from "@azure/core-util";
|
|
10
|
+
import { MessageStreamEvent, RunStepStreamEvent, RunStreamEvent, ThreadStreamEvent, } from "../models/streamingModels.js";
|
|
11
|
+
import { logger } from "../logger.js";
|
|
12
|
+
export function _listVectorStoreFileBatchFilesSend(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
13
|
+
var _a;
|
|
14
|
+
return context
|
|
15
|
+
.path("/vector_stores/{vectorStoreId}/file_batches/{batchId}/files", vectorStoreId, batchId)
|
|
16
|
+
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers) }));
|
|
17
|
+
}
|
|
18
|
+
export async function _listVectorStoreFileBatchFilesDeserialize(result) {
|
|
19
|
+
const expectedStatuses = ["200"];
|
|
20
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
21
|
+
throw createRestError(result);
|
|
22
|
+
}
|
|
23
|
+
return openAIPageableListOfVectorStoreFileDeserializer(result.body);
|
|
24
|
+
}
|
|
25
|
+
/** Returns a list of vector store files in a batch. */
|
|
26
|
+
export async function listVectorStoreFileBatchFiles(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
27
|
+
const result = await _listVectorStoreFileBatchFilesSend(context, vectorStoreId, batchId, options);
|
|
28
|
+
return _listVectorStoreFileBatchFilesDeserialize(result);
|
|
29
|
+
}
|
|
30
|
+
export function _cancelVectorStoreFileBatchSend(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel{?api%2Dversion}", {
|
|
33
|
+
vectorStoreId: vectorStoreId,
|
|
34
|
+
batchId: batchId,
|
|
35
|
+
"api%2Dversion": context.apiVersion,
|
|
36
|
+
}, {
|
|
37
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
38
|
+
});
|
|
39
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
40
|
+
}
|
|
41
|
+
export async function _cancelVectorStoreFileBatchDeserialize(result) {
|
|
42
|
+
const expectedStatuses = ["200"];
|
|
43
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
44
|
+
throw createRestError(result);
|
|
45
|
+
}
|
|
46
|
+
return vectorStoreFileBatchDeserializer(result.body);
|
|
47
|
+
}
|
|
48
|
+
/** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */
|
|
49
|
+
export async function cancelVectorStoreFileBatch(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
50
|
+
const result = await _cancelVectorStoreFileBatchSend(context, vectorStoreId, batchId, options);
|
|
51
|
+
return _cancelVectorStoreFileBatchDeserialize(result);
|
|
52
|
+
}
|
|
53
|
+
export function _getVectorStoreFileBatchSend(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/file_batches/{batchId}{?api%2Dversion}", {
|
|
56
|
+
vectorStoreId: vectorStoreId,
|
|
57
|
+
batchId: batchId,
|
|
58
|
+
"api%2Dversion": context.apiVersion,
|
|
59
|
+
}, {
|
|
60
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
61
|
+
});
|
|
62
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
63
|
+
}
|
|
64
|
+
export async function _getVectorStoreFileBatchDeserialize(result) {
|
|
65
|
+
const expectedStatuses = ["200"];
|
|
66
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
67
|
+
throw createRestError(result);
|
|
68
|
+
}
|
|
69
|
+
return vectorStoreFileBatchDeserializer(result.body);
|
|
70
|
+
}
|
|
71
|
+
/** Retrieve a vector store file batch. */
|
|
72
|
+
export async function getVectorStoreFileBatch(context, vectorStoreId, batchId, options = { requestOptions: {} }) {
|
|
73
|
+
const result = await _getVectorStoreFileBatchSend(context, vectorStoreId, batchId, options);
|
|
74
|
+
return _getVectorStoreFileBatchDeserialize(result);
|
|
75
|
+
}
|
|
76
|
+
export function _createVectorStoreFileBatchSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/file_batches{?api%2Dversion}", {
|
|
79
|
+
vectorStoreId: vectorStoreId,
|
|
80
|
+
"api%2Dversion": context.apiVersion,
|
|
81
|
+
}, {
|
|
82
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
83
|
+
});
|
|
84
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
85
|
+
file_ids: !(options === null || options === void 0 ? void 0 : options.fileIds)
|
|
86
|
+
? options === null || options === void 0 ? void 0 : options.fileIds
|
|
87
|
+
: options === null || options === void 0 ? void 0 : options.fileIds.map((p) => {
|
|
88
|
+
return p;
|
|
89
|
+
}),
|
|
90
|
+
data_sources: !(options === null || options === void 0 ? void 0 : options.dataSources)
|
|
91
|
+
? options === null || options === void 0 ? void 0 : options.dataSources
|
|
92
|
+
: vectorStoreDataSourceArraySerializer(options === null || options === void 0 ? void 0 : options.dataSources),
|
|
93
|
+
chunking_strategy: !(options === null || options === void 0 ? void 0 : options.chunkingStrategy)
|
|
94
|
+
? options === null || options === void 0 ? void 0 : options.chunkingStrategy
|
|
95
|
+
: vectorStoreChunkingStrategyRequestUnionSerializer(options === null || options === void 0 ? void 0 : options.chunkingStrategy),
|
|
96
|
+
} }));
|
|
97
|
+
}
|
|
98
|
+
export async function _createVectorStoreFileBatchDeserialize(result) {
|
|
99
|
+
const expectedStatuses = ["200"];
|
|
100
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
101
|
+
throw createRestError(result);
|
|
102
|
+
}
|
|
103
|
+
return vectorStoreFileBatchDeserializer(result.body);
|
|
104
|
+
}
|
|
105
|
+
/** Create a vector store file batch. */
|
|
106
|
+
export async function createVectorStoreFileBatchInternal(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
107
|
+
const result = await _createVectorStoreFileBatchSend(context, vectorStoreId, options);
|
|
108
|
+
return _createVectorStoreFileBatchDeserialize(result);
|
|
109
|
+
}
|
|
110
|
+
/** Create a vector store file batch. */
|
|
111
|
+
export function createVectorStoreFileBatch(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
112
|
+
var _a;
|
|
113
|
+
return createPoller({
|
|
114
|
+
initOperation: async () => {
|
|
115
|
+
return createVectorStoreFileBatchInternal(context, vectorStoreId, options);
|
|
116
|
+
},
|
|
117
|
+
pollOperation: async (currentResult) => {
|
|
118
|
+
return getVectorStoreFileBatch(context, vectorStoreId, currentResult.id, options);
|
|
119
|
+
},
|
|
120
|
+
getOperationStatus: getLroOperationStatus,
|
|
121
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Create a vector store file batch and poll. */
|
|
125
|
+
export function createVectorStoreFileBatchAndPoll(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
126
|
+
var _a;
|
|
127
|
+
return createPoller({
|
|
128
|
+
initOperation: async () => {
|
|
129
|
+
return createVectorStoreFileBatchInternal(context, vectorStoreId, options);
|
|
130
|
+
},
|
|
131
|
+
pollOperation: async (currentResult) => {
|
|
132
|
+
return getVectorStoreFileBatch(context, vectorStoreId, currentResult.id, options);
|
|
133
|
+
},
|
|
134
|
+
getOperationStatus: getLroOperationStatus,
|
|
135
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export function _deleteVectorStoreFileSend(context, vectorStoreId, fileId, options = { requestOptions: {} }) {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/files/{fileId}{?api%2Dversion}", {
|
|
141
|
+
vectorStoreId: vectorStoreId,
|
|
142
|
+
fileId: fileId,
|
|
143
|
+
"api%2Dversion": context.apiVersion,
|
|
144
|
+
}, {
|
|
145
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
146
|
+
});
|
|
147
|
+
return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
148
|
+
}
|
|
149
|
+
export async function _deleteVectorStoreFileDeserialize(result) {
|
|
150
|
+
const expectedStatuses = ["200"];
|
|
151
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
152
|
+
throw createRestError(result);
|
|
153
|
+
}
|
|
154
|
+
return vectorStoreFileDeletionStatusDeserializer(result.body);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted.
|
|
158
|
+
* To delete the file, use the delete file endpoint.
|
|
159
|
+
*/
|
|
160
|
+
export async function deleteVectorStoreFile(context, vectorStoreId, fileId, options = { requestOptions: {} }) {
|
|
161
|
+
const result = await _deleteVectorStoreFileSend(context, vectorStoreId, fileId, options);
|
|
162
|
+
return _deleteVectorStoreFileDeserialize(result);
|
|
163
|
+
}
|
|
164
|
+
export function _getVectorStoreFileSend(context, vectorStoreId, fileId, options = { requestOptions: {} }) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/files/{fileId}{?api%2Dversion}", {
|
|
167
|
+
vectorStoreId: vectorStoreId,
|
|
168
|
+
fileId: fileId,
|
|
169
|
+
"api%2Dversion": context.apiVersion,
|
|
170
|
+
}, {
|
|
171
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
172
|
+
});
|
|
173
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
174
|
+
}
|
|
175
|
+
export async function _getVectorStoreFileDeserialize(result) {
|
|
176
|
+
const expectedStatuses = ["200"];
|
|
177
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
178
|
+
throw createRestError(result);
|
|
179
|
+
}
|
|
180
|
+
return vectorStoreFileDeserializer(result.body);
|
|
181
|
+
}
|
|
182
|
+
/** Retrieves a vector store file. */
|
|
183
|
+
export async function getVectorStoreFile(context, vectorStoreId, fileId, options = { requestOptions: {} }) {
|
|
184
|
+
const result = await _getVectorStoreFileSend(context, vectorStoreId, fileId, options);
|
|
185
|
+
return _getVectorStoreFileDeserialize(result);
|
|
186
|
+
}
|
|
187
|
+
export function _createVectorStoreFileSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/files{?api%2Dversion}", {
|
|
190
|
+
vectorStoreId: vectorStoreId,
|
|
191
|
+
"api%2Dversion": context.apiVersion,
|
|
192
|
+
}, {
|
|
193
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
194
|
+
});
|
|
195
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
196
|
+
file_id: options === null || options === void 0 ? void 0 : options.fileId,
|
|
197
|
+
data_source: !(options === null || options === void 0 ? void 0 : options.dataSource)
|
|
198
|
+
? options === null || options === void 0 ? void 0 : options.dataSource
|
|
199
|
+
: vectorStoreDataSourceSerializer(options === null || options === void 0 ? void 0 : options.dataSource),
|
|
200
|
+
chunking_strategy: !(options === null || options === void 0 ? void 0 : options.chunkingStrategy)
|
|
201
|
+
? options === null || options === void 0 ? void 0 : options.chunkingStrategy
|
|
202
|
+
: vectorStoreChunkingStrategyRequestUnionSerializer(options === null || options === void 0 ? void 0 : options.chunkingStrategy),
|
|
203
|
+
} }));
|
|
204
|
+
}
|
|
205
|
+
export async function _createVectorStoreFileDeserialize(result) {
|
|
206
|
+
const expectedStatuses = ["200"];
|
|
207
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
208
|
+
throw createRestError(result);
|
|
209
|
+
}
|
|
210
|
+
return vectorStoreFileDeserializer(result.body);
|
|
211
|
+
}
|
|
212
|
+
/** Create a vector store file by attaching a file to a vector store. */
|
|
213
|
+
export async function createVectorStoreFileInternal(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
214
|
+
const result = await _createVectorStoreFileSend(context, vectorStoreId, options);
|
|
215
|
+
return _createVectorStoreFileDeserialize(result);
|
|
216
|
+
}
|
|
217
|
+
/** Create a vector store file by attaching a file to a vector store. */
|
|
218
|
+
export function createVectorStoreFile(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
219
|
+
var _a;
|
|
220
|
+
return createPoller({
|
|
221
|
+
initOperation: async () => {
|
|
222
|
+
return createVectorStoreFileInternal(context, vectorStoreId, options);
|
|
223
|
+
},
|
|
224
|
+
pollOperation: async (currentResult) => {
|
|
225
|
+
return getVectorStoreFile(context, vectorStoreId, currentResult.id, options);
|
|
226
|
+
},
|
|
227
|
+
getOperationStatus: getLroOperationStatus,
|
|
228
|
+
getOperationError: (result) => {
|
|
229
|
+
return result.status === "failed" && result.lastError
|
|
230
|
+
? new Error(`Operation failed with code ${result.lastError.code}: ${result.lastError.message}`)
|
|
231
|
+
: undefined;
|
|
232
|
+
},
|
|
233
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/** Create a vector store file by attaching a file to a vector store and poll. */
|
|
237
|
+
export function createVectorStoreFileAndPoll(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
238
|
+
var _a;
|
|
239
|
+
return createPoller({
|
|
240
|
+
initOperation: async () => {
|
|
241
|
+
return createVectorStoreFileInternal(context, vectorStoreId, options);
|
|
242
|
+
},
|
|
243
|
+
pollOperation: async (currentResult) => {
|
|
244
|
+
return getVectorStoreFile(context, vectorStoreId, currentResult.id, options);
|
|
245
|
+
},
|
|
246
|
+
getOperationStatus: getLroOperationStatus,
|
|
247
|
+
getOperationError: (result) => {
|
|
248
|
+
return result.status === "failed" && result.lastError
|
|
249
|
+
? new Error(`Operation failed with code ${result.lastError.code}: ${result.lastError.message}`)
|
|
250
|
+
: undefined;
|
|
251
|
+
},
|
|
252
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export function _listVectorStoreFilesSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
256
|
+
var _a, _b;
|
|
257
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}/files{?api%2Dversion,filter,limit,order,after,before}", {
|
|
258
|
+
vectorStoreId: vectorStoreId,
|
|
259
|
+
"api%2Dversion": context.apiVersion,
|
|
260
|
+
filter: options === null || options === void 0 ? void 0 : options.filter,
|
|
261
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
262
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
263
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
264
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
265
|
+
}, {
|
|
266
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
267
|
+
});
|
|
268
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
269
|
+
}
|
|
270
|
+
export async function _listVectorStoreFilesDeserialize(result) {
|
|
271
|
+
const expectedStatuses = ["200"];
|
|
272
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
273
|
+
throw createRestError(result);
|
|
274
|
+
}
|
|
275
|
+
return openAIPageableListOfVectorStoreFileDeserializer(result.body);
|
|
276
|
+
}
|
|
277
|
+
/** Returns a list of vector store files. */
|
|
278
|
+
export async function listVectorStoreFiles(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
279
|
+
const result = await _listVectorStoreFilesSend(context, vectorStoreId, options);
|
|
280
|
+
return _listVectorStoreFilesDeserialize(result);
|
|
281
|
+
}
|
|
282
|
+
export function _deleteVectorStoreSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
283
|
+
var _a, _b;
|
|
284
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}{?api%2Dversion}", {
|
|
285
|
+
vectorStoreId: vectorStoreId,
|
|
286
|
+
"api%2Dversion": context.apiVersion,
|
|
287
|
+
}, {
|
|
288
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
289
|
+
});
|
|
290
|
+
return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
291
|
+
}
|
|
292
|
+
export async function _deleteVectorStoreDeserialize(result) {
|
|
293
|
+
const expectedStatuses = ["200"];
|
|
294
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
295
|
+
throw createRestError(result);
|
|
296
|
+
}
|
|
297
|
+
return vectorStoreDeletionStatusDeserializer(result.body);
|
|
298
|
+
}
|
|
299
|
+
/** Deletes the vector store object matching the specified ID. */
|
|
300
|
+
export async function deleteVectorStore(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
301
|
+
const result = await _deleteVectorStoreSend(context, vectorStoreId, options);
|
|
302
|
+
return _deleteVectorStoreDeserialize(result);
|
|
303
|
+
}
|
|
304
|
+
export function _modifyVectorStoreSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
305
|
+
var _a, _b;
|
|
306
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}{?api%2Dversion}", {
|
|
307
|
+
vectorStoreId: vectorStoreId,
|
|
308
|
+
"api%2Dversion": context.apiVersion,
|
|
309
|
+
}, {
|
|
310
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
311
|
+
});
|
|
312
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
313
|
+
name: options === null || options === void 0 ? void 0 : options.name,
|
|
314
|
+
expires_after: !(options === null || options === void 0 ? void 0 : options.expiresAfter)
|
|
315
|
+
? options === null || options === void 0 ? void 0 : options.expiresAfter
|
|
316
|
+
: vectorStoreExpirationPolicySerializer(options === null || options === void 0 ? void 0 : options.expiresAfter),
|
|
317
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
318
|
+
} }));
|
|
319
|
+
}
|
|
320
|
+
export async function _modifyVectorStoreDeserialize(result) {
|
|
321
|
+
const expectedStatuses = ["200"];
|
|
322
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
323
|
+
throw createRestError(result);
|
|
324
|
+
}
|
|
325
|
+
return vectorStoreDeserializer(result.body);
|
|
326
|
+
}
|
|
327
|
+
/** The ID of the vector store to modify. */
|
|
328
|
+
export async function modifyVectorStore(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
329
|
+
const result = await _modifyVectorStoreSend(context, vectorStoreId, options);
|
|
330
|
+
return _modifyVectorStoreDeserialize(result);
|
|
331
|
+
}
|
|
332
|
+
export function _getVectorStoreSend(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
333
|
+
var _a, _b;
|
|
334
|
+
const path = expandUrlTemplate("/vector_stores/{vectorStoreId}{?api%2Dversion}", {
|
|
335
|
+
vectorStoreId: vectorStoreId,
|
|
336
|
+
"api%2Dversion": context.apiVersion,
|
|
337
|
+
}, {
|
|
338
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
339
|
+
});
|
|
340
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
341
|
+
}
|
|
342
|
+
export async function _getVectorStoreDeserialize(result) {
|
|
343
|
+
const expectedStatuses = ["200"];
|
|
344
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
345
|
+
throw createRestError(result);
|
|
346
|
+
}
|
|
347
|
+
return vectorStoreDeserializer(result.body);
|
|
348
|
+
}
|
|
349
|
+
/** Returns the vector store object matching the specified ID. */
|
|
350
|
+
export async function getVectorStore(context, vectorStoreId, options = { requestOptions: {} }) {
|
|
351
|
+
const result = await _getVectorStoreSend(context, vectorStoreId, options);
|
|
352
|
+
return _getVectorStoreDeserialize(result);
|
|
353
|
+
}
|
|
354
|
+
export function _createVectorStoreSend(context, options = { requestOptions: {} }) {
|
|
355
|
+
var _a;
|
|
356
|
+
return context.path("/vector_stores").post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers), body: {
|
|
357
|
+
file_ids: !(options === null || options === void 0 ? void 0 : options.fileIds)
|
|
358
|
+
? options === null || options === void 0 ? void 0 : options.fileIds
|
|
359
|
+
: options === null || options === void 0 ? void 0 : options.fileIds.map((p) => {
|
|
360
|
+
return p;
|
|
361
|
+
}),
|
|
362
|
+
name: options === null || options === void 0 ? void 0 : options.name,
|
|
363
|
+
configuration: !(options === null || options === void 0 ? void 0 : options.storeConfiguration)
|
|
364
|
+
? options === null || options === void 0 ? void 0 : options.storeConfiguration
|
|
365
|
+
: vectorStoreConfigurationSerializer(options === null || options === void 0 ? void 0 : options.storeConfiguration),
|
|
366
|
+
expires_after: !(options === null || options === void 0 ? void 0 : options.expiresAfter)
|
|
367
|
+
? options === null || options === void 0 ? void 0 : options.expiresAfter
|
|
368
|
+
: vectorStoreExpirationPolicySerializer(options === null || options === void 0 ? void 0 : options.expiresAfter),
|
|
369
|
+
chunking_strategy: !(options === null || options === void 0 ? void 0 : options.chunkingStrategy)
|
|
370
|
+
? options === null || options === void 0 ? void 0 : options.chunkingStrategy
|
|
371
|
+
: vectorStoreChunkingStrategyRequestUnionSerializer(options === null || options === void 0 ? void 0 : options.chunkingStrategy),
|
|
372
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
373
|
+
} }));
|
|
374
|
+
}
|
|
375
|
+
export async function _createVectorStoreDeserialize(result) {
|
|
376
|
+
const expectedStatuses = ["200"];
|
|
377
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
378
|
+
throw createRestError(result);
|
|
379
|
+
}
|
|
380
|
+
return vectorStoreDeserializer(result.body);
|
|
381
|
+
}
|
|
382
|
+
/** Creates a vector store. */
|
|
383
|
+
export async function createVectorStoreInternal(context, options = { requestOptions: {} }) {
|
|
384
|
+
const result = await _createVectorStoreSend(context, options);
|
|
385
|
+
return _createVectorStoreDeserialize(result);
|
|
386
|
+
}
|
|
387
|
+
/** Creates a vector store. */
|
|
388
|
+
export function createVectorStore(context, options = { requestOptions: {} }) {
|
|
389
|
+
var _a;
|
|
390
|
+
return createPoller({
|
|
391
|
+
initOperation: async () => {
|
|
392
|
+
return createVectorStoreInternal(context, options);
|
|
393
|
+
},
|
|
394
|
+
pollOperation: async (currentResult) => {
|
|
395
|
+
return getVectorStore(context, currentResult.id, options);
|
|
396
|
+
},
|
|
397
|
+
getOperationStatus: getLroOperationStatus,
|
|
398
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Creates a vector store and poll.
|
|
403
|
+
*/
|
|
404
|
+
export function createVectorStoreAndPoll(context, options = { requestOptions: {} }) {
|
|
405
|
+
var _a;
|
|
406
|
+
return createPoller({
|
|
407
|
+
initOperation: async () => {
|
|
408
|
+
return createVectorStoreInternal(context, options);
|
|
409
|
+
},
|
|
410
|
+
pollOperation: async (currentResult) => {
|
|
411
|
+
return getVectorStore(context, currentResult.id, options);
|
|
412
|
+
},
|
|
413
|
+
getOperationStatus: getLroOperationStatus,
|
|
414
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export function _listVectorStoresSend(context, options = { requestOptions: {} }) {
|
|
418
|
+
var _a, _b;
|
|
419
|
+
const path = expandUrlTemplate("/vector_stores{?api%2Dversion,limit,order,after,before}", {
|
|
420
|
+
"api%2Dversion": context.apiVersion,
|
|
421
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
422
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
423
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
424
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
425
|
+
}, {
|
|
426
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
427
|
+
});
|
|
428
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
429
|
+
}
|
|
430
|
+
export async function _listVectorStoresDeserialize(result) {
|
|
431
|
+
const expectedStatuses = ["200"];
|
|
432
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
433
|
+
throw createRestError(result);
|
|
434
|
+
}
|
|
435
|
+
return openAIPageableListOfVectorStoreDeserializer(result.body);
|
|
436
|
+
}
|
|
437
|
+
/** Returns a list of vector stores. */
|
|
438
|
+
export async function listVectorStores(context, options = { requestOptions: {} }) {
|
|
439
|
+
const result = await _listVectorStoresSend(context, options);
|
|
440
|
+
return _listVectorStoresDeserialize(result);
|
|
441
|
+
}
|
|
442
|
+
export function _getFileContentSend(context, fileId, options = { requestOptions: {} }) {
|
|
443
|
+
var _a, _b;
|
|
444
|
+
const path = expandUrlTemplate("/files/{fileId}/content{?api%2Dversion}", {
|
|
445
|
+
fileId: fileId,
|
|
446
|
+
"api%2Dversion": context.apiVersion,
|
|
447
|
+
}, {
|
|
448
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
449
|
+
});
|
|
450
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/octet-stream" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
451
|
+
}
|
|
452
|
+
export async function _getFileContentDeserialize(result) {
|
|
453
|
+
const expectedStatuses = ["200"];
|
|
454
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
455
|
+
throw createRestError(result);
|
|
456
|
+
}
|
|
457
|
+
return result.body;
|
|
458
|
+
}
|
|
459
|
+
/** Retrieves the raw content of a specific file. */
|
|
460
|
+
export async function getFileContent(context, fileId, options = { requestOptions: {} }) {
|
|
461
|
+
const result = await _getFileContentSend(context, fileId, options);
|
|
462
|
+
return _getFileContentDeserialize(result);
|
|
463
|
+
}
|
|
464
|
+
export function _getFileSend(context, fileId, options = { requestOptions: {} }) {
|
|
465
|
+
var _a, _b;
|
|
466
|
+
const path = expandUrlTemplate("/files/{fileId}{?api%2Dversion}", {
|
|
467
|
+
fileId: fileId,
|
|
468
|
+
"api%2Dversion": context.apiVersion,
|
|
469
|
+
}, {
|
|
470
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
471
|
+
});
|
|
472
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
473
|
+
}
|
|
474
|
+
export async function _getFileDeserialize(result) {
|
|
475
|
+
const expectedStatuses = ["200"];
|
|
476
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
477
|
+
throw createRestError(result);
|
|
478
|
+
}
|
|
479
|
+
return openAIFileDeserializer(result.body);
|
|
480
|
+
}
|
|
481
|
+
/** Returns information about a specific file. Does not retrieve file content. */
|
|
482
|
+
export async function getFile(context, fileId, options = { requestOptions: {} }) {
|
|
483
|
+
const result = await _getFileSend(context, fileId, options);
|
|
484
|
+
return _getFileDeserialize(result);
|
|
485
|
+
}
|
|
486
|
+
export function _deleteFileSend(context, fileId, options = { requestOptions: {} }) {
|
|
487
|
+
var _a, _b;
|
|
488
|
+
const path = expandUrlTemplate("/files/{fileId}{?api%2Dversion}", {
|
|
489
|
+
fileId: fileId,
|
|
490
|
+
"api%2Dversion": context.apiVersion,
|
|
491
|
+
}, {
|
|
492
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
493
|
+
});
|
|
494
|
+
return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
495
|
+
}
|
|
496
|
+
export async function _deleteFileDeserialize(result) {
|
|
497
|
+
const expectedStatuses = ["200"];
|
|
498
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
499
|
+
throw createRestError(result);
|
|
500
|
+
}
|
|
501
|
+
return fileDeletionStatusDeserializer(result.body);
|
|
502
|
+
}
|
|
503
|
+
/** Delete a previously uploaded file. */
|
|
504
|
+
export async function deleteFile(context, fileId, options = { requestOptions: {} }) {
|
|
505
|
+
const result = await _deleteFileSend(context, fileId, options);
|
|
506
|
+
return _deleteFileDeserialize(result);
|
|
507
|
+
}
|
|
508
|
+
export function _uploadFileSend(context, body, options = { requestOptions: {} }) {
|
|
509
|
+
var _a;
|
|
510
|
+
return context.path("/files").post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "multipart/form-data", headers: Object.assign({ accept: "application/json" }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers), body: _uploadFileRequestSerializer(body) }));
|
|
511
|
+
}
|
|
512
|
+
export async function _uploadFileDeserialize(result) {
|
|
513
|
+
const expectedStatuses = ["200"];
|
|
514
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
515
|
+
throw createRestError(result);
|
|
516
|
+
}
|
|
517
|
+
return openAIFileDeserializer(result.body);
|
|
518
|
+
}
|
|
519
|
+
/** Uploads a file for use by other operations. */
|
|
520
|
+
export async function uploadFileInternal(context, body, options = { requestOptions: {} }) {
|
|
521
|
+
const result = await _uploadFileSend(context, body, options);
|
|
522
|
+
return _uploadFileDeserialize(result);
|
|
523
|
+
}
|
|
524
|
+
/** Uploads a file for use by other operations. */
|
|
525
|
+
export function uploadFile(context, body, options = { requestOptions: {} }) {
|
|
526
|
+
var _a;
|
|
527
|
+
return createPoller({
|
|
528
|
+
initOperation: async () => {
|
|
529
|
+
return uploadFileInternal(context, body, options);
|
|
530
|
+
},
|
|
531
|
+
pollOperation: async (currentResult) => {
|
|
532
|
+
return getFile(context, currentResult.id, options);
|
|
533
|
+
},
|
|
534
|
+
getOperationStatus: getLroOperationStatus,
|
|
535
|
+
getOperationError: (result) => {
|
|
536
|
+
return getLroOperationStatus(result) === "failed" && result.statusDetails
|
|
537
|
+
? new Error(`Operation failed: ${result.statusDetails}`)
|
|
538
|
+
: undefined;
|
|
539
|
+
},
|
|
540
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
export function uploadFileAndPoll(context, body, options = { requestOptions: {} }) {
|
|
544
|
+
var _a;
|
|
545
|
+
return createPoller({
|
|
546
|
+
initOperation: async () => {
|
|
547
|
+
return uploadFileInternal(context, body, options);
|
|
548
|
+
},
|
|
549
|
+
pollOperation: async (currentResult) => {
|
|
550
|
+
return getFile(context, currentResult.id, options);
|
|
551
|
+
},
|
|
552
|
+
getOperationStatus: getLroOperationStatus,
|
|
553
|
+
getOperationError: (result) => {
|
|
554
|
+
return getLroOperationStatus(result) === "failed" && result.statusDetails
|
|
555
|
+
? new Error(`Operation failed: ${result.statusDetails}`)
|
|
556
|
+
: undefined;
|
|
557
|
+
},
|
|
558
|
+
intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function getLroOperationStatus(result) {
|
|
562
|
+
switch (result.status) {
|
|
563
|
+
case "running":
|
|
564
|
+
case "pending":
|
|
565
|
+
return "running";
|
|
566
|
+
case "uploaded":
|
|
567
|
+
case "processed":
|
|
568
|
+
return "succeeded";
|
|
569
|
+
case "in_progress":
|
|
570
|
+
return "running";
|
|
571
|
+
case "completed":
|
|
572
|
+
return "succeeded";
|
|
573
|
+
case "expired":
|
|
574
|
+
return "failed";
|
|
575
|
+
default:
|
|
576
|
+
return "failed";
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
export function _listFilesSend(context, options = { requestOptions: {} }) {
|
|
580
|
+
var _a, _b;
|
|
581
|
+
const path = expandUrlTemplate("/files{?api%2Dversion,purpose}", {
|
|
582
|
+
"api%2Dversion": context.apiVersion,
|
|
583
|
+
purpose: options === null || options === void 0 ? void 0 : options.purpose,
|
|
584
|
+
}, {
|
|
585
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
586
|
+
});
|
|
587
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
588
|
+
}
|
|
589
|
+
export async function _listFilesDeserialize(result) {
|
|
590
|
+
const expectedStatuses = ["200"];
|
|
591
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
592
|
+
throw createRestError(result);
|
|
593
|
+
}
|
|
594
|
+
return fileListResponseDeserializer(result.body);
|
|
595
|
+
}
|
|
596
|
+
/** Gets a list of previously uploaded files. */
|
|
597
|
+
export async function listFiles(context, options = { requestOptions: {} }) {
|
|
598
|
+
const result = await _listFilesSend(context, options);
|
|
599
|
+
return _listFilesDeserialize(result);
|
|
600
|
+
}
|
|
601
|
+
export function _listRunStepsSend(context, threadId, runId, options = { requestOptions: {} }) {
|
|
602
|
+
var _a, _b;
|
|
603
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}/steps{?api%2Dversion,include%5B%5D,limit,order,after,before}", {
|
|
604
|
+
threadId: threadId,
|
|
605
|
+
runId: runId,
|
|
606
|
+
"api%2Dversion": context.apiVersion,
|
|
607
|
+
"include%5B%5D": !(options === null || options === void 0 ? void 0 : options.include)
|
|
608
|
+
? options === null || options === void 0 ? void 0 : options.include
|
|
609
|
+
: options === null || options === void 0 ? void 0 : options.include.map((p) => {
|
|
610
|
+
return p;
|
|
611
|
+
}),
|
|
612
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
613
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
614
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
615
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
616
|
+
}, {
|
|
617
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
618
|
+
});
|
|
619
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
620
|
+
}
|
|
621
|
+
export async function _listRunStepsDeserialize(result) {
|
|
622
|
+
const expectedStatuses = ["200"];
|
|
623
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
624
|
+
throw createRestError(result);
|
|
625
|
+
}
|
|
626
|
+
return openAIPageableListOfRunStepDeserializer(result.body);
|
|
627
|
+
}
|
|
628
|
+
/** Gets a list of run steps from a thread run. */
|
|
629
|
+
export async function listRunSteps(context, threadId, runId, options = { requestOptions: {} }) {
|
|
630
|
+
const result = await _listRunStepsSend(context, threadId, runId, options);
|
|
631
|
+
return _listRunStepsDeserialize(result);
|
|
632
|
+
}
|
|
633
|
+
export function _getRunStepSend(context, threadId, runId, stepId, options = { requestOptions: {} }) {
|
|
634
|
+
var _a, _b;
|
|
635
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}/steps/{stepId}{?api%2Dversion,include%5B%5D}", {
|
|
636
|
+
threadId: threadId,
|
|
637
|
+
runId: runId,
|
|
638
|
+
stepId: stepId,
|
|
639
|
+
"api%2Dversion": context.apiVersion,
|
|
640
|
+
"include%5B%5D": !(options === null || options === void 0 ? void 0 : options.include)
|
|
641
|
+
? options === null || options === void 0 ? void 0 : options.include
|
|
642
|
+
: options === null || options === void 0 ? void 0 : options.include.map((p) => {
|
|
643
|
+
return p;
|
|
644
|
+
}),
|
|
645
|
+
}, {
|
|
646
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
647
|
+
});
|
|
648
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
649
|
+
}
|
|
650
|
+
export async function _getRunStepDeserialize(result) {
|
|
651
|
+
const expectedStatuses = ["200"];
|
|
652
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
653
|
+
throw createRestError(result);
|
|
654
|
+
}
|
|
655
|
+
return runStepDeserializer(result.body);
|
|
656
|
+
}
|
|
657
|
+
/** Gets a single run step from a thread run. */
|
|
658
|
+
export async function getRunStep(context, threadId, runId, stepId, options = { requestOptions: {} }) {
|
|
659
|
+
const result = await _getRunStepSend(context, threadId, runId, stepId, options);
|
|
660
|
+
return _getRunStepDeserialize(result);
|
|
661
|
+
}
|
|
662
|
+
export function _createThreadAndRunSend(context, assistantId, options = { requestOptions: {} }) {
|
|
663
|
+
var _a, _b;
|
|
664
|
+
const path = expandUrlTemplate("/threads/runs{?api%2Dversion}", {
|
|
665
|
+
"api%2Dversion": context.apiVersion,
|
|
666
|
+
}, {
|
|
667
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
668
|
+
});
|
|
669
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
670
|
+
assistant_id: assistantId,
|
|
671
|
+
thread: !(options === null || options === void 0 ? void 0 : options.thread)
|
|
672
|
+
? options === null || options === void 0 ? void 0 : options.thread
|
|
673
|
+
: agentThreadCreationOptionsSerializer(options === null || options === void 0 ? void 0 : options.thread),
|
|
674
|
+
model: options === null || options === void 0 ? void 0 : options.model,
|
|
675
|
+
instructions: options === null || options === void 0 ? void 0 : options.instructions,
|
|
676
|
+
tools: !(options === null || options === void 0 ? void 0 : options.tools) ? options === null || options === void 0 ? void 0 : options.tools : toolDefinitionUnionArraySerializer(options === null || options === void 0 ? void 0 : options.tools),
|
|
677
|
+
tool_resources: !(options === null || options === void 0 ? void 0 : options.toolResources)
|
|
678
|
+
? options === null || options === void 0 ? void 0 : options.toolResources
|
|
679
|
+
: updateToolResourcesOptionsSerializer(options === null || options === void 0 ? void 0 : options.toolResources),
|
|
680
|
+
stream: options === null || options === void 0 ? void 0 : options.stream,
|
|
681
|
+
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
682
|
+
top_p: options === null || options === void 0 ? void 0 : options.topP,
|
|
683
|
+
max_prompt_tokens: options === null || options === void 0 ? void 0 : options.maxPromptTokens,
|
|
684
|
+
max_completion_tokens: options === null || options === void 0 ? void 0 : options.maxCompletionTokens,
|
|
685
|
+
truncation_strategy: !(options === null || options === void 0 ? void 0 : options.truncationStrategy)
|
|
686
|
+
? options === null || options === void 0 ? void 0 : options.truncationStrategy
|
|
687
|
+
: truncationObjectSerializer(options === null || options === void 0 ? void 0 : options.truncationStrategy),
|
|
688
|
+
tool_choice: !(options === null || options === void 0 ? void 0 : options.toolChoice)
|
|
689
|
+
? options === null || options === void 0 ? void 0 : options.toolChoice
|
|
690
|
+
: agentsApiToolChoiceOptionSerializer(options === null || options === void 0 ? void 0 : options.toolChoice),
|
|
691
|
+
response_format: !(options === null || options === void 0 ? void 0 : options.responseFormat)
|
|
692
|
+
? options === null || options === void 0 ? void 0 : options.responseFormat
|
|
693
|
+
: agentsApiResponseFormatOptionSerializer(options === null || options === void 0 ? void 0 : options.responseFormat),
|
|
694
|
+
parallel_tool_calls: options === null || options === void 0 ? void 0 : options.parallelToolCalls,
|
|
695
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
696
|
+
} }));
|
|
697
|
+
}
|
|
698
|
+
export async function _createThreadAndRunDeserialize(result) {
|
|
699
|
+
const expectedStatuses = ["200"];
|
|
700
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
701
|
+
throw createRestError(result);
|
|
702
|
+
}
|
|
703
|
+
return threadRunDeserializer(result.body);
|
|
704
|
+
}
|
|
705
|
+
/** Creates a new agent thread and immediately starts a run using that new thread. */
|
|
706
|
+
export function createThreadAndRun(context, assistantId, options = { requestOptions: {} }) {
|
|
707
|
+
async function executeCreateThreadAndRun() {
|
|
708
|
+
const result = await _createThreadAndRunSend(context, assistantId, options);
|
|
709
|
+
return _createThreadAndRunDeserialize(result);
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
then: function (onFulfilled, onRejected) {
|
|
713
|
+
return executeCreateThreadAndRun().then(onFulfilled, onRejected).catch(onRejected);
|
|
714
|
+
},
|
|
715
|
+
async stream() {
|
|
716
|
+
return createThreadAndRunStreaming(context, assistantId, options);
|
|
717
|
+
},
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
export function _cancelRunSend(context, threadId, runId, options = { requestOptions: {} }) {
|
|
721
|
+
var _a, _b;
|
|
722
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}/cancel{?api%2Dversion}", {
|
|
723
|
+
threadId: threadId,
|
|
724
|
+
runId: runId,
|
|
725
|
+
"api%2Dversion": context.apiVersion,
|
|
726
|
+
}, {
|
|
727
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
728
|
+
});
|
|
729
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
730
|
+
}
|
|
731
|
+
export async function _cancelRunDeserialize(result) {
|
|
732
|
+
const expectedStatuses = ["200"];
|
|
733
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
734
|
+
throw createRestError(result);
|
|
735
|
+
}
|
|
736
|
+
return threadRunDeserializer(result.body);
|
|
737
|
+
}
|
|
738
|
+
/** Cancels a run of an in progress thread. */
|
|
739
|
+
export async function cancelRun(context, threadId, runId, options = { requestOptions: {} }) {
|
|
740
|
+
const result = await _cancelRunSend(context, threadId, runId, options);
|
|
741
|
+
return _cancelRunDeserialize(result);
|
|
742
|
+
}
|
|
743
|
+
export function _submitToolOutputsToRunSend(context, threadId, runId, toolOutputs, options = { requestOptions: {} }) {
|
|
744
|
+
var _a, _b;
|
|
745
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}/submit_tool_outputs{?api%2Dversion}", {
|
|
746
|
+
threadId: threadId,
|
|
747
|
+
runId: runId,
|
|
748
|
+
"api%2Dversion": context.apiVersion,
|
|
749
|
+
}, {
|
|
750
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
751
|
+
});
|
|
752
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
753
|
+
tool_outputs: toolOutputArraySerializer(toolOutputs),
|
|
754
|
+
stream: options === null || options === void 0 ? void 0 : options.stream,
|
|
755
|
+
} }));
|
|
756
|
+
}
|
|
757
|
+
export async function _submitToolOutputsToRunDeserialize(result) {
|
|
758
|
+
const expectedStatuses = ["200"];
|
|
759
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
760
|
+
throw createRestError(result);
|
|
761
|
+
}
|
|
762
|
+
return threadRunDeserializer(result.body);
|
|
763
|
+
}
|
|
764
|
+
/** Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. */
|
|
765
|
+
export async function submitToolOutputsToRun(context, threadId, runId, toolOutputs, options = { requestOptions: {} }) {
|
|
766
|
+
const result = await _submitToolOutputsToRunSend(context, threadId, runId, toolOutputs, options);
|
|
767
|
+
return _submitToolOutputsToRunDeserialize(result);
|
|
768
|
+
}
|
|
769
|
+
export function _updateRunSend(context, threadId, runId, options = { requestOptions: {} }) {
|
|
770
|
+
var _a, _b;
|
|
771
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}{?api%2Dversion}", {
|
|
772
|
+
threadId: threadId,
|
|
773
|
+
runId: runId,
|
|
774
|
+
"api%2Dversion": context.apiVersion,
|
|
775
|
+
}, {
|
|
776
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
777
|
+
});
|
|
778
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: { metadata: options === null || options === void 0 ? void 0 : options.metadata } }));
|
|
779
|
+
}
|
|
780
|
+
export async function _updateRunDeserialize(result) {
|
|
781
|
+
const expectedStatuses = ["200"];
|
|
782
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
783
|
+
throw createRestError(result);
|
|
784
|
+
}
|
|
785
|
+
return threadRunDeserializer(result.body);
|
|
786
|
+
}
|
|
787
|
+
/** Modifies an existing thread run. */
|
|
788
|
+
export async function updateRun(context, threadId, runId, options = { requestOptions: {} }) {
|
|
789
|
+
const result = await _updateRunSend(context, threadId, runId, options);
|
|
790
|
+
return _updateRunDeserialize(result);
|
|
791
|
+
}
|
|
792
|
+
export function _getRunSend(context, threadId, runId, options = { requestOptions: {} }) {
|
|
793
|
+
var _a, _b;
|
|
794
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs/{runId}{?api%2Dversion}", {
|
|
795
|
+
threadId: threadId,
|
|
796
|
+
runId: runId,
|
|
797
|
+
"api%2Dversion": context.apiVersion,
|
|
798
|
+
}, {
|
|
799
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
800
|
+
});
|
|
801
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
802
|
+
}
|
|
803
|
+
export async function _getRunDeserialize(result) {
|
|
804
|
+
const expectedStatuses = ["200"];
|
|
805
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
806
|
+
throw createRestError(result);
|
|
807
|
+
}
|
|
808
|
+
return threadRunDeserializer(result.body);
|
|
809
|
+
}
|
|
810
|
+
/** Gets an existing run from an existing thread. */
|
|
811
|
+
export async function getRun(context, threadId, runId, options = { requestOptions: {} }) {
|
|
812
|
+
const result = await _getRunSend(context, threadId, runId, options);
|
|
813
|
+
return _getRunDeserialize(result);
|
|
814
|
+
}
|
|
815
|
+
export function _listRunsSend(context, threadId, options = { requestOptions: {} }) {
|
|
816
|
+
var _a, _b;
|
|
817
|
+
const path = expandUrlTemplate("/threads/{threadId}/runs{?api%2Dversion,limit,order,after,before}", {
|
|
818
|
+
threadId: threadId,
|
|
819
|
+
"api%2Dversion": context.apiVersion,
|
|
820
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
821
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
822
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
823
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
824
|
+
}, {
|
|
825
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
826
|
+
});
|
|
827
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
828
|
+
}
|
|
829
|
+
export async function _listRunsDeserialize(result) {
|
|
830
|
+
const expectedStatuses = ["200"];
|
|
831
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
832
|
+
throw createRestError(result);
|
|
833
|
+
}
|
|
834
|
+
return openAIPageableListOfThreadRunDeserializer(result.body);
|
|
835
|
+
}
|
|
836
|
+
/** Gets a list of runs for a specified thread. */
|
|
837
|
+
export async function listRuns(context, threadId, options = { requestOptions: {} }) {
|
|
838
|
+
const result = await _listRunsSend(context, threadId, options);
|
|
839
|
+
return _listRunsDeserialize(result);
|
|
840
|
+
}
|
|
841
|
+
export function _createRunSend(context, threadId, assistantId, options = { requestOptions: {} }) {
|
|
842
|
+
var _a;
|
|
843
|
+
return context.path("/threads/{threadId}/runs", threadId).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers), body: {
|
|
844
|
+
assistant_id: assistantId,
|
|
845
|
+
model: options === null || options === void 0 ? void 0 : options.model,
|
|
846
|
+
instructions: options === null || options === void 0 ? void 0 : options.instructions,
|
|
847
|
+
additional_instructions: options === null || options === void 0 ? void 0 : options.additionalInstructions,
|
|
848
|
+
additional_messages: !(options === null || options === void 0 ? void 0 : options.additionalMessages)
|
|
849
|
+
? options === null || options === void 0 ? void 0 : options.additionalMessages
|
|
850
|
+
: threadMessageOptionsArraySerializer(options === null || options === void 0 ? void 0 : options.additionalMessages),
|
|
851
|
+
tools: !(options === null || options === void 0 ? void 0 : options.tools) ? options === null || options === void 0 ? void 0 : options.tools : toolDefinitionUnionArraySerializer(options === null || options === void 0 ? void 0 : options.tools),
|
|
852
|
+
stream: options === null || options === void 0 ? void 0 : options.stream,
|
|
853
|
+
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
854
|
+
top_p: options === null || options === void 0 ? void 0 : options.topP,
|
|
855
|
+
max_prompt_tokens: options === null || options === void 0 ? void 0 : options.maxPromptTokens,
|
|
856
|
+
max_completion_tokens: options === null || options === void 0 ? void 0 : options.maxCompletionTokens,
|
|
857
|
+
truncation_strategy: !(options === null || options === void 0 ? void 0 : options.truncationStrategy)
|
|
858
|
+
? options === null || options === void 0 ? void 0 : options.truncationStrategy
|
|
859
|
+
: truncationObjectSerializer(options === null || options === void 0 ? void 0 : options.truncationStrategy),
|
|
860
|
+
tool_choice: !(options === null || options === void 0 ? void 0 : options.toolChoice)
|
|
861
|
+
? options === null || options === void 0 ? void 0 : options.toolChoice
|
|
862
|
+
: agentsApiToolChoiceOptionSerializer(options === null || options === void 0 ? void 0 : options.toolChoice),
|
|
863
|
+
response_format: !(options === null || options === void 0 ? void 0 : options.responseFormat)
|
|
864
|
+
? options === null || options === void 0 ? void 0 : options.responseFormat
|
|
865
|
+
: agentsApiResponseFormatOptionSerializer(options === null || options === void 0 ? void 0 : options.responseFormat),
|
|
866
|
+
parallel_tool_calls: options === null || options === void 0 ? void 0 : options.parallelToolCalls,
|
|
867
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
868
|
+
} }));
|
|
869
|
+
}
|
|
870
|
+
export async function _createRunDeserialize(result) {
|
|
871
|
+
const expectedStatuses = ["200"];
|
|
872
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
873
|
+
throw createRestError(result);
|
|
874
|
+
}
|
|
875
|
+
return threadRunDeserializer(result.body);
|
|
876
|
+
}
|
|
877
|
+
/** Creates a new run for an agent thread. */
|
|
878
|
+
export function createRun(context, threadId, assistantId, options) {
|
|
879
|
+
async function executeCreateRun() {
|
|
880
|
+
const result = await _createRunSend(context, threadId, assistantId, options);
|
|
881
|
+
return _createRunDeserialize(result);
|
|
882
|
+
}
|
|
883
|
+
return {
|
|
884
|
+
then: function (onFulfilled, onRejected) {
|
|
885
|
+
return executeCreateRun().then(onFulfilled, onRejected).catch(onRejected);
|
|
886
|
+
},
|
|
887
|
+
async stream() {
|
|
888
|
+
return createRunStreaming(context, assistantId, threadId, options);
|
|
889
|
+
},
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
export function _updateMessageSend(context, threadId, messageId, options = { requestOptions: {} }) {
|
|
893
|
+
var _a, _b;
|
|
894
|
+
const path = expandUrlTemplate("/threads/{threadId}/messages/{messageId}{?api%2Dversion}", {
|
|
895
|
+
threadId: threadId,
|
|
896
|
+
messageId: messageId,
|
|
897
|
+
"api%2Dversion": context.apiVersion,
|
|
898
|
+
}, {
|
|
899
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
900
|
+
});
|
|
901
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: { metadata: options === null || options === void 0 ? void 0 : options.metadata } }));
|
|
902
|
+
}
|
|
903
|
+
export async function _updateMessageDeserialize(result) {
|
|
904
|
+
const expectedStatuses = ["200"];
|
|
905
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
906
|
+
throw createRestError(result);
|
|
907
|
+
}
|
|
908
|
+
return threadMessageDeserializer(result.body);
|
|
909
|
+
}
|
|
910
|
+
/** Modifies an existing message on an existing thread. */
|
|
911
|
+
export async function updateMessage(context, threadId, messageId, options = { requestOptions: {} }) {
|
|
912
|
+
const result = await _updateMessageSend(context, threadId, messageId, options);
|
|
913
|
+
return _updateMessageDeserialize(result);
|
|
914
|
+
}
|
|
915
|
+
export function _getMessageSend(context, threadId, messageId, options = { requestOptions: {} }) {
|
|
916
|
+
var _a, _b;
|
|
917
|
+
const path = expandUrlTemplate("/threads/{threadId}/messages/{messageId}{?api%2Dversion}", {
|
|
918
|
+
threadId: threadId,
|
|
919
|
+
messageId: messageId,
|
|
920
|
+
"api%2Dversion": context.apiVersion,
|
|
921
|
+
}, {
|
|
922
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
923
|
+
});
|
|
924
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
925
|
+
}
|
|
926
|
+
export async function _getMessageDeserialize(result) {
|
|
927
|
+
const expectedStatuses = ["200"];
|
|
928
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
929
|
+
throw createRestError(result);
|
|
930
|
+
}
|
|
931
|
+
return threadMessageDeserializer(result.body);
|
|
932
|
+
}
|
|
933
|
+
/** Gets an existing message from an existing thread. */
|
|
934
|
+
export async function getMessage(context, threadId, messageId, options = { requestOptions: {} }) {
|
|
935
|
+
const result = await _getMessageSend(context, threadId, messageId, options);
|
|
936
|
+
return _getMessageDeserialize(result);
|
|
937
|
+
}
|
|
938
|
+
export function _listMessagesSend(context, threadId, options = { requestOptions: {} }) {
|
|
939
|
+
var _a, _b;
|
|
940
|
+
const path = expandUrlTemplate("/threads/{threadId}/messages{?api%2Dversion,runId,limit,order,after,before}", {
|
|
941
|
+
threadId: threadId,
|
|
942
|
+
"api%2Dversion": context.apiVersion,
|
|
943
|
+
runId: options === null || options === void 0 ? void 0 : options.runId,
|
|
944
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
945
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
946
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
947
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
948
|
+
}, {
|
|
949
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
950
|
+
});
|
|
951
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
952
|
+
}
|
|
953
|
+
export async function _listMessagesDeserialize(result) {
|
|
954
|
+
const expectedStatuses = ["200"];
|
|
955
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
956
|
+
throw createRestError(result);
|
|
957
|
+
}
|
|
958
|
+
return openAIPageableListOfThreadMessageDeserializer(result.body);
|
|
959
|
+
}
|
|
960
|
+
/** Gets a list of messages that exist on a thread. */
|
|
961
|
+
export async function listMessages(context, threadId, options = { requestOptions: {} }) {
|
|
962
|
+
const result = await _listMessagesSend(context, threadId, options);
|
|
963
|
+
return _listMessagesDeserialize(result);
|
|
964
|
+
}
|
|
965
|
+
export function _createMessageSend(context, threadId, role, content, options = { requestOptions: {} }) {
|
|
966
|
+
var _a, _b;
|
|
967
|
+
const path = expandUrlTemplate("/threads/{threadId}/messages{?api%2Dversion}", {
|
|
968
|
+
threadId: threadId,
|
|
969
|
+
"api%2Dversion": context.apiVersion,
|
|
970
|
+
}, {
|
|
971
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
972
|
+
});
|
|
973
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
974
|
+
role: role,
|
|
975
|
+
content: messageInputContentSerializer(content),
|
|
976
|
+
attachments: !(options === null || options === void 0 ? void 0 : options.attachments)
|
|
977
|
+
? options === null || options === void 0 ? void 0 : options.attachments
|
|
978
|
+
: messageAttachmentArraySerializer(options === null || options === void 0 ? void 0 : options.attachments),
|
|
979
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
980
|
+
} }));
|
|
981
|
+
}
|
|
982
|
+
export async function _createMessageDeserialize(result) {
|
|
983
|
+
const expectedStatuses = ["200"];
|
|
984
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
985
|
+
throw createRestError(result);
|
|
986
|
+
}
|
|
987
|
+
return threadMessageDeserializer(result.body);
|
|
988
|
+
}
|
|
989
|
+
/** Creates a new message on a specified thread. */
|
|
990
|
+
export async function createMessage(context, threadId, role, content, options = { requestOptions: {} }) {
|
|
991
|
+
const result = await _createMessageSend(context, threadId, role, content, options);
|
|
992
|
+
return _createMessageDeserialize(result);
|
|
993
|
+
}
|
|
994
|
+
export function _listThreadsSend(context, options = { requestOptions: {} }) {
|
|
995
|
+
var _a, _b;
|
|
996
|
+
const path = expandUrlTemplate("/threads{?api%2Dversion,limit,order,after,before}", {
|
|
997
|
+
"api%2Dversion": context.apiVersion,
|
|
998
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
999
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
1000
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
1001
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
1002
|
+
}, {
|
|
1003
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1004
|
+
});
|
|
1005
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1006
|
+
}
|
|
1007
|
+
export async function _listThreadsDeserialize(result) {
|
|
1008
|
+
const expectedStatuses = ["200"];
|
|
1009
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1010
|
+
throw createRestError(result);
|
|
1011
|
+
}
|
|
1012
|
+
return openAIPageableListOfAgentThreadDeserializer(result.body);
|
|
1013
|
+
}
|
|
1014
|
+
/** Gets a list of threads that were previously created. */
|
|
1015
|
+
export async function listThreads(context, options = { requestOptions: {} }) {
|
|
1016
|
+
const result = await _listThreadsSend(context, options);
|
|
1017
|
+
return _listThreadsDeserialize(result);
|
|
1018
|
+
}
|
|
1019
|
+
export function _deleteThreadSend(context, threadId, options = { requestOptions: {} }) {
|
|
1020
|
+
var _a, _b;
|
|
1021
|
+
const path = expandUrlTemplate("/threads/{threadId}{?api%2Dversion}", {
|
|
1022
|
+
threadId: threadId,
|
|
1023
|
+
"api%2Dversion": context.apiVersion,
|
|
1024
|
+
}, {
|
|
1025
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1026
|
+
});
|
|
1027
|
+
return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1028
|
+
}
|
|
1029
|
+
export async function _deleteThreadDeserialize(result) {
|
|
1030
|
+
const expectedStatuses = ["200"];
|
|
1031
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1032
|
+
throw createRestError(result);
|
|
1033
|
+
}
|
|
1034
|
+
return threadDeletionStatusDeserializer(result.body);
|
|
1035
|
+
}
|
|
1036
|
+
/** Deletes an existing thread. */
|
|
1037
|
+
export async function deleteThread(context, threadId, options = { requestOptions: {} }) {
|
|
1038
|
+
const result = await _deleteThreadSend(context, threadId, options);
|
|
1039
|
+
return _deleteThreadDeserialize(result);
|
|
1040
|
+
}
|
|
1041
|
+
export function _updateThreadSend(context, threadId, options = { requestOptions: {} }) {
|
|
1042
|
+
var _a, _b;
|
|
1043
|
+
const path = expandUrlTemplate("/threads/{threadId}{?api%2Dversion}", {
|
|
1044
|
+
threadId: threadId,
|
|
1045
|
+
"api%2Dversion": context.apiVersion,
|
|
1046
|
+
}, {
|
|
1047
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1048
|
+
});
|
|
1049
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
1050
|
+
tool_resources: !(options === null || options === void 0 ? void 0 : options.toolResources)
|
|
1051
|
+
? options === null || options === void 0 ? void 0 : options.toolResources
|
|
1052
|
+
: toolResourcesSerializer(options === null || options === void 0 ? void 0 : options.toolResources),
|
|
1053
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
1054
|
+
} }));
|
|
1055
|
+
}
|
|
1056
|
+
export async function _updateThreadDeserialize(result) {
|
|
1057
|
+
const expectedStatuses = ["200"];
|
|
1058
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1059
|
+
throw createRestError(result);
|
|
1060
|
+
}
|
|
1061
|
+
return agentThreadDeserializer(result.body);
|
|
1062
|
+
}
|
|
1063
|
+
/** Modifies an existing thread. */
|
|
1064
|
+
export async function updateThread(context, threadId, options = { requestOptions: {} }) {
|
|
1065
|
+
const result = await _updateThreadSend(context, threadId, options);
|
|
1066
|
+
return _updateThreadDeserialize(result);
|
|
1067
|
+
}
|
|
1068
|
+
export function _getThreadSend(context, threadId, options = { requestOptions: {} }) {
|
|
1069
|
+
var _a, _b;
|
|
1070
|
+
const path = expandUrlTemplate("/threads/{threadId}{?api%2Dversion}", {
|
|
1071
|
+
threadId: threadId,
|
|
1072
|
+
"api%2Dversion": context.apiVersion,
|
|
1073
|
+
}, {
|
|
1074
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1075
|
+
});
|
|
1076
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1077
|
+
}
|
|
1078
|
+
export async function _getThreadDeserialize(result) {
|
|
1079
|
+
const expectedStatuses = ["200"];
|
|
1080
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1081
|
+
throw createRestError(result);
|
|
1082
|
+
}
|
|
1083
|
+
return agentThreadDeserializer(result.body);
|
|
1084
|
+
}
|
|
1085
|
+
/** Gets information about an existing thread. */
|
|
1086
|
+
export async function getThread(context, threadId, options = { requestOptions: {} }) {
|
|
1087
|
+
const result = await _getThreadSend(context, threadId, options);
|
|
1088
|
+
return _getThreadDeserialize(result);
|
|
1089
|
+
}
|
|
1090
|
+
export function _createThreadSend(context, options = { requestOptions: {} }) {
|
|
1091
|
+
var _a, _b;
|
|
1092
|
+
const path = expandUrlTemplate("/threads{?api%2Dversion}", {
|
|
1093
|
+
"api%2Dversion": context.apiVersion,
|
|
1094
|
+
}, {
|
|
1095
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1096
|
+
});
|
|
1097
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
1098
|
+
messages: !(options === null || options === void 0 ? void 0 : options.messages)
|
|
1099
|
+
? options === null || options === void 0 ? void 0 : options.messages
|
|
1100
|
+
: threadMessageOptionsArraySerializer(options === null || options === void 0 ? void 0 : options.messages),
|
|
1101
|
+
tool_resources: !(options === null || options === void 0 ? void 0 : options.toolResources)
|
|
1102
|
+
? options === null || options === void 0 ? void 0 : options.toolResources
|
|
1103
|
+
: toolResourcesSerializer(options === null || options === void 0 ? void 0 : options.toolResources),
|
|
1104
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
1105
|
+
} }));
|
|
1106
|
+
}
|
|
1107
|
+
export async function _createThreadDeserialize(result) {
|
|
1108
|
+
const expectedStatuses = ["200"];
|
|
1109
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1110
|
+
throw createRestError(result);
|
|
1111
|
+
}
|
|
1112
|
+
return agentThreadDeserializer(result.body);
|
|
1113
|
+
}
|
|
1114
|
+
/** Creates a new thread. Threads contain messages and can be run by agents. */
|
|
1115
|
+
export async function createThread(context, options = { requestOptions: {} }) {
|
|
1116
|
+
const result = await _createThreadSend(context, options);
|
|
1117
|
+
return _createThreadDeserialize(result);
|
|
1118
|
+
}
|
|
1119
|
+
export function _deleteAgentSend(context, assistantId, options = { requestOptions: {} }) {
|
|
1120
|
+
var _a, _b;
|
|
1121
|
+
const path = expandUrlTemplate("/assistants/{assistantId}{?api%2Dversion}", {
|
|
1122
|
+
assistantId: assistantId,
|
|
1123
|
+
"api%2Dversion": context.apiVersion,
|
|
1124
|
+
}, {
|
|
1125
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1126
|
+
});
|
|
1127
|
+
return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1128
|
+
}
|
|
1129
|
+
export async function _deleteAgentDeserialize(result) {
|
|
1130
|
+
const expectedStatuses = ["200"];
|
|
1131
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1132
|
+
throw createRestError(result);
|
|
1133
|
+
}
|
|
1134
|
+
return agentDeletionStatusDeserializer(result.body);
|
|
1135
|
+
}
|
|
1136
|
+
/** Deletes an agent. */
|
|
1137
|
+
export async function deleteAgent(context, assistantId, options = { requestOptions: {} }) {
|
|
1138
|
+
const result = await _deleteAgentSend(context, assistantId, options);
|
|
1139
|
+
return _deleteAgentDeserialize(result);
|
|
1140
|
+
}
|
|
1141
|
+
export function _updateAgentSend(context, assistantId, options = { requestOptions: {} }) {
|
|
1142
|
+
var _a, _b;
|
|
1143
|
+
const path = expandUrlTemplate("/assistants/{assistantId}{?api%2Dversion}", {
|
|
1144
|
+
assistantId: assistantId,
|
|
1145
|
+
"api%2Dversion": context.apiVersion,
|
|
1146
|
+
}, {
|
|
1147
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1148
|
+
});
|
|
1149
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
1150
|
+
model: options === null || options === void 0 ? void 0 : options.model,
|
|
1151
|
+
name: options === null || options === void 0 ? void 0 : options.name,
|
|
1152
|
+
description: options === null || options === void 0 ? void 0 : options.description,
|
|
1153
|
+
instructions: options === null || options === void 0 ? void 0 : options.instructions,
|
|
1154
|
+
tools: !(options === null || options === void 0 ? void 0 : options.tools) ? options === null || options === void 0 ? void 0 : options.tools : toolDefinitionUnionArraySerializer(options === null || options === void 0 ? void 0 : options.tools),
|
|
1155
|
+
tool_resources: !(options === null || options === void 0 ? void 0 : options.toolResources)
|
|
1156
|
+
? options === null || options === void 0 ? void 0 : options.toolResources
|
|
1157
|
+
: toolResourcesSerializer(options === null || options === void 0 ? void 0 : options.toolResources),
|
|
1158
|
+
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
1159
|
+
top_p: options === null || options === void 0 ? void 0 : options.topP,
|
|
1160
|
+
response_format: !(options === null || options === void 0 ? void 0 : options.responseFormat)
|
|
1161
|
+
? options === null || options === void 0 ? void 0 : options.responseFormat
|
|
1162
|
+
: agentsApiResponseFormatOptionSerializer(options === null || options === void 0 ? void 0 : options.responseFormat),
|
|
1163
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
1164
|
+
} }));
|
|
1165
|
+
}
|
|
1166
|
+
export async function _updateAgentDeserialize(result) {
|
|
1167
|
+
const expectedStatuses = ["200"];
|
|
1168
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1169
|
+
throw createRestError(result);
|
|
1170
|
+
}
|
|
1171
|
+
return agentDeserializer(result.body);
|
|
1172
|
+
}
|
|
1173
|
+
/** Modifies an existing agent. */
|
|
1174
|
+
export async function updateAgent(context, assistantId, options = { requestOptions: {} }) {
|
|
1175
|
+
const result = await _updateAgentSend(context, assistantId, options);
|
|
1176
|
+
return _updateAgentDeserialize(result);
|
|
1177
|
+
}
|
|
1178
|
+
export function _getAgentSend(context, assistantId, options = { requestOptions: {} }) {
|
|
1179
|
+
var _a, _b;
|
|
1180
|
+
const path = expandUrlTemplate("/assistants/{assistantId}{?api%2Dversion}", {
|
|
1181
|
+
assistantId: assistantId,
|
|
1182
|
+
"api%2Dversion": context.apiVersion,
|
|
1183
|
+
}, {
|
|
1184
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1185
|
+
});
|
|
1186
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1187
|
+
}
|
|
1188
|
+
export async function _getAgentDeserialize(result) {
|
|
1189
|
+
const expectedStatuses = ["200"];
|
|
1190
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1191
|
+
throw createRestError(result);
|
|
1192
|
+
}
|
|
1193
|
+
return agentDeserializer(result.body);
|
|
1194
|
+
}
|
|
1195
|
+
/** Retrieves an existing agent. */
|
|
1196
|
+
export async function getAgent(context, assistantId, options = { requestOptions: {} }) {
|
|
1197
|
+
const result = await _getAgentSend(context, assistantId, options);
|
|
1198
|
+
return _getAgentDeserialize(result);
|
|
1199
|
+
}
|
|
1200
|
+
export function _listAgentsSend(context, options = { requestOptions: {} }) {
|
|
1201
|
+
var _a, _b;
|
|
1202
|
+
const path = expandUrlTemplate("/assistants{?api%2Dversion,limit,order,after,before}", {
|
|
1203
|
+
"api%2Dversion": context.apiVersion,
|
|
1204
|
+
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
1205
|
+
order: options === null || options === void 0 ? void 0 : options.order,
|
|
1206
|
+
after: options === null || options === void 0 ? void 0 : options.after,
|
|
1207
|
+
before: options === null || options === void 0 ? void 0 : options.before,
|
|
1208
|
+
}, {
|
|
1209
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1210
|
+
});
|
|
1211
|
+
return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
|
|
1212
|
+
}
|
|
1213
|
+
export async function _listAgentsDeserialize(result) {
|
|
1214
|
+
const expectedStatuses = ["200"];
|
|
1215
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1216
|
+
throw createRestError(result);
|
|
1217
|
+
}
|
|
1218
|
+
return openAIPageableListOfAgentDeserializer(result.body);
|
|
1219
|
+
}
|
|
1220
|
+
/** Gets a list of agents that were previously created. */
|
|
1221
|
+
export async function listAgents(context, options = { requestOptions: {} }) {
|
|
1222
|
+
const result = await _listAgentsSend(context, options);
|
|
1223
|
+
return _listAgentsDeserialize(result);
|
|
1224
|
+
}
|
|
1225
|
+
export function _createAgentSend(context, model, options = { requestOptions: {} }) {
|
|
1226
|
+
var _a, _b;
|
|
1227
|
+
const path = expandUrlTemplate("/assistants{?api%2Dversion}", {
|
|
1228
|
+
"api%2Dversion": context.apiVersion,
|
|
1229
|
+
}, {
|
|
1230
|
+
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
|
|
1231
|
+
});
|
|
1232
|
+
return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: {
|
|
1233
|
+
model: model,
|
|
1234
|
+
name: options === null || options === void 0 ? void 0 : options.name,
|
|
1235
|
+
description: options === null || options === void 0 ? void 0 : options.description,
|
|
1236
|
+
instructions: options === null || options === void 0 ? void 0 : options.instructions,
|
|
1237
|
+
tools: !(options === null || options === void 0 ? void 0 : options.tools) ? options === null || options === void 0 ? void 0 : options.tools : toolDefinitionUnionArraySerializer(options === null || options === void 0 ? void 0 : options.tools),
|
|
1238
|
+
tool_resources: !(options === null || options === void 0 ? void 0 : options.toolResources)
|
|
1239
|
+
? options === null || options === void 0 ? void 0 : options.toolResources
|
|
1240
|
+
: toolResourcesSerializer(options === null || options === void 0 ? void 0 : options.toolResources),
|
|
1241
|
+
temperature: options === null || options === void 0 ? void 0 : options.temperature,
|
|
1242
|
+
top_p: options === null || options === void 0 ? void 0 : options.topP,
|
|
1243
|
+
response_format: !(options === null || options === void 0 ? void 0 : options.responseFormat)
|
|
1244
|
+
? options === null || options === void 0 ? void 0 : options.responseFormat
|
|
1245
|
+
: agentsApiResponseFormatOptionSerializer(options === null || options === void 0 ? void 0 : options.responseFormat),
|
|
1246
|
+
metadata: options === null || options === void 0 ? void 0 : options.metadata,
|
|
1247
|
+
} }));
|
|
1248
|
+
}
|
|
1249
|
+
export async function _createAgentDeserialize(result) {
|
|
1250
|
+
const expectedStatuses = ["200"];
|
|
1251
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1252
|
+
throw createRestError(result);
|
|
1253
|
+
}
|
|
1254
|
+
return agentDeserializer(result.body);
|
|
1255
|
+
}
|
|
1256
|
+
/** Creates a new agent. */
|
|
1257
|
+
export async function createAgent(context, model, options = { requestOptions: {} }) {
|
|
1258
|
+
const result = await _createAgentSend(context, model, options);
|
|
1259
|
+
return _createAgentDeserialize(result);
|
|
1260
|
+
}
|
|
1261
|
+
const handlers = [
|
|
1262
|
+
{ events: Object.values(ThreadStreamEvent) },
|
|
1263
|
+
{ events: Object.values(RunStreamEvent) },
|
|
1264
|
+
{ events: Object.values(RunStepStreamEvent) },
|
|
1265
|
+
{ events: Object.values(MessageStreamEvent) },
|
|
1266
|
+
];
|
|
1267
|
+
function createAgentStream(stream) {
|
|
1268
|
+
const asyncIterator = toAsyncIterable(stream);
|
|
1269
|
+
const asyncDisposable = stream;
|
|
1270
|
+
return Object.assign(asyncIterator, asyncDisposable);
|
|
1271
|
+
}
|
|
1272
|
+
function toAsyncIterable(stream) {
|
|
1273
|
+
return __asyncGenerator(this, arguments, function* toAsyncIterable_1() {
|
|
1274
|
+
var _a, e_1, _b, _c;
|
|
1275
|
+
try {
|
|
1276
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
1277
|
+
_c = stream_1_1.value;
|
|
1278
|
+
_d = false;
|
|
1279
|
+
const event = _c;
|
|
1280
|
+
const data = deserializeEventData(event);
|
|
1281
|
+
yield yield __await({ data: data, event: event.event });
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1285
|
+
finally {
|
|
1286
|
+
try {
|
|
1287
|
+
if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
|
|
1288
|
+
}
|
|
1289
|
+
finally { if (e_1) throw e_1.error; }
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
function deserializeEventData(event) {
|
|
1294
|
+
try {
|
|
1295
|
+
const jsonData = JSON.parse(event.data);
|
|
1296
|
+
switch (event.event) {
|
|
1297
|
+
case MessageStreamEvent.ThreadMessageDelta:
|
|
1298
|
+
return jsonData;
|
|
1299
|
+
case RunStepStreamEvent.ThreadRunStepDelta:
|
|
1300
|
+
return jsonData;
|
|
1301
|
+
default: {
|
|
1302
|
+
for (const { events } of handlers) {
|
|
1303
|
+
if (events.includes(event.event)) {
|
|
1304
|
+
return jsonData;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return jsonData;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
catch (ex) {
|
|
1312
|
+
logger.error(`Failed to parse event data ${event.event} - error: ${ex}`);
|
|
1313
|
+
return event.data;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
async function processStream(streamResponse) {
|
|
1317
|
+
const expectedStatuses = ["200"];
|
|
1318
|
+
const result = isNodeLike
|
|
1319
|
+
? await streamResponse.asNodeStream()
|
|
1320
|
+
: await streamResponse.asBrowserStream();
|
|
1321
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
1322
|
+
throw createRestError(result);
|
|
1323
|
+
}
|
|
1324
|
+
if (!result.body) {
|
|
1325
|
+
throw new Error("No body in response");
|
|
1326
|
+
}
|
|
1327
|
+
const stream = isNodeLike
|
|
1328
|
+
? createSseStream(result.body)
|
|
1329
|
+
: createSseStream(result.body);
|
|
1330
|
+
return createAgentStream(stream);
|
|
1331
|
+
}
|
|
1332
|
+
/** Create a run and stream the events */
|
|
1333
|
+
export async function createRunStreaming(context, assistantId, threadId, options = { requestOptions: {} }) {
|
|
1334
|
+
options.stream = true;
|
|
1335
|
+
return processStream(_createRunSend(context, threadId, assistantId, options));
|
|
1336
|
+
}
|
|
1337
|
+
/** Create a thread and run and stream the events */
|
|
1338
|
+
export async function createThreadAndRunStreaming(context, assistantId, options = { requestOptions: {} }) {
|
|
1339
|
+
options.stream = true;
|
|
1340
|
+
return processStream(_createThreadAndRunSend(context, assistantId, options));
|
|
1341
|
+
}
|
|
1342
|
+
export async function submitToolOutputsToRunStreaming(context, threadId, runId, options = { requestOptions: {} }) {
|
|
1343
|
+
options.stream = true;
|
|
1344
|
+
return processStream(context
|
|
1345
|
+
.path("/threads/{threadId}/runs/{runId}/submit_tool_outputs", threadId, runId)
|
|
1346
|
+
.post(options));
|
|
1347
|
+
}
|
|
1348
|
+
//# sourceMappingURL=operations.js.map
|