@azure/ai-projects 1.0.0-alpha.20250313.1 → 1.0.0-alpha.20250318.2
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/README.md +231 -185
- package/dist/browser/agents/assistants.d.ts.map +1 -1
- package/dist/browser/agents/assistants.js +3 -1
- package/dist/browser/agents/assistants.js.map +1 -1
- package/dist/browser/agents/customModels.d.ts +4 -29
- package/dist/browser/agents/customModels.d.ts.map +1 -1
- package/dist/browser/agents/customModels.js.map +1 -1
- package/dist/browser/agents/files.d.ts +5 -4
- package/dist/browser/agents/files.d.ts.map +1 -1
- package/dist/browser/agents/files.js +55 -27
- package/dist/browser/agents/files.js.map +1 -1
- package/dist/browser/agents/index.d.ts +10 -10
- package/dist/browser/agents/index.d.ts.map +1 -1
- package/dist/browser/agents/index.js.map +1 -1
- package/dist/browser/agents/inputOutputs.d.ts +3 -3
- package/dist/browser/agents/inputOutputs.d.ts.map +1 -1
- package/dist/browser/agents/inputOutputs.js.map +1 -1
- package/dist/browser/agents/inputValidations.d.ts.map +1 -1
- package/dist/browser/agents/inputValidations.js +2 -1
- package/dist/browser/agents/inputValidations.js.map +1 -1
- package/dist/browser/agents/messages.js +2 -2
- package/dist/browser/agents/messages.js.map +1 -1
- package/dist/browser/agents/poller.d.ts +8 -33
- package/dist/browser/agents/poller.d.ts.map +1 -1
- package/dist/browser/agents/poller.js +130 -53
- package/dist/browser/agents/poller.js.map +1 -1
- package/dist/browser/agents/streamingModels.d.ts +17 -15
- package/dist/browser/agents/streamingModels.d.ts.map +1 -1
- package/dist/browser/agents/streamingModels.js.map +1 -1
- package/dist/browser/agents/traceUtility.d.ts +3 -3
- package/dist/browser/agents/traceUtility.d.ts.map +1 -1
- package/dist/browser/agents/traceUtility.js.map +1 -1
- package/dist/browser/agents/utils.d.ts +53 -3
- package/dist/browser/agents/utils.d.ts.map +1 -1
- package/dist/browser/agents/utils.js +71 -1
- package/dist/browser/agents/utils.js.map +1 -1
- package/dist/browser/agents/vectorStores.d.ts +3 -4
- package/dist/browser/agents/vectorStores.d.ts.map +1 -1
- package/dist/browser/agents/vectorStores.js +44 -26
- package/dist/browser/agents/vectorStores.js.map +1 -1
- package/dist/browser/agents/vectorStoresFileBatches.d.ts +5 -4
- package/dist/browser/agents/vectorStoresFileBatches.d.ts.map +1 -1
- package/dist/browser/agents/vectorStoresFileBatches.js +46 -32
- package/dist/browser/agents/vectorStoresFileBatches.js.map +1 -1
- package/dist/browser/agents/vectorStoresFiles.d.ts +4 -4
- package/dist/browser/agents/vectorStoresFiles.d.ts.map +1 -1
- package/dist/browser/agents/vectorStoresFiles.js +57 -28
- package/dist/browser/agents/vectorStoresFiles.js.map +1 -1
- package/dist/browser/customization/convertModelsToWrite.d.ts.map +1 -1
- package/dist/browser/customization/convertModelsToWrite.js +42 -93
- package/dist/browser/customization/convertModelsToWrite.js.map +1 -1
- package/dist/browser/customization/convertOutputModelsFromWire.d.ts.map +1 -1
- package/dist/browser/customization/convertOutputModelsFromWire.js +51 -9
- package/dist/browser/customization/convertOutputModelsFromWire.js.map +1 -1
- package/dist/browser/customization/convertParametersToWire.d.ts +1 -1
- package/dist/browser/customization/convertParametersToWire.d.ts.map +1 -1
- package/dist/browser/customization/convertParametersToWire.js.map +1 -1
- package/dist/browser/customization/models.d.ts +146 -151
- package/dist/browser/customization/models.d.ts.map +1 -1
- package/dist/browser/customization/models.js.map +1 -1
- package/dist/browser/customization/outputModels.d.ts +188 -37
- package/dist/browser/customization/outputModels.d.ts.map +1 -1
- package/dist/browser/customization/outputModels.js.map +1 -1
- package/dist/browser/customization/streamingModels.d.ts +2 -1
- package/dist/browser/customization/streamingModels.d.ts.map +1 -1
- package/dist/browser/customization/streamingModels.js.map +1 -1
- package/dist/browser/customization/streamingWireModels.d.ts +2 -1
- package/dist/browser/customization/streamingWireModels.d.ts.map +1 -1
- package/dist/browser/customization/streamingWireModels.js.map +1 -1
- package/dist/browser/generated/src/models.d.ts +131 -150
- package/dist/browser/generated/src/models.d.ts.map +1 -1
- package/dist/browser/generated/src/models.js.map +1 -1
- package/dist/browser/generated/src/outputModels.d.ts +187 -36
- package/dist/browser/generated/src/outputModels.d.ts.map +1 -1
- package/dist/browser/generated/src/outputModels.js.map +1 -1
- package/dist/browser/generated/src/paginateHelper.d.ts +27 -2
- package/dist/browser/generated/src/paginateHelper.d.ts.map +1 -1
- package/dist/browser/generated/src/paginateHelper.js +98 -1
- package/dist/browser/generated/src/paginateHelper.js.map +1 -1
- package/dist/browser/generated/src/projectsClient.d.ts +2 -2
- package/dist/browser/generated/src/projectsClient.d.ts.map +1 -1
- package/dist/browser/generated/src/projectsClient.js +2 -2
- package/dist/browser/generated/src/projectsClient.js.map +1 -1
- package/dist/commonjs/agents/assistants.d.ts.map +1 -1
- package/dist/commonjs/agents/assistants.js +3 -1
- package/dist/commonjs/agents/assistants.js.map +1 -1
- package/dist/commonjs/agents/customModels.d.ts +4 -29
- package/dist/commonjs/agents/customModels.d.ts.map +1 -1
- package/dist/commonjs/agents/customModels.js.map +1 -1
- package/dist/commonjs/agents/files.d.ts +5 -4
- package/dist/commonjs/agents/files.d.ts.map +1 -1
- package/dist/commonjs/agents/files.js +55 -26
- package/dist/commonjs/agents/files.js.map +1 -1
- package/dist/commonjs/agents/index.d.ts +10 -10
- package/dist/commonjs/agents/index.d.ts.map +1 -1
- package/dist/commonjs/agents/index.js.map +1 -1
- package/dist/commonjs/agents/inputOutputs.d.ts +3 -3
- package/dist/commonjs/agents/inputOutputs.d.ts.map +1 -1
- package/dist/commonjs/agents/inputOutputs.js.map +1 -1
- package/dist/commonjs/agents/inputValidations.d.ts.map +1 -1
- package/dist/commonjs/agents/inputValidations.js +2 -1
- package/dist/commonjs/agents/inputValidations.js.map +1 -1
- package/dist/commonjs/agents/messages.js +2 -2
- package/dist/commonjs/agents/messages.js.map +1 -1
- package/dist/commonjs/agents/poller.d.ts +8 -33
- package/dist/commonjs/agents/poller.d.ts.map +1 -1
- package/dist/commonjs/agents/poller.js +131 -55
- package/dist/commonjs/agents/poller.js.map +1 -1
- package/dist/commonjs/agents/streamingModels.d.ts +17 -15
- package/dist/commonjs/agents/streamingModels.d.ts.map +1 -1
- package/dist/commonjs/agents/streamingModels.js.map +1 -1
- package/dist/commonjs/agents/traceUtility.d.ts +3 -3
- package/dist/commonjs/agents/traceUtility.d.ts.map +1 -1
- package/dist/commonjs/agents/traceUtility.js.map +1 -1
- package/dist/commonjs/agents/utils.d.ts +53 -3
- package/dist/commonjs/agents/utils.d.ts.map +1 -1
- package/dist/commonjs/agents/utils.js +71 -1
- package/dist/commonjs/agents/utils.js.map +1 -1
- package/dist/commonjs/agents/vectorStores.d.ts +3 -4
- package/dist/commonjs/agents/vectorStores.d.ts.map +1 -1
- package/dist/commonjs/agents/vectorStores.js +43 -25
- package/dist/commonjs/agents/vectorStores.js.map +1 -1
- package/dist/commonjs/agents/vectorStoresFileBatches.d.ts +5 -4
- package/dist/commonjs/agents/vectorStoresFileBatches.d.ts.map +1 -1
- package/dist/commonjs/agents/vectorStoresFileBatches.js +46 -31
- package/dist/commonjs/agents/vectorStoresFileBatches.js.map +1 -1
- package/dist/commonjs/agents/vectorStoresFiles.d.ts +4 -4
- package/dist/commonjs/agents/vectorStoresFiles.d.ts.map +1 -1
- package/dist/commonjs/agents/vectorStoresFiles.js +56 -27
- package/dist/commonjs/agents/vectorStoresFiles.js.map +1 -1
- package/dist/commonjs/customization/convertModelsToWrite.d.ts.map +1 -1
- package/dist/commonjs/customization/convertModelsToWrite.js +42 -93
- package/dist/commonjs/customization/convertModelsToWrite.js.map +1 -1
- package/dist/commonjs/customization/convertOutputModelsFromWire.d.ts.map +1 -1
- package/dist/commonjs/customization/convertOutputModelsFromWire.js +51 -9
- package/dist/commonjs/customization/convertOutputModelsFromWire.js.map +1 -1
- package/dist/commonjs/customization/convertParametersToWire.d.ts +1 -1
- package/dist/commonjs/customization/convertParametersToWire.d.ts.map +1 -1
- package/dist/commonjs/customization/convertParametersToWire.js.map +1 -1
- package/dist/commonjs/customization/models.d.ts +146 -151
- package/dist/commonjs/customization/models.d.ts.map +1 -1
- package/dist/commonjs/customization/models.js.map +1 -1
- package/dist/commonjs/customization/outputModels.d.ts +188 -37
- package/dist/commonjs/customization/outputModels.d.ts.map +1 -1
- package/dist/commonjs/customization/outputModels.js.map +1 -1
- package/dist/commonjs/customization/streamingModels.d.ts +2 -1
- package/dist/commonjs/customization/streamingModels.d.ts.map +1 -1
- package/dist/commonjs/customization/streamingModels.js.map +1 -1
- package/dist/commonjs/customization/streamingWireModels.d.ts +2 -1
- package/dist/commonjs/customization/streamingWireModels.d.ts.map +1 -1
- package/dist/commonjs/customization/streamingWireModels.js.map +1 -1
- package/dist/commonjs/generated/src/models.d.ts +131 -150
- package/dist/commonjs/generated/src/models.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models.js.map +1 -1
- package/dist/commonjs/generated/src/outputModels.d.ts +187 -36
- package/dist/commonjs/generated/src/outputModels.d.ts.map +1 -1
- package/dist/commonjs/generated/src/outputModels.js.map +1 -1
- package/dist/commonjs/generated/src/paginateHelper.d.ts +27 -2
- package/dist/commonjs/generated/src/paginateHelper.d.ts.map +1 -1
- package/dist/commonjs/generated/src/paginateHelper.js +99 -2
- package/dist/commonjs/generated/src/paginateHelper.js.map +1 -1
- package/dist/commonjs/generated/src/projectsClient.d.ts +2 -2
- package/dist/commonjs/generated/src/projectsClient.d.ts.map +1 -1
- package/dist/commonjs/generated/src/projectsClient.js +2 -2
- package/dist/commonjs/generated/src/projectsClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/agents/assistants.d.ts.map +1 -1
- package/dist/esm/agents/assistants.js +3 -1
- package/dist/esm/agents/assistants.js.map +1 -1
- package/dist/esm/agents/customModels.d.ts +4 -29
- package/dist/esm/agents/customModels.d.ts.map +1 -1
- package/dist/esm/agents/customModels.js.map +1 -1
- package/dist/esm/agents/files.d.ts +5 -4
- package/dist/esm/agents/files.d.ts.map +1 -1
- package/dist/esm/agents/files.js +55 -27
- package/dist/esm/agents/files.js.map +1 -1
- package/dist/esm/agents/index.d.ts +10 -10
- package/dist/esm/agents/index.d.ts.map +1 -1
- package/dist/esm/agents/index.js.map +1 -1
- package/dist/esm/agents/inputOutputs.d.ts +3 -3
- package/dist/esm/agents/inputOutputs.d.ts.map +1 -1
- package/dist/esm/agents/inputOutputs.js.map +1 -1
- package/dist/esm/agents/inputValidations.d.ts.map +1 -1
- package/dist/esm/agents/inputValidations.js +2 -1
- package/dist/esm/agents/inputValidations.js.map +1 -1
- package/dist/esm/agents/messages.js +2 -2
- package/dist/esm/agents/messages.js.map +1 -1
- package/dist/esm/agents/poller.d.ts +8 -33
- package/dist/esm/agents/poller.d.ts.map +1 -1
- package/dist/esm/agents/poller.js +130 -53
- package/dist/esm/agents/poller.js.map +1 -1
- package/dist/esm/agents/streamingModels.d.ts +17 -15
- package/dist/esm/agents/streamingModels.d.ts.map +1 -1
- package/dist/esm/agents/streamingModels.js.map +1 -1
- package/dist/esm/agents/traceUtility.d.ts +3 -3
- package/dist/esm/agents/traceUtility.d.ts.map +1 -1
- package/dist/esm/agents/traceUtility.js.map +1 -1
- package/dist/esm/agents/utils.d.ts +53 -3
- package/dist/esm/agents/utils.d.ts.map +1 -1
- package/dist/esm/agents/utils.js +71 -1
- package/dist/esm/agents/utils.js.map +1 -1
- package/dist/esm/agents/vectorStores.d.ts +3 -4
- package/dist/esm/agents/vectorStores.d.ts.map +1 -1
- package/dist/esm/agents/vectorStores.js +44 -26
- package/dist/esm/agents/vectorStores.js.map +1 -1
- package/dist/esm/agents/vectorStoresFileBatches.d.ts +5 -4
- package/dist/esm/agents/vectorStoresFileBatches.d.ts.map +1 -1
- package/dist/esm/agents/vectorStoresFileBatches.js +46 -32
- package/dist/esm/agents/vectorStoresFileBatches.js.map +1 -1
- package/dist/esm/agents/vectorStoresFiles.d.ts +4 -4
- package/dist/esm/agents/vectorStoresFiles.d.ts.map +1 -1
- package/dist/esm/agents/vectorStoresFiles.js +57 -28
- package/dist/esm/agents/vectorStoresFiles.js.map +1 -1
- package/dist/esm/customization/convertModelsToWrite.d.ts.map +1 -1
- package/dist/esm/customization/convertModelsToWrite.js +42 -93
- package/dist/esm/customization/convertModelsToWrite.js.map +1 -1
- package/dist/esm/customization/convertOutputModelsFromWire.d.ts.map +1 -1
- package/dist/esm/customization/convertOutputModelsFromWire.js +51 -9
- package/dist/esm/customization/convertOutputModelsFromWire.js.map +1 -1
- package/dist/esm/customization/convertParametersToWire.d.ts +1 -1
- package/dist/esm/customization/convertParametersToWire.d.ts.map +1 -1
- package/dist/esm/customization/convertParametersToWire.js.map +1 -1
- package/dist/esm/customization/models.d.ts +146 -151
- package/dist/esm/customization/models.d.ts.map +1 -1
- package/dist/esm/customization/models.js.map +1 -1
- package/dist/esm/customization/outputModels.d.ts +188 -37
- package/dist/esm/customization/outputModels.d.ts.map +1 -1
- package/dist/esm/customization/outputModels.js.map +1 -1
- package/dist/esm/customization/streamingModels.d.ts +2 -1
- package/dist/esm/customization/streamingModels.d.ts.map +1 -1
- package/dist/esm/customization/streamingModels.js.map +1 -1
- package/dist/esm/customization/streamingWireModels.d.ts +2 -1
- package/dist/esm/customization/streamingWireModels.d.ts.map +1 -1
- package/dist/esm/customization/streamingWireModels.js.map +1 -1
- package/dist/esm/generated/src/models.d.ts +131 -150
- package/dist/esm/generated/src/models.d.ts.map +1 -1
- package/dist/esm/generated/src/models.js.map +1 -1
- package/dist/esm/generated/src/outputModels.d.ts +187 -36
- package/dist/esm/generated/src/outputModels.d.ts.map +1 -1
- package/dist/esm/generated/src/outputModels.js.map +1 -1
- package/dist/esm/generated/src/paginateHelper.d.ts +27 -2
- package/dist/esm/generated/src/paginateHelper.d.ts.map +1 -1
- package/dist/esm/generated/src/paginateHelper.js +98 -1
- package/dist/esm/generated/src/paginateHelper.js.map +1 -1
- package/dist/esm/generated/src/projectsClient.d.ts +2 -2
- package/dist/esm/generated/src/projectsClient.d.ts.map +1 -1
- package/dist/esm/generated/src/projectsClient.js +2 -2
- package/dist/esm/generated/src/projectsClient.js.map +1 -1
- package/dist/react-native/agents/assistants.d.ts.map +1 -1
- package/dist/react-native/agents/assistants.js +3 -1
- package/dist/react-native/agents/assistants.js.map +1 -1
- package/dist/react-native/agents/customModels.d.ts +4 -29
- package/dist/react-native/agents/customModels.d.ts.map +1 -1
- package/dist/react-native/agents/customModels.js.map +1 -1
- package/dist/react-native/agents/files.d.ts +5 -4
- package/dist/react-native/agents/files.d.ts.map +1 -1
- package/dist/react-native/agents/files.js +55 -27
- package/dist/react-native/agents/files.js.map +1 -1
- package/dist/react-native/agents/index.d.ts +10 -10
- package/dist/react-native/agents/index.d.ts.map +1 -1
- package/dist/react-native/agents/index.js.map +1 -1
- package/dist/react-native/agents/inputOutputs.d.ts +3 -3
- package/dist/react-native/agents/inputOutputs.d.ts.map +1 -1
- package/dist/react-native/agents/inputOutputs.js.map +1 -1
- package/dist/react-native/agents/inputValidations.d.ts.map +1 -1
- package/dist/react-native/agents/inputValidations.js +2 -1
- package/dist/react-native/agents/inputValidations.js.map +1 -1
- package/dist/react-native/agents/messages.js +2 -2
- package/dist/react-native/agents/messages.js.map +1 -1
- package/dist/react-native/agents/poller.d.ts +8 -33
- package/dist/react-native/agents/poller.d.ts.map +1 -1
- package/dist/react-native/agents/poller.js +130 -53
- package/dist/react-native/agents/poller.js.map +1 -1
- package/dist/react-native/agents/streamingModels.d.ts +17 -15
- package/dist/react-native/agents/streamingModels.d.ts.map +1 -1
- package/dist/react-native/agents/streamingModels.js.map +1 -1
- package/dist/react-native/agents/traceUtility.d.ts +3 -3
- package/dist/react-native/agents/traceUtility.d.ts.map +1 -1
- package/dist/react-native/agents/traceUtility.js.map +1 -1
- package/dist/react-native/agents/utils.d.ts +53 -3
- package/dist/react-native/agents/utils.d.ts.map +1 -1
- package/dist/react-native/agents/utils.js +71 -1
- package/dist/react-native/agents/utils.js.map +1 -1
- package/dist/react-native/agents/vectorStores.d.ts +3 -4
- package/dist/react-native/agents/vectorStores.d.ts.map +1 -1
- package/dist/react-native/agents/vectorStores.js +44 -26
- package/dist/react-native/agents/vectorStores.js.map +1 -1
- package/dist/react-native/agents/vectorStoresFileBatches.d.ts +5 -4
- package/dist/react-native/agents/vectorStoresFileBatches.d.ts.map +1 -1
- package/dist/react-native/agents/vectorStoresFileBatches.js +46 -32
- package/dist/react-native/agents/vectorStoresFileBatches.js.map +1 -1
- package/dist/react-native/agents/vectorStoresFiles.d.ts +4 -4
- package/dist/react-native/agents/vectorStoresFiles.d.ts.map +1 -1
- package/dist/react-native/agents/vectorStoresFiles.js +57 -28
- package/dist/react-native/agents/vectorStoresFiles.js.map +1 -1
- package/dist/react-native/customization/convertModelsToWrite.d.ts.map +1 -1
- package/dist/react-native/customization/convertModelsToWrite.js +42 -93
- package/dist/react-native/customization/convertModelsToWrite.js.map +1 -1
- package/dist/react-native/customization/convertOutputModelsFromWire.d.ts.map +1 -1
- package/dist/react-native/customization/convertOutputModelsFromWire.js +51 -9
- package/dist/react-native/customization/convertOutputModelsFromWire.js.map +1 -1
- package/dist/react-native/customization/convertParametersToWire.d.ts +1 -1
- package/dist/react-native/customization/convertParametersToWire.d.ts.map +1 -1
- package/dist/react-native/customization/convertParametersToWire.js.map +1 -1
- package/dist/react-native/customization/models.d.ts +146 -151
- package/dist/react-native/customization/models.d.ts.map +1 -1
- package/dist/react-native/customization/models.js.map +1 -1
- package/dist/react-native/customization/outputModels.d.ts +188 -37
- package/dist/react-native/customization/outputModels.d.ts.map +1 -1
- package/dist/react-native/customization/outputModels.js.map +1 -1
- package/dist/react-native/customization/streamingModels.d.ts +2 -1
- package/dist/react-native/customization/streamingModels.d.ts.map +1 -1
- package/dist/react-native/customization/streamingModels.js.map +1 -1
- package/dist/react-native/customization/streamingWireModels.d.ts +2 -1
- package/dist/react-native/customization/streamingWireModels.d.ts.map +1 -1
- package/dist/react-native/customization/streamingWireModels.js.map +1 -1
- package/dist/react-native/generated/src/models.d.ts +131 -150
- package/dist/react-native/generated/src/models.d.ts.map +1 -1
- package/dist/react-native/generated/src/models.js.map +1 -1
- package/dist/react-native/generated/src/outputModels.d.ts +187 -36
- package/dist/react-native/generated/src/outputModels.d.ts.map +1 -1
- package/dist/react-native/generated/src/outputModels.js.map +1 -1
- package/dist/react-native/generated/src/paginateHelper.d.ts +27 -2
- package/dist/react-native/generated/src/paginateHelper.d.ts.map +1 -1
- package/dist/react-native/generated/src/paginateHelper.js +98 -1
- package/dist/react-native/generated/src/paginateHelper.js.map +1 -1
- package/dist/react-native/generated/src/projectsClient.d.ts +2 -2
- package/dist/react-native/generated/src/projectsClient.d.ts.map +1 -1
- package/dist/react-native/generated/src/projectsClient.js +2 -2
- package/dist/react-native/generated/src/projectsClient.js.map +1 -1
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@ Use the AI Projects client library (in preview) to:
|
|
|
9
9
|
|
|
10
10
|
[Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
| [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples)
|
|
13
|
+
| [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects)
|
|
14
|
+
| [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-preview)
|
|
15
15
|
|
|
16
16
|
## Table of contents
|
|
17
17
|
|
|
@@ -49,7 +49,7 @@ Use the AI Projects client library (in preview) to:
|
|
|
49
49
|
- [Troubleshooting](#troubleshooting)
|
|
50
50
|
- [Exceptions](#exceptions)
|
|
51
51
|
- [Reporting issues](#reporting-issues)
|
|
52
|
-
|
|
52
|
+
- [Next steps](#next-steps)
|
|
53
53
|
- [Contributing](#contributing)
|
|
54
54
|
|
|
55
55
|
## Getting started
|
|
@@ -78,14 +78,11 @@ npm install @azure/ai-projects @azure/identity
|
|
|
78
78
|
|
|
79
79
|
The class factory method `fromConnectionString` is used to construct the client. To construct a client:
|
|
80
80
|
|
|
81
|
-
```
|
|
81
|
+
```ts snippet:setup
|
|
82
82
|
import { AIProjectsClient } from "@azure/ai-projects";
|
|
83
83
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || "<connectionString>";
|
|
88
|
-
|
|
85
|
+
const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING ?? "<connectionString>";
|
|
89
86
|
const client = AIProjectsClient.fromConnectionString(
|
|
90
87
|
connectionString,
|
|
91
88
|
new DefaultAzureCredential(),
|
|
@@ -98,13 +95,13 @@ const client = AIProjectsClient.fromConnectionString(
|
|
|
98
95
|
|
|
99
96
|
Your Azure AI Foundry project has a "Management center". When you enter it, you will see a tab named "Connected resources" under your project. The `.connections` operations on the client allow you to enumerate the connections and get connection properties. Connection properties include the resource URL and authentication credentials, among other things.
|
|
100
97
|
|
|
101
|
-
Below are code examples of the connection operations. Full samples can be found under the "connections" folder in the [package samples]
|
|
98
|
+
Below are code examples of the connection operations. Full samples can be found under the "connections" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples).
|
|
102
99
|
|
|
103
100
|
#### Get properties of all connections
|
|
104
101
|
|
|
105
102
|
To list the properties of all the connections in the Azure AI Foundry project:
|
|
106
103
|
|
|
107
|
-
```
|
|
104
|
+
```ts snippet:listConnections
|
|
108
105
|
const connections = await client.connections.listConnections();
|
|
109
106
|
for (const connection of connections) {
|
|
110
107
|
console.log(connection);
|
|
@@ -115,7 +112,7 @@ for (const connection of connections) {
|
|
|
115
112
|
|
|
116
113
|
To list the properties of connections of a certain type (here Azure OpenAI):
|
|
117
114
|
|
|
118
|
-
```
|
|
115
|
+
```ts snippet:filterConnections
|
|
119
116
|
const connections = await client.connections.listConnections({ category: "AzureOpenAI" });
|
|
120
117
|
for (const connection of connections) {
|
|
121
118
|
console.log(connection);
|
|
@@ -126,21 +123,21 @@ for (const connection of connections) {
|
|
|
126
123
|
|
|
127
124
|
To get the connection properties of a connection named `connectionName`:
|
|
128
125
|
|
|
129
|
-
```
|
|
126
|
+
```ts snippet:getConnection
|
|
130
127
|
const connection = await client.connections.getConnection("connectionName");
|
|
131
128
|
console.log(connection);
|
|
132
129
|
```
|
|
133
130
|
|
|
134
131
|
To get the connection properties with its authentication credentials:
|
|
135
132
|
|
|
136
|
-
```
|
|
133
|
+
```ts snippet:getConnectionWithSecrets
|
|
137
134
|
const connection = await client.connections.getConnectionWithSecrets("connectionName");
|
|
138
135
|
console.log(connection);
|
|
139
136
|
```
|
|
140
137
|
|
|
141
138
|
### Agents (Preview)
|
|
142
139
|
|
|
143
|
-
Agents in the Azure AI Projects client library are designed to facilitate various interactions and operations within your AI projects. They serve as the core components that manage and execute tasks, leveraging different tools and resources to achieve specific goals. The following steps outline the typical sequence for interacting with Agents. See the "agents" folder in the [package samples]
|
|
140
|
+
Agents in the Azure AI Projects client library are designed to facilitate various interactions and operations within your AI projects. They serve as the core components that manage and execute tasks, leveraging different tools and resources to achieve specific goals. The following steps outline the typical sequence for interacting with Agents. See the "agents" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) for additional Agent samples.
|
|
144
141
|
|
|
145
142
|
Agents are actively being developed. A sign-up form for private preview is coming soon.
|
|
146
143
|
|
|
@@ -148,7 +145,7 @@ Agents are actively being developed. A sign-up form for private preview is comin
|
|
|
148
145
|
|
|
149
146
|
Here is an example of how to create an Agent:
|
|
150
147
|
|
|
151
|
-
```
|
|
148
|
+
```ts snippet:createAgent
|
|
152
149
|
const agent = await client.agents.createAgent("gpt-4o", {
|
|
153
150
|
name: "my-agent",
|
|
154
151
|
instructions: "You are a helpful assistant",
|
|
@@ -159,12 +156,12 @@ To allow Agents to access your resources or custom functions, you need tools. Yo
|
|
|
159
156
|
|
|
160
157
|
You can use `ToolSet` to do this:
|
|
161
158
|
|
|
162
|
-
```
|
|
159
|
+
```ts snippet:toolSet
|
|
160
|
+
import { ToolSet } from "@azure/ai-projects";
|
|
161
|
+
|
|
163
162
|
const toolSet = new ToolSet();
|
|
164
163
|
toolSet.addFileSearchTool([vectorStore.id]);
|
|
165
164
|
toolSet.addCodeInterpreterTool([codeInterpreterFile.id]);
|
|
166
|
-
|
|
167
|
-
// Create agent with tool set
|
|
168
165
|
const agent = await client.agents.createAgent("gpt-4o", {
|
|
169
166
|
name: "my-agent",
|
|
170
167
|
instructions: "You are a helpful agent",
|
|
@@ -178,21 +175,20 @@ console.log(`Created agent, agent ID: ${agent.id}`);
|
|
|
178
175
|
|
|
179
176
|
To perform file search by an Agent, we first need to upload a file, create a vector store, and associate the file to the vector store. Here is an example:
|
|
180
177
|
|
|
181
|
-
```
|
|
182
|
-
|
|
178
|
+
```ts snippet:fileSearch
|
|
179
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
180
|
+
|
|
181
|
+
const localFileStream = fs.createReadStream(filePath);
|
|
183
182
|
const file = await client.agents.uploadFile(localFileStream, "assistants", {
|
|
184
183
|
fileName: "sample_file_for_upload.txt",
|
|
185
184
|
});
|
|
186
185
|
console.log(`Uploaded file, ID: ${file.id}`);
|
|
187
|
-
|
|
188
186
|
const vectorStore = await client.agents.createVectorStore({
|
|
189
187
|
fileIds: [file.id],
|
|
190
188
|
name: "my_vector_store",
|
|
191
189
|
});
|
|
192
190
|
console.log(`Created vector store, ID: ${vectorStore.id}`);
|
|
193
|
-
|
|
194
191
|
const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]);
|
|
195
|
-
|
|
196
192
|
const agent = await client.agents.createAgent("gpt-4o", {
|
|
197
193
|
name: "SDK Test Agent - Retrieval",
|
|
198
194
|
instructions: "You are helpful agent that can help fetch data from files you know about.",
|
|
@@ -206,15 +202,15 @@ console.log(`Created agent, agent ID : ${agent.id}`);
|
|
|
206
202
|
|
|
207
203
|
Here is an example to upload a file and use it for code interpreter by an Agent:
|
|
208
204
|
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
const fFile = await client.agents.uploadFile(fileStream, "assistants", {
|
|
212
|
-
fileName: "nifty_500_quarterly_results.csv",
|
|
213
|
-
});
|
|
214
|
-
console.log(`Uploaded local file, file ID : ${file.id}`);
|
|
215
|
-
|
|
216
|
-
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([file.id]);
|
|
205
|
+
```ts snippet:codeInterpreter
|
|
206
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
217
207
|
|
|
208
|
+
const localFileStream = fs.createReadStream(filePath);
|
|
209
|
+
const localFile = await client.agents.uploadFile(localFileStream, "assistants", {
|
|
210
|
+
fileName: "localFile",
|
|
211
|
+
});
|
|
212
|
+
console.log(`Uploaded local file, file ID : ${localFile.id}`);
|
|
213
|
+
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]);
|
|
218
214
|
// Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment
|
|
219
215
|
const agent = await client.agents.createAgent("gpt-4o-mini", {
|
|
220
216
|
name: "my-agent",
|
|
@@ -231,13 +227,15 @@ To enable your Agent to perform search through Bing search API, you use `ToolUti
|
|
|
231
227
|
|
|
232
228
|
Here is an example:
|
|
233
229
|
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [
|
|
237
|
-
bingGroundingConnectionId,
|
|
238
|
-
]);
|
|
230
|
+
```ts snippet:bingGrounding
|
|
231
|
+
import { ToolUtility, connectionToolType } from "@azure/ai-projects";
|
|
239
232
|
|
|
240
|
-
const
|
|
233
|
+
const bingConnection = await client.connections.getConnection(
|
|
234
|
+
process.env.BING_CONNECTION_NAME ?? "<connection-name>",
|
|
235
|
+
);
|
|
236
|
+
const connectionId = bingConnection.id;
|
|
237
|
+
const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [connectionId]);
|
|
238
|
+
const agent = await client.agents.createAgent("gpt-4o", {
|
|
241
239
|
name: "my-agent",
|
|
242
240
|
instructions: "You are a helpful agent",
|
|
243
241
|
tools: [bingTool.definition],
|
|
@@ -251,17 +249,13 @@ Azure AI Search is an enterprise search system for high-performance applications
|
|
|
251
249
|
|
|
252
250
|
Here is an example to integrate Azure AI Search:
|
|
253
251
|
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
const cognitiveServicesConnection = await client.connections.getConnection(
|
|
257
|
-
cognitiveServicesConnectionName,
|
|
258
|
-
);
|
|
259
|
-
const azureAISearchTool = ToolUtility.createAzureAISearchTool(
|
|
260
|
-
cognitiveServicesConnection.id,
|
|
261
|
-
cognitiveServicesConnection.name,
|
|
262
|
-
);
|
|
252
|
+
```ts snippet:AISearch
|
|
253
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
263
254
|
|
|
264
|
-
|
|
255
|
+
const connectionName =
|
|
256
|
+
process.env.AZURE_AI_SEARCH_CONNECTION_NAME ?? "<AzureAISearchConnectionName>";
|
|
257
|
+
const connection = await client.connections.getConnection(connectionName);
|
|
258
|
+
const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, connection.name);
|
|
265
259
|
const agent = await client.agents.createAgent("gpt-4-0125-preview", {
|
|
266
260
|
name: "my-agent",
|
|
267
261
|
instructions: "You are a helpful agent",
|
|
@@ -277,48 +271,71 @@ You can enhance your Agents by defining callback functions as function tools. Th
|
|
|
277
271
|
|
|
278
272
|
Here is an example:
|
|
279
273
|
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
|
|
274
|
+
```ts snippet:functionTools
|
|
275
|
+
import {
|
|
276
|
+
FunctionToolDefinition,
|
|
277
|
+
ToolUtility,
|
|
278
|
+
RequiredToolCallOutput,
|
|
279
|
+
FunctionToolDefinitionOutput,
|
|
280
|
+
ToolOutput,
|
|
281
|
+
} from "@azure/ai-projects";
|
|
283
282
|
|
|
283
|
+
class FunctionToolExecutor {
|
|
284
|
+
private functionTools: {
|
|
285
|
+
func: Function;
|
|
286
|
+
definition: FunctionToolDefinition;
|
|
287
|
+
}[];
|
|
284
288
|
constructor() {
|
|
285
|
-
this.functionTools = [
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
289
|
+
this.functionTools = [
|
|
290
|
+
{
|
|
291
|
+
func: this.getUserFavoriteCity,
|
|
292
|
+
...ToolUtility.createFunctionTool({
|
|
293
|
+
name: "getUserFavoriteCity",
|
|
294
|
+
description: "Gets the user's favorite city.",
|
|
295
|
+
parameters: {},
|
|
296
|
+
}),
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
func: this.getCityNickname,
|
|
300
|
+
...ToolUtility.createFunctionTool({
|
|
301
|
+
name: "getCityNickname",
|
|
302
|
+
description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.",
|
|
303
|
+
parameters: {
|
|
304
|
+
type: "object",
|
|
305
|
+
properties: {
|
|
306
|
+
location: { type: "string", description: "The city and state, e.g. Seattle, Wa" },
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
}),
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
func: this.getWeather,
|
|
313
|
+
...ToolUtility.createFunctionTool({
|
|
314
|
+
name: "getWeather",
|
|
315
|
+
description: "Gets the weather for a location.",
|
|
316
|
+
parameters: {
|
|
317
|
+
type: "object",
|
|
318
|
+
properties: {
|
|
319
|
+
location: { type: "string", description: "The city and state, e.g. Seattle, Wa" },
|
|
320
|
+
unit: { type: "string", enum: ["c", "f"] },
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
}),
|
|
324
|
+
},
|
|
325
|
+
];
|
|
307
326
|
}
|
|
308
|
-
|
|
309
327
|
private getUserFavoriteCity(): {} {
|
|
310
|
-
return {
|
|
328
|
+
return { location: "Seattle, WA" };
|
|
311
329
|
}
|
|
312
|
-
|
|
313
330
|
private getCityNickname(location: string): {} {
|
|
314
|
-
return {
|
|
331
|
+
return { nickname: "The Emerald City" };
|
|
315
332
|
}
|
|
316
|
-
|
|
317
333
|
private getWeather(location: string, unit: string): {} {
|
|
318
|
-
return {
|
|
334
|
+
return { weather: unit === "f" ? "72f" : "22c" };
|
|
319
335
|
}
|
|
320
|
-
|
|
321
|
-
|
|
336
|
+
public invokeTool(
|
|
337
|
+
toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput,
|
|
338
|
+
): ToolOutput | undefined {
|
|
322
339
|
console.log(`Function tool call - ${toolCall.function.name}`);
|
|
323
340
|
const args = [];
|
|
324
341
|
if (toolCall.function.parameters) {
|
|
@@ -334,26 +351,30 @@ class FunctionToolExecutor {
|
|
|
334
351
|
return undefined;
|
|
335
352
|
}
|
|
336
353
|
}
|
|
337
|
-
const result = this.functionTools
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
354
|
+
const result = this.functionTools
|
|
355
|
+
.find((tool) => tool.definition.function.name === toolCall.function.name)
|
|
356
|
+
?.func(...args);
|
|
357
|
+
return result
|
|
358
|
+
? {
|
|
359
|
+
toolCallId: toolCall.id,
|
|
360
|
+
output: JSON.stringify(result),
|
|
361
|
+
}
|
|
362
|
+
: undefined;
|
|
342
363
|
}
|
|
343
|
-
|
|
344
364
|
public getFunctionDefinitions(): FunctionToolDefinition[] {
|
|
345
|
-
return this.functionTools.map(tool => {
|
|
365
|
+
return this.functionTools.map((tool) => {
|
|
366
|
+
return tool.definition;
|
|
367
|
+
});
|
|
346
368
|
}
|
|
347
369
|
}
|
|
348
|
-
|
|
349
370
|
const functionToolExecutor = new FunctionToolExecutor();
|
|
350
371
|
const functionTools = functionToolExecutor.getFunctionDefinitions();
|
|
351
|
-
const agent = await client.agents.createAgent("gpt-4o",
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
372
|
+
const agent = await client.agents.createAgent("gpt-4o", {
|
|
373
|
+
name: "my-agent",
|
|
374
|
+
instructions:
|
|
375
|
+
"You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.",
|
|
376
|
+
tools: functionTools,
|
|
377
|
+
});
|
|
357
378
|
console.log(`Created agent, agent ID: ${agent.id}`);
|
|
358
379
|
```
|
|
359
380
|
|
|
@@ -361,7 +382,7 @@ console.log(`Created agent, agent ID: ${agent.id}`);
|
|
|
361
382
|
|
|
362
383
|
For each session or conversation, a thread is required. Here is an example:
|
|
363
384
|
|
|
364
|
-
```
|
|
385
|
+
```ts snippet:createThread
|
|
365
386
|
const thread = await client.agents.createThread();
|
|
366
387
|
```
|
|
367
388
|
|
|
@@ -369,28 +390,25 @@ const thread = await client.agents.createThread();
|
|
|
369
390
|
|
|
370
391
|
In some scenarios, you might need to assign specific resources to individual threads. To achieve this, you provide the `toolResources` argument to `createThread`. In the following example, you create a vector store and upload a file, enable an Agent for file search using the `tools` argument, and then associate the file with the thread using the `toolResources` argument.
|
|
371
392
|
|
|
372
|
-
```
|
|
373
|
-
|
|
393
|
+
```ts snippet:threadWithTool
|
|
394
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
395
|
+
|
|
396
|
+
const localFileStream = fs.createReadStream(filePath);
|
|
374
397
|
const file = await client.agents.uploadFile(localFileStream, "assistants", {
|
|
375
|
-
fileName: "sample_file_for_upload.
|
|
398
|
+
fileName: "sample_file_for_upload.csv",
|
|
376
399
|
});
|
|
377
400
|
console.log(`Uploaded file, ID: ${file.id}`);
|
|
378
|
-
|
|
379
401
|
const vectorStore = await client.agents.createVectorStore({
|
|
380
402
|
fileIds: [file.id],
|
|
381
|
-
name: "my_vector_store",
|
|
382
403
|
});
|
|
383
404
|
console.log(`Created vector store, ID: ${vectorStore.id}`);
|
|
384
|
-
|
|
385
405
|
const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]);
|
|
386
|
-
|
|
387
406
|
const agent = await client.agents.createAgent("gpt-4o", {
|
|
388
|
-
name: "
|
|
407
|
+
name: "myAgent",
|
|
389
408
|
instructions: "You are helpful agent that can help fetch data from files you know about.",
|
|
390
409
|
tools: [fileSearchTool.definition],
|
|
391
410
|
});
|
|
392
411
|
console.log(`Created agent, agent ID : ${agent.id}`);
|
|
393
|
-
|
|
394
412
|
// Create thread with file resources.
|
|
395
413
|
// If the agent has multiple threads, only this thread can search this file.
|
|
396
414
|
const thread = await client.agents.createThread({ toolResources: fileSearchTool.resources });
|
|
@@ -400,18 +418,21 @@ const thread = await client.agents.createThread({ toolResources: fileSearchTool.
|
|
|
400
418
|
|
|
401
419
|
To create a message for assistant to process, you pass `user` as `role` and a question as `content`:
|
|
402
420
|
|
|
403
|
-
```
|
|
421
|
+
```ts snippet:createMessage
|
|
404
422
|
const message = await client.agents.createMessage(thread.id, {
|
|
405
423
|
role: "user",
|
|
406
424
|
content: "hello, world!",
|
|
407
425
|
});
|
|
426
|
+
console.log(`Created message, message ID: ${message.id}`);
|
|
408
427
|
```
|
|
409
428
|
|
|
410
429
|
#### Create Message with File Search Attachment
|
|
411
430
|
|
|
412
431
|
To attach a file to a message for content searching, you use `ToolUtility.createFileSearchTool()` and the `attachments` argument:
|
|
413
432
|
|
|
414
|
-
```
|
|
433
|
+
```ts snippet:messageWithFileSearch
|
|
434
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
435
|
+
|
|
415
436
|
const fileSearchTool = ToolUtility.createFileSearchTool();
|
|
416
437
|
const message = await client.agents.createMessage(thread.id, {
|
|
417
438
|
role: "user",
|
|
@@ -429,7 +450,9 @@ To attach a file to a message for data analysis, you use `ToolUtility.createCode
|
|
|
429
450
|
|
|
430
451
|
Here is an example:
|
|
431
452
|
|
|
432
|
-
```
|
|
453
|
+
```ts snippet:messageWithCodeInterpreter
|
|
454
|
+
import { ToolUtility } from "@azure/ai-projects";
|
|
455
|
+
|
|
433
456
|
// notice that CodeInterpreter must be enabled in the agent creation,
|
|
434
457
|
// otherwise the agent will not be able to see the file attachment for code interpretation
|
|
435
458
|
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool();
|
|
@@ -442,7 +465,6 @@ console.log(`Created agent, agent ID: ${agent.id}`);
|
|
|
442
465
|
|
|
443
466
|
const thread = await client.agents.createThread();
|
|
444
467
|
console.log(`Created thread, thread ID: ${thread.id}`);
|
|
445
|
-
|
|
446
468
|
const message = await client.agents.createMessage(thread.id, {
|
|
447
469
|
role: "user",
|
|
448
470
|
content:
|
|
@@ -459,9 +481,8 @@ console.log(`Created message, message ID: ${message.id}`);
|
|
|
459
481
|
|
|
460
482
|
Here is an example of `createRun` and poll until the run is completed:
|
|
461
483
|
|
|
462
|
-
```
|
|
484
|
+
```ts snippet:createRun
|
|
463
485
|
let run = await client.agents.createRun(thread.id, agent.id);
|
|
464
|
-
|
|
465
486
|
// Poll the run as long as run status is queued or in progress
|
|
466
487
|
while (
|
|
467
488
|
run.status === "queued" ||
|
|
@@ -484,10 +505,10 @@ const run = await client.agents.createThreadAndRun(agent.id, {
|
|
|
484
505
|
messages: [
|
|
485
506
|
{
|
|
486
507
|
role: "user",
|
|
487
|
-
content: "hello, world!"
|
|
488
|
-
}
|
|
489
|
-
]
|
|
490
|
-
}
|
|
508
|
+
content: "hello, world!",
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
},
|
|
491
512
|
});
|
|
492
513
|
```
|
|
493
514
|
|
|
@@ -495,40 +516,49 @@ With streaming, polling also need not be considered.
|
|
|
495
516
|
|
|
496
517
|
Here is an example:
|
|
497
518
|
|
|
498
|
-
```
|
|
519
|
+
```ts snippet:createRunStream
|
|
499
520
|
const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
|
|
500
521
|
```
|
|
501
522
|
|
|
502
523
|
Event handling can be done as follows:
|
|
503
524
|
|
|
504
|
-
```
|
|
525
|
+
```ts snippet:eventHandling
|
|
526
|
+
import {
|
|
527
|
+
RunStreamEvent,
|
|
528
|
+
ThreadRunOutput,
|
|
529
|
+
MessageStreamEvent,
|
|
530
|
+
MessageDeltaChunk,
|
|
531
|
+
MessageDeltaTextContent,
|
|
532
|
+
DoneEvent,
|
|
533
|
+
} from "@azure/ai-projects";
|
|
534
|
+
|
|
535
|
+
const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
|
|
505
536
|
for await (const eventMessage of streamEventMessages) {
|
|
506
|
-
switch (eventMessage.event) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
break;
|
|
537
|
+
switch (eventMessage.event) {
|
|
538
|
+
case RunStreamEvent.ThreadRunCreated:
|
|
539
|
+
console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`);
|
|
540
|
+
break;
|
|
541
|
+
case MessageStreamEvent.ThreadMessageDelta:
|
|
542
|
+
{
|
|
543
|
+
const messageDelta = eventMessage.data as MessageDeltaChunk;
|
|
544
|
+
messageDelta.delta.content.forEach((contentPart) => {
|
|
545
|
+
if (contentPart.type === "text") {
|
|
546
|
+
const textContent = contentPart as MessageDeltaTextContent;
|
|
547
|
+
const textValue = textContent.text?.value || "No text";
|
|
548
|
+
console.log(`Text delta received:: ${textValue}`);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
break;
|
|
553
|
+
case RunStreamEvent.ThreadRunCompleted:
|
|
554
|
+
console.log("Thread Run Completed");
|
|
555
|
+
break;
|
|
556
|
+
case ErrorEvent.Error:
|
|
557
|
+
console.log(`An error occurred. Data ${eventMessage.data}`);
|
|
558
|
+
break;
|
|
559
|
+
case DoneEvent.Done:
|
|
560
|
+
console.log("Stream completed.");
|
|
561
|
+
break;
|
|
532
562
|
}
|
|
533
563
|
}
|
|
534
564
|
```
|
|
@@ -537,10 +567,14 @@ switch (eventMessage.event) {
|
|
|
537
567
|
|
|
538
568
|
To retrieve messages from agents, use the following example:
|
|
539
569
|
|
|
540
|
-
```
|
|
570
|
+
```ts snippet:listMessages
|
|
571
|
+
import { MessageContentOutput, isOutputOfType, MessageTextContentOutput } from "../src/index.js";
|
|
572
|
+
|
|
541
573
|
const messages = await client.agents.listMessages(thread.id);
|
|
542
574
|
while (messages.hasMore) {
|
|
543
|
-
const nextMessages = await client.agents.listMessages(currentRun.threadId, {
|
|
575
|
+
const nextMessages = await client.agents.listMessages(currentRun.threadId, {
|
|
576
|
+
after: messages.lastId,
|
|
577
|
+
});
|
|
544
578
|
messages.data = messages.data.concat(nextMessages.data);
|
|
545
579
|
messages.hasMore = nextMessages.hasMore;
|
|
546
580
|
messages.lastId = nextMessages.lastId;
|
|
@@ -549,12 +583,14 @@ while (messages.hasMore) {
|
|
|
549
583
|
// The messages are following in the reverse order,
|
|
550
584
|
// we will iterate them and output only text contents.
|
|
551
585
|
for (const dataPoint of messages.data.reverse()) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
586
|
+
const lastMessageContent: MessageContentOutput = dataPoint.content[dataPoint.content.length - 1];
|
|
587
|
+
console.log(lastMessageContent);
|
|
588
|
+
if (isOutputOfType<MessageTextContentOutput>(lastMessageContent, "text")) {
|
|
589
|
+
console.log(
|
|
590
|
+
`${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`,
|
|
591
|
+
);
|
|
557
592
|
}
|
|
593
|
+
}
|
|
558
594
|
```
|
|
559
595
|
|
|
560
596
|
### Retrieve File
|
|
@@ -563,12 +599,29 @@ Files uploaded by Agents cannot be retrieved back. If your use case needs to acc
|
|
|
563
599
|
|
|
564
600
|
Here is an example retrieving file ids from messages:
|
|
565
601
|
|
|
566
|
-
```
|
|
602
|
+
```ts snippet:retrieveFile
|
|
603
|
+
import {
|
|
604
|
+
isOutputOfType,
|
|
605
|
+
MessageTextContentOutput,
|
|
606
|
+
MessageImageFileContentOutput,
|
|
607
|
+
} from "../src/index.js";
|
|
608
|
+
|
|
567
609
|
const messages = await client.agents.listMessages(thread.id);
|
|
610
|
+
// Get most recent message from the assistant
|
|
611
|
+
const assistantMessage = messages.data.find((msg) => msg.role === "assistant");
|
|
612
|
+
if (assistantMessage) {
|
|
613
|
+
const textContent = assistantMessage.content.find((content) =>
|
|
614
|
+
isOutputOfType<MessageTextContentOutput>(content, "text"),
|
|
615
|
+
) as MessageTextContentOutput;
|
|
616
|
+
if (textContent) {
|
|
617
|
+
console.log(`Last message: ${textContent.text.value}`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
568
620
|
const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile;
|
|
569
621
|
const imageFileName = (await client.agents.getFile(imageFile.fileId)).filename;
|
|
570
|
-
|
|
571
|
-
|
|
622
|
+
const fileContent = await (
|
|
623
|
+
await client.agents.getFileContent(imageFile.fileId).asNodeStream()
|
|
624
|
+
).body;
|
|
572
625
|
if (fileContent) {
|
|
573
626
|
const chunks: Buffer[] = [];
|
|
574
627
|
for await (const chunk of fileContent) {
|
|
@@ -586,13 +639,11 @@ console.log(`Saved image file to: ${imageFileName}`);
|
|
|
586
639
|
|
|
587
640
|
To remove resources after completing tasks, use the following functions:
|
|
588
641
|
|
|
589
|
-
```
|
|
642
|
+
```ts snippet:teardown
|
|
590
643
|
await client.agents.deleteVectorStore(vectorStore.id);
|
|
591
644
|
console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`);
|
|
592
|
-
|
|
593
645
|
await client.agents.deleteFile(file.id);
|
|
594
646
|
console.log(`Deleted file, file ID: ${file.id}`);
|
|
595
|
-
|
|
596
647
|
client.agents.deleteAgent(agent.id);
|
|
597
648
|
console.log(`Deleted agent, agent ID: ${agent.id}`);
|
|
598
649
|
```
|
|
@@ -626,39 +677,34 @@ npm install @opentelemetry/exporter-trace-otlp-proto \
|
|
|
626
677
|
|
|
627
678
|
Here is a code sample to be included above `createAgent`:
|
|
628
679
|
|
|
629
|
-
```
|
|
630
|
-
import { trace } from "@opentelemetry/api";
|
|
631
|
-
import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"
|
|
680
|
+
```ts snippet:tracing
|
|
632
681
|
import {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
682
|
+
NodeTracerProvider,
|
|
683
|
+
SimpleSpanProcessor,
|
|
684
|
+
ConsoleSpanExporter,
|
|
636
685
|
} from "@opentelemetry/sdk-trace-node";
|
|
686
|
+
import { trace } from "@opentelemetry/api";
|
|
687
|
+
import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter";
|
|
637
688
|
|
|
638
689
|
const provider = new NodeTracerProvider();
|
|
639
690
|
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
|
640
691
|
provider.register();
|
|
641
|
-
|
|
642
692
|
const tracer = trace.getTracer("Agents Sample", "1.0.0");
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
);
|
|
647
|
-
|
|
648
|
-
if (!appInsightsConnectionString) {
|
|
693
|
+
let appInsightsConnectionString =
|
|
694
|
+
process.env.APP_INSIGHTS_CONNECTION_STRING ?? "<appInsightsConnectionString>";
|
|
695
|
+
if (appInsightsConnectionString == "<appInsightsConnectionString>") {
|
|
649
696
|
appInsightsConnectionString = await client.telemetry.getConnectionString();
|
|
650
697
|
}
|
|
651
|
-
|
|
652
698
|
if (appInsightsConnectionString) {
|
|
653
699
|
const exporter = new AzureMonitorTraceExporter({
|
|
654
|
-
connectionString: appInsightsConnectionString
|
|
700
|
+
connectionString: appInsightsConnectionString,
|
|
655
701
|
});
|
|
656
702
|
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
|
|
657
703
|
}
|
|
658
|
-
|
|
659
704
|
await tracer.startActiveSpan("main", async (span) => {
|
|
660
|
-
|
|
661
|
-
// ...
|
|
705
|
+
client.telemetry.updateSettings({ enableContentRecording: true });
|
|
706
|
+
// ...
|
|
707
|
+
});
|
|
662
708
|
```
|
|
663
709
|
|
|
664
710
|
## Troubleshooting
|
|
@@ -667,16 +713,18 @@ await tracer.startActiveSpan("main", async (span) => {
|
|
|
667
713
|
|
|
668
714
|
Client methods that make service calls raise an [RestError](https://learn.microsoft.com/javascript/api/%40azure/core-rest-pipeline/resterror) for a non-success HTTP status code response from the service. The exception's `code` will hold the HTTP response status code. The exception's `error.message` contains a detailed message that may be helpful in diagnosing the issue:
|
|
669
715
|
|
|
670
|
-
```
|
|
671
|
-
import { RestError } from "@azure/core-rest-pipeline"
|
|
672
|
-
|
|
673
|
-
// ...
|
|
716
|
+
```ts snippet:exceptions
|
|
717
|
+
import { RestError } from "@azure/core-rest-pipeline";
|
|
674
718
|
|
|
675
719
|
try {
|
|
676
720
|
const result = await client.connections.listConnections();
|
|
677
|
-
} catch (e
|
|
678
|
-
|
|
679
|
-
|
|
721
|
+
} catch (e) {
|
|
722
|
+
if (e instanceof RestError) {
|
|
723
|
+
console.log(`Status code: ${e.code}`);
|
|
724
|
+
console.log(e.message);
|
|
725
|
+
} else {
|
|
726
|
+
console.error(e);
|
|
727
|
+
}
|
|
680
728
|
}
|
|
681
729
|
```
|
|
682
730
|
|
|
@@ -691,9 +739,9 @@ Operation returned an invalid status 'Unauthorized'
|
|
|
691
739
|
|
|
692
740
|
To report issues with the client library, or request additional features, please open a GitHub issue [here](https://github.com/Azure/azure-sdk-for-js/issues)
|
|
693
741
|
|
|
694
|
-
|
|
742
|
+
## Next steps
|
|
695
743
|
|
|
696
|
-
Have a look at the [
|
|
744
|
+
Have a look at the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) folder, containing fully runnable code.
|
|
697
745
|
|
|
698
746
|
## Contributing
|
|
699
747
|
|
|
@@ -714,8 +762,6 @@ additional questions or comments.
|
|
|
714
762
|
|
|
715
763
|
<!-- LINKS -->
|
|
716
764
|
|
|
717
|
-
<!-- [samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples -->
|
|
718
|
-
|
|
719
765
|
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
|
|
720
766
|
[entra_id]: https://learn.microsoft.com/azure/ai-services/authentication?tabs=powershell#authenticate-with-microsoft-entra-id
|
|
721
767
|
[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity
|