@azure/ai-agents 1.0.0-beta.2 → 1.0.0-beta.3
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 +29 -16
- package/dist/browser/api/agentsContext.d.ts.map +1 -1
- package/dist/browser/api/agentsContext.js +7 -4
- package/dist/browser/api/agentsContext.js.map +1 -1
- package/dist/browser/api/operations.js +6 -6
- package/dist/browser/api/operations.js.map +1 -1
- package/dist/browser/api/poller.d.ts +7 -2
- package/dist/browser/api/poller.d.ts.map +1 -1
- package/dist/browser/api/poller.js +31 -9
- package/dist/browser/api/poller.js.map +1 -1
- package/dist/browser/api/runs/operations.d.ts +9 -7
- package/dist/browser/api/runs/operations.d.ts.map +1 -1
- package/dist/browser/api/runs/operations.js +47 -7
- package/dist/browser/api/runs/operations.js.map +1 -1
- package/dist/browser/api/runs/options.d.ts +2 -1
- package/dist/browser/api/runs/options.d.ts.map +1 -1
- package/dist/browser/api/runs/options.js.map +1 -1
- package/dist/browser/classic/runs/index.d.ts +4 -1
- package/dist/browser/classic/runs/index.d.ts.map +1 -1
- package/dist/browser/classic/runs/index.js +2 -1
- package/dist/browser/classic/runs/index.js.map +1 -1
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/constants.js +1 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/models/models.d.ts +6 -2
- package/dist/browser/models/models.d.ts.map +1 -1
- package/dist/browser/models/models.js +8 -0
- package/dist/browser/models/models.js.map +1 -1
- package/dist/browser/utils.d.ts.map +1 -1
- package/dist/browser/utils.js +3 -1
- package/dist/browser/utils.js.map +1 -1
- package/dist/commonjs/api/agentsContext.d.ts.map +1 -1
- package/dist/commonjs/api/agentsContext.js +7 -4
- package/dist/commonjs/api/agentsContext.js.map +1 -1
- package/dist/commonjs/api/operations.js +6 -6
- package/dist/commonjs/api/operations.js.map +1 -1
- package/dist/commonjs/api/poller.d.ts +7 -2
- package/dist/commonjs/api/poller.d.ts.map +1 -1
- package/dist/commonjs/api/poller.js +32 -9
- package/dist/commonjs/api/poller.js.map +1 -1
- package/dist/commonjs/api/runs/operations.d.ts +9 -7
- package/dist/commonjs/api/runs/operations.d.ts.map +1 -1
- package/dist/commonjs/api/runs/operations.js +45 -4
- package/dist/commonjs/api/runs/operations.js.map +1 -1
- package/dist/commonjs/api/runs/options.d.ts +2 -1
- package/dist/commonjs/api/runs/options.d.ts.map +1 -1
- package/dist/commonjs/api/runs/options.js.map +1 -1
- package/dist/commonjs/classic/runs/index.d.ts +4 -1
- package/dist/commonjs/classic/runs/index.d.ts.map +1 -1
- package/dist/commonjs/classic/runs/index.js +1 -0
- package/dist/commonjs/classic/runs/index.js.map +1 -1
- package/dist/commonjs/constants.d.ts +1 -1
- package/dist/commonjs/constants.js +1 -1
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/commonjs/models/models.d.ts +6 -2
- package/dist/commonjs/models/models.d.ts.map +1 -1
- package/dist/commonjs/models/models.js +8 -0
- package/dist/commonjs/models/models.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/utils.d.ts.map +1 -1
- package/dist/commonjs/utils.js +3 -1
- package/dist/commonjs/utils.js.map +1 -1
- package/dist/esm/api/agentsContext.d.ts.map +1 -1
- package/dist/esm/api/agentsContext.js +7 -4
- package/dist/esm/api/agentsContext.js.map +1 -1
- package/dist/esm/api/operations.js +6 -6
- package/dist/esm/api/operations.js.map +1 -1
- package/dist/esm/api/poller.d.ts +7 -2
- package/dist/esm/api/poller.d.ts.map +1 -1
- package/dist/esm/api/poller.js +31 -9
- package/dist/esm/api/poller.js.map +1 -1
- package/dist/esm/api/runs/operations.d.ts +9 -7
- package/dist/esm/api/runs/operations.d.ts.map +1 -1
- package/dist/esm/api/runs/operations.js +47 -7
- package/dist/esm/api/runs/operations.js.map +1 -1
- package/dist/esm/api/runs/options.d.ts +2 -1
- package/dist/esm/api/runs/options.d.ts.map +1 -1
- package/dist/esm/api/runs/options.js.map +1 -1
- package/dist/esm/classic/runs/index.d.ts +4 -1
- package/dist/esm/classic/runs/index.d.ts.map +1 -1
- package/dist/esm/classic/runs/index.js +2 -1
- package/dist/esm/classic/runs/index.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/models/models.d.ts +6 -2
- package/dist/esm/models/models.d.ts.map +1 -1
- package/dist/esm/models/models.js +8 -0
- package/dist/esm/models/models.js.map +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +3 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/react-native/api/agentsContext.d.ts.map +1 -1
- package/dist/react-native/api/agentsContext.js +7 -4
- package/dist/react-native/api/agentsContext.js.map +1 -1
- package/dist/react-native/api/operations.js +6 -6
- package/dist/react-native/api/operations.js.map +1 -1
- package/dist/react-native/api/poller.d.ts +7 -2
- package/dist/react-native/api/poller.d.ts.map +1 -1
- package/dist/react-native/api/poller.js +31 -9
- package/dist/react-native/api/poller.js.map +1 -1
- package/dist/react-native/api/runs/operations.d.ts +9 -7
- package/dist/react-native/api/runs/operations.d.ts.map +1 -1
- package/dist/react-native/api/runs/operations.js +47 -7
- package/dist/react-native/api/runs/operations.js.map +1 -1
- package/dist/react-native/api/runs/options.d.ts +2 -1
- package/dist/react-native/api/runs/options.d.ts.map +1 -1
- package/dist/react-native/api/runs/options.js.map +1 -1
- package/dist/react-native/classic/runs/index.d.ts +4 -1
- package/dist/react-native/classic/runs/index.d.ts.map +1 -1
- package/dist/react-native/classic/runs/index.js +2 -1
- package/dist/react-native/classic/runs/index.js.map +1 -1
- package/dist/react-native/constants.d.ts +1 -1
- package/dist/react-native/constants.js +1 -1
- package/dist/react-native/constants.js.map +1 -1
- package/dist/react-native/models/models.d.ts +6 -2
- package/dist/react-native/models/models.d.ts.map +1 -1
- package/dist/react-native/models/models.js +8 -0
- package/dist/react-native/models/models.js.map +1 -1
- package/dist/react-native/utils.d.ts.map +1 -1
- package/dist/react-native/utils.js +3 -1
- package/dist/react-native/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,EACxB,+BAA+B,EAC/B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,wBAAwB,EACxB,gCAAgC,EACjC,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACvD,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,EAC/D,IAAI,EAAE,MAAM,GACX,MAAM,IAAI,CAAC,CAEb;AAED,2DAA2D;AAC3D,oBAAY,kBAAkB;IAC5B,iCAAiC;IACjC,aAAa,mBAAmB;IAChC,4BAA4B;IAC5B,eAAe,qBAAqB;IACpC,sBAAsB;IACtB,mBAAmB,yBAAyB;IAC5C,0BAA0B;IAC1B,aAAa,mBAAmB;IAChC,8BAA8B;IAC9B,gBAAgB,uBAAuB;CACxC;AAUD;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CACzB,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,MAAM,EAAE,GACtB;QAAE,UAAU,EAAE,mBAAmB,CAAA;KAAE;IAWtC;;;;;;;OAOG;IACH,MAAM,CAAC,6BAA6B,CAAC,YAAY,EAAE,MAAM,GAAG;QAC1D,UAAU,EA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AE,6BAA6B,CAAA;KAAE;IAMlF;;;;;;OAMG;IACH,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,UAAU,EAAE,wBAAwB,CAAA;KAAE;CAK3F"}
|
package/dist/commonjs/utils.js
CHANGED
|
@@ -88,11 +88,13 @@ class ToolUtility {
|
|
|
88
88
|
*
|
|
89
89
|
*/
|
|
90
90
|
static createBingGroundingTool(searchConfigurations) {
|
|
91
|
+
// Ensure searchConfigurations is an array even if it's undefined
|
|
92
|
+
const configs = searchConfigurations || [];
|
|
91
93
|
return {
|
|
92
94
|
definition: {
|
|
93
95
|
type: "bing_grounding",
|
|
94
96
|
bingGrounding: {
|
|
95
|
-
searchConfigurations:
|
|
97
|
+
searchConfigurations: configs.map((searchConfiguration) => ({
|
|
96
98
|
connectionId: searchConfiguration.connectionId,
|
|
97
99
|
market: searchConfiguration === null || searchConfiguration === void 0 ? void 0 : searchConfiguration.market,
|
|
98
100
|
setLang: searchConfiguration === null || searchConfiguration === void 0 ? void 0 : searchConfiguration.setLang,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAmClC,wCAKC;AAbD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,MAA+D,EAC/D,IAAY;IAEZ,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAC9B,CAAC;AAED,2DAA2D;AAC3D,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,iCAAiC;IACjC,sDAAgC,CAAA;IAChC,4BAA4B;IAC5B,0DAAoC,CAAA;IACpC,sBAAsB;IACtB,kEAA4C,CAAA;IAC5C,0BAA0B;IAC1B,sDAAgC,CAAA;IAChC,8BAA8B;IAC9B,6DAAuC,CAAA;AACzC,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B;AAED,MAAM,OAAO,GAAG;IACd,cAAc,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AC,CAAC;QAC3C,IAAI,CAAC,aAAa,mCAAQ,IAAI,CAAC,aAAa,GAAK,IAAI,CAAC,SAAS,CAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,yBAAoD;QAGjE,MAAM,IAAI,GAAG,WAAW,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB,CAAC,oBAAwD;QAG3E,MAAM,IAAI,GAAG,WAAW,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,YAAoB;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,0BAA0B,CAAC,YAAoB;QAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,6BAA6B,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtID,0BAsIC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AzureAISearchToolDefinition,\n CodeInterpreterToolDefinition,\n FileSearchToolDefinition,\n FileSearchToolDefinitionDetails,\n FunctionDefinition,\n FunctionToolDefinition,\n OpenApiToolDefinition,\n RequiredAction,\n RequiredToolCall,\n ToolDefinition,\n ToolDefinitionUnion,\n ToolResources,\n VectorStoreConfigurations,\n VectorStoreDataSource,\n OpenApiFunctionDefinition,\n AISearchIndexResource,\n BingGroundingToolDefinition,\n MicrosoftFabricToolDefinition,\n BingCustomSearchToolDefinition,\n BingCustomSearchConfiguration,\n SharepointToolDefinition,\n BingGroundingSearchConfiguration,\n} from \"./index.js\";\n\n/**\n * Determines if the given output is of the specified type.\n *\n * @typeParam T - The type to check against, which extends one of the possible output parent types.\n * @param output - The action to check, which can be of type `RequiredAction`, `RequiredToolCall`, or `ToolDefinitionUnion`.\n * @param type - The type to check the action against.\n * @returns A boolean indicating whether the action is of the specified type.\n */\nexport function isOutputOfType<T extends { type: string }>(\n output: RequiredAction | RequiredToolCall | ToolDefinitionUnion,\n type: string,\n): output is T {\n return output.type === type;\n}\n\n/** Types of connection tools used to configure an agent */\nexport enum connectionToolType {\n /** Bing grounding search tool */\n BingGrounding = \"bing_grounding\",\n /** Microsoft Fabric tool */\n MicrosoftFabric = \"fabric_dataagent\",\n /** Sharepoint tool */\n SharepointGrounding = \"sharepoint_grounding\",\n /** Azure Function tool */\n AzureFunction = \"azure_function\",\n /** Bing custom search tool */\n BingCustomSearch = \"bing_custom_search\",\n}\n\nconst toolMap = {\n bing_grounding: \"bingGrounding\",\n fabric_dataagent: \"fabric_dataagent\",\n sharepoint_grounding: \"sharepointGrounding\",\n azure_function: \"azureFunction\",\n bing_custom_search: \"bingCustomSearch\",\n};\n\n/**\n * Utility class for creating various tools.\n */\nexport class ToolUtility {\n /**\n * Creates a connection tool\n *\n * @param toolType - The type of the connection tool.\n * @param connectionIds - A list of the IDs of the connections to use.\n * @returns An object containing the definition for the connection tool\n */\n static createConnectionTool(\n toolType: connectionToolType,\n connectionIds: string[],\n ): { definition: ToolDefinitionUnion } {\n return {\n definition: {\n type: toolType,\n [toolMap[toolType]]: {\n connections: connectionIds.map((connectionId) => ({ connectionId: connectionId })),\n },\n },\n };\n }\n\n /**\n * Creates a sharepoint grounding search tool\n *\n * @param connectionId - The ID of the sharepoint search connection.\n *\n * @returns An object containing the definition and resources for the sharepoint grounding search tool\n *\n */\n static createSharepointGroundingTool(connectionId: string): {\n definition: SharepointToolDefinition;\n } {\n return {\n definition: {\n type: \"sharepoint_grounding\",\n sharepointGrounding: {\n connectionList: [\n {\n connectionId: connectionId,\n },\n ],\n },\n },\n };\n }\n\n /**\n * Creates a bing grounding search tool\n *\n * @param connectionId - The ID of the bing search connection.\n *\n * @returns An object containing the definition and resources for the bing grounding search tool\n *\n */\n static createBingGroundingTool(searchConfigurations: BingGroundingSearchConfiguration[]): {\n definition: BingGroundingToolDefinition;\n } {\n return {\n definition: {\n type: \"bing_grounding\",\n bingGrounding: {\n searchConfigurations: searchConfigurations.map((searchConfiguration) => ({\n connectionId: searchConfiguration.connectionId,\n market: searchConfiguration?.market,\n setLang: searchConfiguration?.setLang,\n count: searchConfiguration?.count,\n freshness: searchConfiguration?.freshness,\n })),\n },\n },\n };\n }\n\n /**\n * Creates a bing custom search tool\n *\n * @param searchConfigurations - The ID of bing search connection and instanceName.\n *\n * @returns An object containing the definition and resources for the bing custom search tool\n */\n\n static createBingCustomSearchTool(searchConfigurations: BingCustomSearchConfiguration[]): {\n definition: BingCustomSearchToolDefinition;\n } {\n return {\n definition: {\n type: \"bing_custom_search\",\n bingCustomSearch: {\n searchConfigurations: searchConfigurations.map((searchConfiguration) => ({\n connectionId: searchConfiguration.connectionId,\n instanceName: searchConfiguration.instanceName,\n })),\n },\n },\n };\n }\n\n /**\n * Creates a file search tool\n *\n * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent.\n * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool.\n * @param definitionDetails - The input definition information for a file search tool as used to configure an agent.\n *\n * @returns An object containing the definition and resources for the file search tool\n */\n static createFileSearchTool(\n vectorStoreIds?: string[],\n vectorStores?: Array<VectorStoreConfigurations>,\n definitionDetails?: FileSearchToolDefinitionDetails,\n ): { definition: FileSearchToolDefinition; resources: ToolResources } {\n return {\n definition: { type: \"file_search\", fileSearch: definitionDetails },\n resources: { fileSearch: { vectorStoreIds: vectorStoreIds, vectorStores: vectorStores } },\n };\n }\n\n /**\n * Creates a code interpreter tool\n *\n * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds.\n *\n * @returns An object containing the definition and resources for the code interpreter tool.\n */\n static createCodeInterpreterTool(\n fileIds?: string[],\n dataSources?: Array<VectorStoreDataSource>,\n ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } {\n if (fileIds && dataSources) {\n throw new Error(\"Cannot specify both fileIds and dataSources\");\n }\n\n return {\n definition: { type: \"code_interpreter\" },\n resources: { codeInterpreter: { fileIds: fileIds, dataSources: dataSources } },\n };\n }\n\n /**\n * Creates an Azure AI search tool\n *\n * @param indexConnectionId - The connection ID of the Azure AI search index.\n * @param indexName - The name of the Azure AI search index.\n *\n * @returns An object containing the definition and resources for the Azure AI search tool.\n */\n static createAzureAISearchTool(\n indexConnectionId: string,\n indexName: string,\n options?: AISearchIndexResource,\n ): { definition: AzureAISearchToolDefinition; resources: ToolResources } {\n return {\n definition: { type: \"azure_ai_search\" },\n resources: {\n azureAISearch: {\n indexList: [\n {\n indexConnectionId: indexConnectionId,\n indexName: indexName,\n queryType: options?.queryType,\n topK: options?.topK,\n filter: options?.filter,\n },\n ],\n },\n },\n };\n }\n\n /**\n * Creates a Microsoft Fabric tool\n *\n * @param connectionIds - A list of the IDs of the Fabric connections to use.\n * @returns An object containing the definition for the Microsoft Fabric tool\n */\n static createFabricTool(connectionId: string): { definition: MicrosoftFabricToolDefinition } {\n return {\n definition: {\n type: \"fabric_dataagent\",\n fabricDataagent: {\n connectionList: [{ connectionId: connectionId }],\n },\n },\n };\n }\n\n /**\n * Creates a function tool\n *\n * @param functionDefinition - The function definition to use.\n *\n * @returns An object containing the definition for the function tool.\n */\n static createFunctionTool(functionDefinition: FunctionDefinition): {\n definition: FunctionToolDefinition;\n } {\n return {\n definition: {\n type: \"function\",\n function: functionDefinition,\n },\n };\n }\n\n /**\n * Creates an OpenApi tool\n *\n * @param openApiFunctionDefinition - The OpenApi function definition to use.\n *\n * @returns An object containing the definition for the OpenApi tool.\n */\n static createOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): {\n definition: OpenApiToolDefinition;\n } {\n return {\n definition: {\n type: \"openapi\",\n openapi: {\n name: openApiFunctionDefinition.name,\n spec: openApiFunctionDefinition.spec,\n description: openApiFunctionDefinition.description,\n auth: openApiFunctionDefinition.auth,\n defaultParams: openApiFunctionDefinition.defaultParams,\n },\n },\n };\n }\n}\n/**\n * Represents a set of tools with their definitions and resources.\n */\nexport class ToolSet {\n /** A list of tool definitions that have been added to the tool set. */\n toolDefinitions: ToolDefinition[] = [];\n\n /** A collection of resources associated with the tools in the tool set. */\n toolResources: ToolResources = {};\n\n /**\n * Adds a connection tool to the tool set.\n *\n * @param toolType - The type of the connection tool.\n * @param connectionIds - A list of the IDs of the connections to use.\n *\n * @returns An object containing the definition for the connection tool\n */\n addConnectionTool(\n toolType: connectionToolType,\n connectionIds: string[],\n ): { definition: ToolDefinition } {\n const tool = ToolUtility.createConnectionTool(toolType, connectionIds);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a file search tool to the tool set.\n *\n * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent.\n * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool.\n * @param definitionDetails - The input definition information for a file search tool as used to configure an agent.\n *\n * @returns An object containing the definition and resources for the file search tool\n */\n addFileSearchTool(\n vectorStoreIds?: string[],\n vectorStores?: Array<VectorStoreConfigurations>,\n definitionDetails?: FileSearchToolDefinitionDetails,\n ): { definition: FileSearchToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createFileSearchTool(vectorStoreIds, vectorStores, definitionDetails);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds a code interpreter tool to the tool set.\n *\n * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds.\n *\n * @returns An object containing the definition and resources for the code interpreter tool\n */\n addCodeInterpreterTool(\n fileIds?: string[],\n dataSources?: Array<VectorStoreDataSource>,\n ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createCodeInterpreterTool(fileIds, dataSources);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds an Azure AI search tool to the tool set.\n *\n * @param indexConnectionId - The connection ID of the Azure AI search index.\n * @param indexName - The name of the Azure AI search index.\n *\n * @returns An object containing the definition and resources for the Azure AI search tool\n */\n addAzureAISearchTool(\n indexConnectionId: string,\n indexName: string,\n ): { definition: AzureAISearchToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createAzureAISearchTool(indexConnectionId, indexName);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds an OpenApi tool to the tool set.\n *\n * @param openApiFunctionDefinition - The OpenApi function definition to use.\n *\n * @returns An object containing the definition for the OpenApi tool\n */\n addOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): {\n definition: OpenApiToolDefinition;\n } {\n const tool = ToolUtility.createOpenApiTool(openApiFunctionDefinition);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a bing grounding search tool to the tool set.\n *\n * @param connectionId - The ID of the bing search connection.\n *\n * @returns An object containing the definition and resources for the bing grounding search tool\n */\n addBingGroundingTool(searchConfigurations: BingGroundingSearchConfiguration[]): {\n definition: BingGroundingToolDefinition;\n } {\n const tool = ToolUtility.createBingGroundingTool(searchConfigurations);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a Microsoft Fabric tool to the tool set.\n *\n * @param connectionId - The ID of the Fabric connection to use.\n * @returns An object containing the definition for the Microsoft Fabric tool\n */\n addFabricTool(connectionId: string): { definition: MicrosoftFabricToolDefinition } {\n const tool = ToolUtility.createFabricTool(connectionId);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds sharepoint grounding search tool to the tool set.\n *\n * @param connectionId - The ID of the sharepoint search connection.\n *\n * @returns An object containing the definition and resources for the sharepoint grounding search tool\n */\n addSharepointGroundingTool(connectionId: string): { definition: SharepointToolDefinition } {\n const tool = ToolUtility.createSharepointGroundingTool(connectionId);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAmClC,wCAKC;AAbD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,MAA+D,EAC/D,IAAY;IAEZ,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAC9B,CAAC;AAED,2DAA2D;AAC3D,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,iCAAiC;IACjC,sDAAgC,CAAA;IAChC,4BAA4B;IAC5B,0DAAoC,CAAA;IACpC,sBAAsB;IACtB,kEAA4C,CAAA;IAC5C,0BAA0B;IAC1B,sDAAgC,CAAA;IAChC,8BAA8B;IAC9B,6DAAuC,CAAA;AACzC,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B;AAED,MAAM,OAAO,GAAG;IACd,cAAc,EAAE,eAAe;IAC/B,gBAAgB,EAAE,kBAAkB;IACpC,oBAAoB,EAAE,qBAAqB;IAC3C,cAAc,EAAE,eAAe;IAC/B,kBAAkB,EAAE,kB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,aAAa,GAAK,IAAI,CAAC,SAAS,CAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,yBAAoD;QAGjE,MAAM,IAAI,GAAG,WAAW,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB,CAAC,oBAAwD;QAG3E,MAAM,IAAI,GAAG,WAAW,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,YAAoB;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,0BAA0B,CAAC,YAAoB;QAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,6BAA6B,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtID,0BAsIC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AzureAISearchToolDefinition,\n CodeInterpreterToolDefinition,\n FileSearchToolDefinition,\n FileSearchToolDefinitionDetails,\n FunctionDefinition,\n FunctionToolDefinition,\n OpenApiToolDefinition,\n RequiredAction,\n RequiredToolCall,\n ToolDefinition,\n ToolDefinitionUnion,\n ToolResources,\n VectorStoreConfigurations,\n VectorStoreDataSource,\n OpenApiFunctionDefinition,\n AISearchIndexResource,\n BingGroundingToolDefinition,\n MicrosoftFabricToolDefinition,\n BingCustomSearchToolDefinition,\n BingCustomSearchConfiguration,\n SharepointToolDefinition,\n BingGroundingSearchConfiguration,\n} from \"./index.js\";\n\n/**\n * Determines if the given output is of the specified type.\n *\n * @typeParam T - The type to check against, which extends one of the possible output parent types.\n * @param output - The action to check, which can be of type `RequiredAction`, `RequiredToolCall`, or `ToolDefinitionUnion`.\n * @param type - The type to check the action against.\n * @returns A boolean indicating whether the action is of the specified type.\n */\nexport function isOutputOfType<T extends { type: string }>(\n output: RequiredAction | RequiredToolCall | ToolDefinitionUnion,\n type: string,\n): output is T {\n return output.type === type;\n}\n\n/** Types of connection tools used to configure an agent */\nexport enum connectionToolType {\n /** Bing grounding search tool */\n BingGrounding = \"bing_grounding\",\n /** Microsoft Fabric tool */\n MicrosoftFabric = \"fabric_dataagent\",\n /** Sharepoint tool */\n SharepointGrounding = \"sharepoint_grounding\",\n /** Azure Function tool */\n AzureFunction = \"azure_function\",\n /** Bing custom search tool */\n BingCustomSearch = \"bing_custom_search\",\n}\n\nconst toolMap = {\n bing_grounding: \"bingGrounding\",\n fabric_dataagent: \"fabric_dataagent\",\n sharepoint_grounding: \"sharepointGrounding\",\n azure_function: \"azureFunction\",\n bing_custom_search: \"bingCustomSearch\",\n};\n\n/**\n * Utility class for creating various tools.\n */\nexport class ToolUtility {\n /**\n * Creates a connection tool\n *\n * @param toolType - The type of the connection tool.\n * @param connectionIds - A list of the IDs of the connections to use.\n * @returns An object containing the definition for the connection tool\n */\n static createConnectionTool(\n toolType: connectionToolType,\n connectionIds: string[],\n ): { definition: ToolDefinitionUnion } {\n return {\n definition: {\n type: toolType,\n [toolMap[toolType]]: {\n connections: connectionIds.map((connectionId) => ({ connectionId: connectionId })),\n },\n },\n };\n }\n\n /**\n * Creates a sharepoint grounding search tool\n *\n * @param connectionId - The ID of the sharepoint search connection.\n *\n * @returns An object containing the definition and resources for the sharepoint grounding search tool\n *\n */\n static createSharepointGroundingTool(connectionId: string): {\n definition: SharepointToolDefinition;\n } {\n return {\n definition: {\n type: \"sharepoint_grounding\",\n sharepointGrounding: {\n connectionList: [\n {\n connectionId: connectionId,\n },\n ],\n },\n },\n };\n }\n\n /**\n * Creates a bing grounding search tool\n *\n * @param connectionId - The ID of the bing search connection.\n *\n * @returns An object containing the definition and resources for the bing grounding search tool\n *\n */\n static createBingGroundingTool(searchConfigurations: BingGroundingSearchConfiguration[]): {\n definition: BingGroundingToolDefinition;\n } {\n // Ensure searchConfigurations is an array even if it's undefined\n const configs = searchConfigurations || [];\n return {\n definition: {\n type: \"bing_grounding\",\n bingGrounding: {\n searchConfigurations: configs.map((searchConfiguration) => ({\n connectionId: searchConfiguration.connectionId,\n market: searchConfiguration?.market,\n setLang: searchConfiguration?.setLang,\n count: searchConfiguration?.count,\n freshness: searchConfiguration?.freshness,\n })),\n },\n },\n };\n }\n\n /**\n * Creates a bing custom search tool\n *\n * @param searchConfigurations - The ID of bing search connection and instanceName.\n *\n * @returns An object containing the definition and resources for the bing custom search tool\n */\n\n static createBingCustomSearchTool(searchConfigurations: BingCustomSearchConfiguration[]): {\n definition: BingCustomSearchToolDefinition;\n } {\n return {\n definition: {\n type: \"bing_custom_search\",\n bingCustomSearch: {\n searchConfigurations: searchConfigurations.map((searchConfiguration) => ({\n connectionId: searchConfiguration.connectionId,\n instanceName: searchConfiguration.instanceName,\n })),\n },\n },\n };\n }\n\n /**\n * Creates a file search tool\n *\n * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent.\n * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool.\n * @param definitionDetails - The input definition information for a file search tool as used to configure an agent.\n *\n * @returns An object containing the definition and resources for the file search tool\n */\n static createFileSearchTool(\n vectorStoreIds?: string[],\n vectorStores?: Array<VectorStoreConfigurations>,\n definitionDetails?: FileSearchToolDefinitionDetails,\n ): { definition: FileSearchToolDefinition; resources: ToolResources } {\n return {\n definition: { type: \"file_search\", fileSearch: definitionDetails },\n resources: { fileSearch: { vectorStoreIds: vectorStoreIds, vectorStores: vectorStores } },\n };\n }\n\n /**\n * Creates a code interpreter tool\n *\n * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds.\n *\n * @returns An object containing the definition and resources for the code interpreter tool.\n */\n static createCodeInterpreterTool(\n fileIds?: string[],\n dataSources?: Array<VectorStoreDataSource>,\n ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } {\n if (fileIds && dataSources) {\n throw new Error(\"Cannot specify both fileIds and dataSources\");\n }\n\n return {\n definition: { type: \"code_interpreter\" },\n resources: { codeInterpreter: { fileIds: fileIds, dataSources: dataSources } },\n };\n }\n\n /**\n * Creates an Azure AI search tool\n *\n * @param indexConnectionId - The connection ID of the Azure AI search index.\n * @param indexName - The name of the Azure AI search index.\n *\n * @returns An object containing the definition and resources for the Azure AI search tool.\n */\n static createAzureAISearchTool(\n indexConnectionId: string,\n indexName: string,\n options?: AISearchIndexResource,\n ): { definition: AzureAISearchToolDefinition; resources: ToolResources } {\n return {\n definition: { type: \"azure_ai_search\" },\n resources: {\n azureAISearch: {\n indexList: [\n {\n indexConnectionId: indexConnectionId,\n indexName: indexName,\n queryType: options?.queryType,\n topK: options?.topK,\n filter: options?.filter,\n },\n ],\n },\n },\n };\n }\n\n /**\n * Creates a Microsoft Fabric tool\n *\n * @param connectionIds - A list of the IDs of the Fabric connections to use.\n * @returns An object containing the definition for the Microsoft Fabric tool\n */\n static createFabricTool(connectionId: string): { definition: MicrosoftFabricToolDefinition } {\n return {\n definition: {\n type: \"fabric_dataagent\",\n fabricDataagent: {\n connectionList: [{ connectionId: connectionId }],\n },\n },\n };\n }\n\n /**\n * Creates a function tool\n *\n * @param functionDefinition - The function definition to use.\n *\n * @returns An object containing the definition for the function tool.\n */\n static createFunctionTool(functionDefinition: FunctionDefinition): {\n definition: FunctionToolDefinition;\n } {\n return {\n definition: {\n type: \"function\",\n function: functionDefinition,\n },\n };\n }\n\n /**\n * Creates an OpenApi tool\n *\n * @param openApiFunctionDefinition - The OpenApi function definition to use.\n *\n * @returns An object containing the definition for the OpenApi tool.\n */\n static createOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): {\n definition: OpenApiToolDefinition;\n } {\n return {\n definition: {\n type: \"openapi\",\n openapi: {\n name: openApiFunctionDefinition.name,\n spec: openApiFunctionDefinition.spec,\n description: openApiFunctionDefinition.description,\n auth: openApiFunctionDefinition.auth,\n defaultParams: openApiFunctionDefinition.defaultParams,\n },\n },\n };\n }\n}\n/**\n * Represents a set of tools with their definitions and resources.\n */\nexport class ToolSet {\n /** A list of tool definitions that have been added to the tool set. */\n toolDefinitions: ToolDefinition[] = [];\n\n /** A collection of resources associated with the tools in the tool set. */\n toolResources: ToolResources = {};\n\n /**\n * Adds a connection tool to the tool set.\n *\n * @param toolType - The type of the connection tool.\n * @param connectionIds - A list of the IDs of the connections to use.\n *\n * @returns An object containing the definition for the connection tool\n */\n addConnectionTool(\n toolType: connectionToolType,\n connectionIds: string[],\n ): { definition: ToolDefinition } {\n const tool = ToolUtility.createConnectionTool(toolType, connectionIds);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a file search tool to the tool set.\n *\n * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent.\n * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool.\n * @param definitionDetails - The input definition information for a file search tool as used to configure an agent.\n *\n * @returns An object containing the definition and resources for the file search tool\n */\n addFileSearchTool(\n vectorStoreIds?: string[],\n vectorStores?: Array<VectorStoreConfigurations>,\n definitionDetails?: FileSearchToolDefinitionDetails,\n ): { definition: FileSearchToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createFileSearchTool(vectorStoreIds, vectorStores, definitionDetails);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds a code interpreter tool to the tool set.\n *\n * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.\n * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds.\n *\n * @returns An object containing the definition and resources for the code interpreter tool\n */\n addCodeInterpreterTool(\n fileIds?: string[],\n dataSources?: Array<VectorStoreDataSource>,\n ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createCodeInterpreterTool(fileIds, dataSources);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds an Azure AI search tool to the tool set.\n *\n * @param indexConnectionId - The connection ID of the Azure AI search index.\n * @param indexName - The name of the Azure AI search index.\n *\n * @returns An object containing the definition and resources for the Azure AI search tool\n */\n addAzureAISearchTool(\n indexConnectionId: string,\n indexName: string,\n ): { definition: AzureAISearchToolDefinition; resources: ToolResources } {\n const tool = ToolUtility.createAzureAISearchTool(indexConnectionId, indexName);\n this.toolDefinitions.push(tool.definition);\n this.toolResources = { ...this.toolResources, ...tool.resources };\n return tool;\n }\n\n /**\n * Adds an OpenApi tool to the tool set.\n *\n * @param openApiFunctionDefinition - The OpenApi function definition to use.\n *\n * @returns An object containing the definition for the OpenApi tool\n */\n addOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): {\n definition: OpenApiToolDefinition;\n } {\n const tool = ToolUtility.createOpenApiTool(openApiFunctionDefinition);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a bing grounding search tool to the tool set.\n *\n * @param connectionId - The ID of the bing search connection.\n *\n * @returns An object containing the definition and resources for the bing grounding search tool\n */\n addBingGroundingTool(searchConfigurations: BingGroundingSearchConfiguration[]): {\n definition: BingGroundingToolDefinition;\n } {\n const tool = ToolUtility.createBingGroundingTool(searchConfigurations);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds a Microsoft Fabric tool to the tool set.\n *\n * @param connectionId - The ID of the Fabric connection to use.\n * @returns An object containing the definition for the Microsoft Fabric tool\n */\n addFabricTool(connectionId: string): { definition: MicrosoftFabricToolDefinition } {\n const tool = ToolUtility.createFabricTool(connectionId);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n\n /**\n * Adds sharepoint grounding search tool to the tool set.\n *\n * @param connectionId - The ID of the sharepoint search connection.\n *\n * @returns An object containing the definition and resources for the sharepoint grounding search tool\n */\n addSharepointGroundingTool(connectionId: string): { definition: SharepointToolDefinition } {\n const tool = ToolUtility.createSharepointGroundingTool(connectionId);\n this.toolDefinitions.push(tool.definition);\n return tool;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentsContext.d.ts","sourceRoot":"","sources":["../../../src/api/agentsContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAmB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,0BAA2B,SAAQ,aAAa;IAC/D,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,aAAa,GAAG,eAAe,EAC3C,OAAO,GAAE,0BAA+B,GACvC,aAAa,
|
|
1
|
+
{"version":3,"file":"agentsContext.d.ts","sourceRoot":"","sources":["../../../src/api/agentsContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAmB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,0BAA2B,SAAQ,aAAa;IAC/D,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,aAAa,GAAG,eAAe,EAC3C,OAAO,GAAE,0BAA+B,GACvC,aAAa,CA4Cf"}
|
|
@@ -7,7 +7,7 @@ import { isKeyCredential } from "@azure/core-auth";
|
|
|
7
7
|
export function createAgents(endpointParam, credential, options = {}) {
|
|
8
8
|
var _a, _b, _c, _d, _e, _f;
|
|
9
9
|
const prefixFromOptions = (_a = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _a === void 0 ? void 0 : _a.userAgentPrefix;
|
|
10
|
-
const userAgentInfo = `azsdk-js-ai-agents/1.0.0-beta.
|
|
10
|
+
const userAgentInfo = `azsdk-js-ai-agents/1.0.0-beta.3`;
|
|
11
11
|
const userAgentPrefix = prefixFromOptions
|
|
12
12
|
? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`
|
|
13
13
|
: `azsdk-js-api ${userAgentInfo}`;
|
|
@@ -29,12 +29,15 @@ export function createAgents(endpointParam, credential, options = {}) {
|
|
|
29
29
|
clientContext.pipeline.addPolicy({
|
|
30
30
|
name: "ClientApiVersionPolicy",
|
|
31
31
|
sendRequest: (req, next) => {
|
|
32
|
+
var _a;
|
|
32
33
|
// Use the apiVersion defined in request url directly
|
|
33
34
|
// Append one if there is no apiVersion and we have one at client options
|
|
34
35
|
const url = new URL(req.url);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const defaultApiVersion = (_a = url.searchParams.get("api-version")) !== null && _a !== void 0 ? _a : apiVersion;
|
|
37
|
+
// remove api-version from url
|
|
38
|
+
url.searchParams.delete("api-version");
|
|
39
|
+
// add api-version to url
|
|
40
|
+
req.url = `${url.toString()}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${defaultApiVersion}`;
|
|
38
41
|
return next(req);
|
|
39
42
|
},
|
|
40
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentsContext.js","sourceRoot":"","sources":["../../../src/api/agentsContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAyB,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAiB,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AAenF,MAAM,UAAU,YAAY,CAC1B,aAAqB,EACrB,UAA2C,EAC3C,UAAsC,EAAE;;IAExC,MAAM,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,0CAAE,eAAe,CAAC;IACrE,MAAM,aAAa,GAAG,iCAAiC,CAAC;IACxD,MAAM,eAAe,GAAG,iBAAiB;QACvC,CAAC,CAAC,GAAG,iBAAiB,iBAAiB,aAAa,EAAE;QACtD,CAAC,CAAC,gBAAgB,aAAa,EAAE,CAAC;IACpC,MAAM,qCACD,OAAO,KACV,gBAAgB,EAAE,EAAE,eAAe,EAAE,EACrC,cAAc,EAAE,EAAE,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI,EAAE,EACzE,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,+BAA+B,CAAC;SACzE,GACF,EAPK,EAAE,UAAU,EAAE,CAAC,OAOpB,E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IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,iBAAiB,GAAG,MAAA,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAI,UAAU,CAAC;YAC5E,8BAA8B;YAC9B,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACvC,yBAAyB;YACzB,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,GACzB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,iBAAiB,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,gCAAK,aAAa,KAAE,UAAU,GAAmB,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { logger } from \"../logger.js\";\nimport { KnownVersions } from \"../models/models.js\";\nimport { Client, ClientOptions, getClient } from \"@azure-rest/core-client\";\nimport { KeyCredential, isKeyCredential, TokenCredential } from \"@azure/core-auth\";\n\nexport interface AgentsContext extends Client {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion: string;\n}\n\n/** Optional parameters for the client. */\nexport interface AgentsClientOptionalParams extends ClientOptions {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\nexport function createAgents(\n endpointParam: string,\n credential: KeyCredential | TokenCredential,\n options: AgentsClientOptionalParams = {},\n): AgentsContext {\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentInfo = `azsdk-js-ai-agents/1.0.0-beta.3`;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`\n : `azsdk-js-api ${userAgentInfo}`;\n const { apiVersion: _, ...updatedOptions } = {\n ...options,\n userAgentOptions: { userAgentPrefix },\n loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://ai.azure.com/.default\"],\n },\n };\n const clientContext = getClient(endpointParam, credential, updatedOptions);\n\n if (isKeyCredential(credential)) {\n clientContext.pipeline.addPolicy({\n name: \"customKeyCredentialPolicy\",\n sendRequest(request, next) {\n request.headers.set(\"Authorization\", \"Bearer \" + credential.key);\n return next(request);\n },\n });\n }\n clientContext.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n const apiVersion = options.apiVersion ?? \"2025-05-15-preview\";\n clientContext.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n const defaultApiVersion = url.searchParams.get(\"api-version\") ?? apiVersion;\n // remove api-version from url\n url.searchParams.delete(\"api-version\");\n // add api-version to url\n req.url = `${url.toString()}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${defaultApiVersion}`;\n return next(req);\n },\n });\n return { ...clientContext, apiVersion } as AgentsContext;\n}\n"]}
|
|
@@ -282,18 +282,18 @@ async function processStream(streamResponse) {
|
|
|
282
282
|
}
|
|
283
283
|
/** Create a run and stream the events */
|
|
284
284
|
export async function createRunStreaming(context, assistantId, threadId, options = { requestOptions: {} }) {
|
|
285
|
-
options
|
|
286
|
-
return processStream(_createRunSend(context, threadId, assistantId,
|
|
285
|
+
const streamOptions = Object.assign(Object.assign({}, options), { stream: true });
|
|
286
|
+
return processStream(_createRunSend(context, threadId, assistantId, streamOptions));
|
|
287
287
|
}
|
|
288
288
|
/** Create a thread and run and stream the events */
|
|
289
289
|
export async function createThreadAndRunStreaming(context, assistantId, options = { requestOptions: {} }) {
|
|
290
|
-
options
|
|
291
|
-
return processStream(_createThreadAndRunSend(context, assistantId,
|
|
290
|
+
const streamOptions = Object.assign(Object.assign({}, options), { stream: true });
|
|
291
|
+
return processStream(_createThreadAndRunSend(context, assistantId, streamOptions));
|
|
292
292
|
}
|
|
293
293
|
export async function submitToolOutputsToRunStreaming(context, threadId, runId, options = { requestOptions: {} }) {
|
|
294
|
-
options
|
|
294
|
+
const streamOptions = Object.assign(Object.assign({}, options), { stream: true });
|
|
295
295
|
return processStream(context
|
|
296
296
|
.path("/threads/{threadId}/runs/{runId}/submit_tool_outputs", threadId, runId)
|
|
297
|
-
.post(
|
|
297
|
+
.post(streamOptions));
|
|
298
298
|
}
|
|
299
299
|
//# sourceMappingURL=operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../src/api/operations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EACL,uBAAuB,EACvB,kCAAkC,EAClC,oCAAoC,EAEpC,iBAAiB,EAEjB,mCAAmC,EAEnC,+BAA+B,EAC/B,oCAAoC,EACpC,oCAAoC,EACpC,0BAA0B,EAC1B,gCAAgC,EAEhC,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAEL,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGL,eAAe,EACf,mCAAmC,GACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAKL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EAAoC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAA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AC;AACnC,CAAC;AAED,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,WAAmB,EACnB,QAAgB,EAChB,UAAuC,EAAE,cAAc,EAAE,EAAE,EAAE;IAE7D,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEtB,OAAO,aAAa,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAe,EACf,WAAmB,EACnB,UAA4C,EAAE,cAAc,EAAE,EAAE,EAAE;IAElE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,aAAa,CAAC,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAAe,EACf,QAAgB,EAChB,KAAa,EACb,UAAoD,EAAE,cAAc,EAAE,EAAE,EAAE;IAE1E,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAEtB,OAAO,aAAa,CAClB,OAAO;SACJ,IAAI,CAAC,sDAAsD,EAAE,QAAQ,EAAE,KAAK,CAAC;SAC7E,IAAI,CAAC,OAAO,CAAC,CACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AgentsContext as Client } from \"./index.js\";\nimport {\n toolResourcesSerializer,\n toolDefinitionUnionArraySerializer,\n agentsResponseFormatOptionSerializer,\n Agent,\n agentDeserializer,\n _AgentsPagedResultAgent,\n _agentsPagedResultAgentDeserializer,\n AgentDeletionStatus,\n agentDeletionStatusDeserializer,\n agentThreadCreationOptionsSerializer,\n updateToolResourcesOptionsSerializer,\n truncationObjectSerializer,\n agentsToolChoiceOptionSerializer,\n ThreadRun,\n threadRunDeserializer,\n} from \"../models/models.js\";\nimport {\n CreateThreadAndRunOptionalParams,\n DeleteAgentOptionalParams,\n UpdateAgentOptionalParams,\n GetAgentOptionalParams,\n ListAgentsOptionalParams,\n CreateAgentOptionalParams,\n} from \"./options.js\";\nimport {\n PagedAsyncIterableIterator,\n buildPagedAsyncIterator,\n} from \"../static-helpers/pagingHelpers.js\";\nimport { expandUrlTemplate } from \"../static-helpers/urlTemplate.js\";\nimport {\n StreamableMethod,\n PathUncheckedResponse,\n createRestError,\n operationOptionsToRequestParameters,\n} from \"@azure-rest/core-client\";\nimport {\n AgentEventMessage,\n AgentEventMessageStream,\n AgentEventStreamData,\n AgentRunResponse,\n MessageStreamEvent,\n RunStepStreamEvent,\n RunStreamEvent,\n ThreadStreamEvent,\n} from \"../models/streamingModels.js\";\nimport {\n RunsCreateRunOptionalParams,\n RunsSubmitToolOutputsToRunOptionalParams,\n} from \"./runs/options.js\";\nimport { EventMessageStream, EventMessage, createSseStream } from \"@azure/core-sse\";\nimport { isNodeLike } from \"@azure/core-util\";\nimport { IncomingMessage } from \"http\";\nimport { logger } from \"../logger.js\";\nimport { _createRunSend } from \"./runs/operations.js\";\n\nexport function _createThreadAndRunSend(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/threads/runs{?api%2Dversion}\",\n {\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n assistant_id: assistantId,\n thread: !options?.thread\n ? options?.thread\n : agentThreadCreationOptionsSerializer(options?.thread),\n model: options?.model,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : updateToolResourcesOptionsSerializer(options?.toolResources),\n stream: options?.stream,\n temperature: options?.temperature,\n top_p: options?.topP,\n max_prompt_tokens: options?.maxPromptTokens,\n max_completion_tokens: options?.maxCompletionTokens,\n truncation_strategy: !options?.truncationStrategy\n ? options?.truncationStrategy\n : truncationObjectSerializer(options?.truncationStrategy),\n tool_choice: !options?.toolChoice\n ? options?.toolChoice\n : agentsToolChoiceOptionSerializer(options?.toolChoice),\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n parallel_tool_calls: options?.parallelToolCalls,\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _createThreadAndRunDeserialize(\n result: PathUncheckedResponse,\n): Promise<ThreadRun> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return threadRunDeserializer(result.body);\n}\n\n/** Creates a new agent thread and immediately starts a run using that new thread. */\nexport function createThreadAndRun(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): AgentRunResponse {\n async function executeCreateThreadAndRun(): Promise<ThreadRun> {\n const result = await _createThreadAndRunSend(context, assistantId, options);\n return _createThreadAndRunDeserialize(result);\n }\n\n return {\n then: function (onFulfilled, onRejected) {\n return executeCreateThreadAndRun().then(onFulfilled, onRejected).catch(onRejected);\n },\n async stream(): Promise<AgentEventMessageStream> {\n return createThreadAndRunStreaming(context, assistantId, options);\n },\n };\n}\n\nexport function _deleteAgentSend(\n context: Client,\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).delete({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _deleteAgentDeserialize(\n result: PathUncheckedResponse,\n): Promise<AgentDeletionStatus> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeletionStatusDeserializer(result.body);\n}\n\n/** Deletes an agent. */\nexport async function deleteAgent(\n context: Client,\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n): Promise<AgentDeletionStatus> {\n const result = await _deleteAgentSend(context, assistantId, options);\n return _deleteAgentDeserialize(result);\n}\n\nexport function _updateAgentSend(\n context: Client,\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n model: options?.model,\n name: options?.name,\n description: options?.description,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : toolResourcesSerializer(options?.toolResources),\n temperature: options?.temperature,\n top_p: options?.topP,\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _updateAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Modifies an existing agent. */\nexport async function updateAgent(\n context: Client,\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _updateAgentSend(context, assistantId, options);\n return _updateAgentDeserialize(result);\n}\n\nexport function _getAgentSend(\n context: Client,\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _getAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Retrieves an existing agent. */\nexport async function getAgent(\n context: Client,\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _getAgentSend(context, assistantId, options);\n return _getAgentDeserialize(result);\n}\n\nexport function _listAgentsSend(\n context: Client,\n options: ListAgentsOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants{?api%2Dversion,limit,order,after,before}\",\n {\n \"api%2Dversion\": context.apiVersion,\n limit: options?.limit,\n order: options?.order,\n after: options?.after,\n before: options?.before,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _listAgentsDeserialize(\n result: PathUncheckedResponse,\n): Promise<_AgentsPagedResultAgent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return _agentsPagedResultAgentDeserializer(result.body);\n}\n\n/** Gets a list of agents that were previously created. */\nexport function listAgents(\n context: Client,\n options: ListAgentsOptionalParams = { requestOptions: {} },\n): PagedAsyncIterableIterator<Agent> {\n return buildPagedAsyncIterator(\n context,\n () => _listAgentsSend(context, options),\n _listAgentsDeserialize,\n [\"200\"],\n { itemName: \"data\" },\n );\n}\n\nexport function _createAgentSend(\n context: Client,\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants{?api%2Dversion}\",\n {\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n model: model,\n name: options?.name,\n description: options?.description,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : toolResourcesSerializer(options?.toolResources),\n temperature: options?.temperature,\n top_p: options?.topP,\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _createAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Creates a new agent. */\nexport async function createAgent(\n context: Client,\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _createAgentSend(context, model, options);\n return _createAgentDeserialize(result);\n}\nconst handlers = [\n { events: Object.values(ThreadStreamEvent) as string[] },\n { events: Object.values(RunStreamEvent) as string[] },\n { events: Object.values(RunStepStreamEvent) as string[] },\n { events: Object.values(MessageStreamEvent) as string[] },\n];\n\nfunction createAgentStream(stream: EventMessageStream): AgentEventMessageStream {\n const asyncIterator = toAsyncIterable(stream);\n const asyncDisposable = stream as AsyncDisposable;\n return Object.assign(asyncIterator, asyncDisposable);\n}\n\nasync function* toAsyncIterable(stream: EventMessageStream): AsyncIterable<AgentEventMessage> {\n for await (const event of stream) {\n const data = deserializeEventData(event);\n yield { data: data, event: event.event };\n }\n}\n\nfunction deserializeEventData(event: EventMessage): AgentEventStreamData {\n try {\n const jsonData = JSON.parse(event.data);\n switch (event.event) {\n case MessageStreamEvent.ThreadMessageDelta:\n return jsonData;\n case RunStepStreamEvent.ThreadRunStepDelta:\n return jsonData;\n default: {\n for (const { events } of handlers) {\n if (events.includes(event.event)) {\n return jsonData;\n }\n }\n\n return jsonData;\n }\n }\n } catch (ex) {\n logger.error(`Failed to parse event data ${event.event} - error: ${ex}`);\n return event.data;\n }\n}\n\nasync function processStream(streamResponse: StreamableMethod): Promise<AgentEventMessageStream> {\n const expectedStatuses = [\"200\"];\n const result = isNodeLike\n ? await streamResponse.asNodeStream()\n : await streamResponse.asBrowserStream();\n\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n if (!result.body) {\n throw new Error(\"No body in response\");\n }\n\n const stream = isNodeLike\n ? createSseStream(result.body as IncomingMessage)\n : createSseStream(result.body as ReadableStream);\n return createAgentStream(stream);\n}\n\n/** Create a run and stream the events */\nexport async function createRunStreaming(\n context: Client,\n assistantId: string,\n threadId: string,\n options: RunsCreateRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n options.stream = true;\n\n return processStream(_createRunSend(context, threadId, assistantId, options));\n}\n\n/** Create a thread and run and stream the events */\nexport async function createThreadAndRunStreaming(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n options.stream = true;\n return processStream(_createThreadAndRunSend(context, assistantId, options));\n}\n\nexport async function submitToolOutputsToRunStreaming(\n context: Client,\n threadId: string,\n runId: string,\n options: RunsSubmitToolOutputsToRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n options.stream = true;\n\n return processStream(\n context\n .path(\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\", threadId, runId)\n .post(options),\n );\n}\n"]}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MAAM,aAAa,mCAAQ,OAAO,KAAE,MAAM,EAAE,IAAI,GAAE,CAAC;IACnD,OAAO,aAAa,CAAC,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAAe,EACf,QAAgB,EAChB,KAAa,EACb,UAAoD,EAAE,cAAc,EAAE,EAAE,EAAE;IAE1E,MAAM,aAAa,mCAAQ,OAAO,KAAE,MAAM,EAAE,IAAI,GAAE,CAAC;IAEnD,OAAO,aAAa,CAClB,OAAO;SACJ,IAAI,CAAC,sDAAsD,EAAE,QAAQ,EAAE,KAAK,CAAC;SAC7E,IAAI,CAAC,aAAa,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AgentsContext as Client } from \"./index.js\";\nimport {\n toolResourcesSerializer,\n toolDefinitionUnionArraySerializer,\n agentsResponseFormatOptionSerializer,\n Agent,\n agentDeserializer,\n _AgentsPagedResultAgent,\n _agentsPagedResultAgentDeserializer,\n AgentDeletionStatus,\n agentDeletionStatusDeserializer,\n agentThreadCreationOptionsSerializer,\n updateToolResourcesOptionsSerializer,\n truncationObjectSerializer,\n agentsToolChoiceOptionSerializer,\n ThreadRun,\n threadRunDeserializer,\n} from \"../models/models.js\";\nimport {\n CreateThreadAndRunOptionalParams,\n DeleteAgentOptionalParams,\n UpdateAgentOptionalParams,\n GetAgentOptionalParams,\n ListAgentsOptionalParams,\n CreateAgentOptionalParams,\n} from \"./options.js\";\nimport {\n PagedAsyncIterableIterator,\n buildPagedAsyncIterator,\n} from \"../static-helpers/pagingHelpers.js\";\nimport { expandUrlTemplate } from \"../static-helpers/urlTemplate.js\";\nimport {\n StreamableMethod,\n PathUncheckedResponse,\n createRestError,\n operationOptionsToRequestParameters,\n} from \"@azure-rest/core-client\";\nimport {\n AgentEventMessage,\n AgentEventMessageStream,\n AgentEventStreamData,\n AgentRunResponse,\n MessageStreamEvent,\n RunStepStreamEvent,\n RunStreamEvent,\n ThreadStreamEvent,\n} from \"../models/streamingModels.js\";\nimport {\n RunsCreateRunOptionalParams,\n RunsSubmitToolOutputsToRunOptionalParams,\n} from \"./runs/options.js\";\nimport { EventMessageStream, EventMessage, createSseStream } from \"@azure/core-sse\";\nimport { isNodeLike } from \"@azure/core-util\";\nimport { IncomingMessage } from \"http\";\nimport { logger } from \"../logger.js\";\nimport { _createRunSend } from \"./runs/operations.js\";\n\nexport function _createThreadAndRunSend(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/threads/runs{?api%2Dversion}\",\n {\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n assistant_id: assistantId,\n thread: !options?.thread\n ? options?.thread\n : agentThreadCreationOptionsSerializer(options?.thread),\n model: options?.model,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : updateToolResourcesOptionsSerializer(options?.toolResources),\n stream: options?.stream,\n temperature: options?.temperature,\n top_p: options?.topP,\n max_prompt_tokens: options?.maxPromptTokens,\n max_completion_tokens: options?.maxCompletionTokens,\n truncation_strategy: !options?.truncationStrategy\n ? options?.truncationStrategy\n : truncationObjectSerializer(options?.truncationStrategy),\n tool_choice: !options?.toolChoice\n ? options?.toolChoice\n : agentsToolChoiceOptionSerializer(options?.toolChoice),\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n parallel_tool_calls: options?.parallelToolCalls,\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _createThreadAndRunDeserialize(\n result: PathUncheckedResponse,\n): Promise<ThreadRun> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return threadRunDeserializer(result.body);\n}\n\n/** Creates a new agent thread and immediately starts a run using that new thread. */\nexport function createThreadAndRun(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): AgentRunResponse {\n async function executeCreateThreadAndRun(): Promise<ThreadRun> {\n const result = await _createThreadAndRunSend(context, assistantId, options);\n return _createThreadAndRunDeserialize(result);\n }\n\n return {\n then: function (onFulfilled, onRejected) {\n return executeCreateThreadAndRun().then(onFulfilled, onRejected).catch(onRejected);\n },\n async stream(): Promise<AgentEventMessageStream> {\n return createThreadAndRunStreaming(context, assistantId, options);\n },\n };\n}\n\nexport function _deleteAgentSend(\n context: Client,\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).delete({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _deleteAgentDeserialize(\n result: PathUncheckedResponse,\n): Promise<AgentDeletionStatus> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeletionStatusDeserializer(result.body);\n}\n\n/** Deletes an agent. */\nexport async function deleteAgent(\n context: Client,\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n): Promise<AgentDeletionStatus> {\n const result = await _deleteAgentSend(context, assistantId, options);\n return _deleteAgentDeserialize(result);\n}\n\nexport function _updateAgentSend(\n context: Client,\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n model: options?.model,\n name: options?.name,\n description: options?.description,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : toolResourcesSerializer(options?.toolResources),\n temperature: options?.temperature,\n top_p: options?.topP,\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _updateAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Modifies an existing agent. */\nexport async function updateAgent(\n context: Client,\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _updateAgentSend(context, assistantId, options);\n return _updateAgentDeserialize(result);\n}\n\nexport function _getAgentSend(\n context: Client,\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants/{assistantId}{?api%2Dversion}\",\n {\n assistantId: assistantId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _getAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Retrieves an existing agent. */\nexport async function getAgent(\n context: Client,\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _getAgentSend(context, assistantId, options);\n return _getAgentDeserialize(result);\n}\n\nexport function _listAgentsSend(\n context: Client,\n options: ListAgentsOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants{?api%2Dversion,limit,order,after,before}\",\n {\n \"api%2Dversion\": context.apiVersion,\n limit: options?.limit,\n order: options?.order,\n after: options?.after,\n before: options?.before,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _listAgentsDeserialize(\n result: PathUncheckedResponse,\n): Promise<_AgentsPagedResultAgent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return _agentsPagedResultAgentDeserializer(result.body);\n}\n\n/** Gets a list of agents that were previously created. */\nexport function listAgents(\n context: Client,\n options: ListAgentsOptionalParams = { requestOptions: {} },\n): PagedAsyncIterableIterator<Agent> {\n return buildPagedAsyncIterator(\n context,\n () => _listAgentsSend(context, options),\n _listAgentsDeserialize,\n [\"200\"],\n { itemName: \"data\" },\n );\n}\n\nexport function _createAgentSend(\n context: Client,\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/assistants{?api%2Dversion}\",\n {\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"application/json\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: {\n model: model,\n name: options?.name,\n description: options?.description,\n instructions: options?.instructions,\n tools: !options?.tools ? options?.tools : toolDefinitionUnionArraySerializer(options?.tools),\n tool_resources: !options?.toolResources\n ? options?.toolResources\n : toolResourcesSerializer(options?.toolResources),\n temperature: options?.temperature,\n top_p: options?.topP,\n response_format: !options?.responseFormat\n ? options?.responseFormat\n : agentsResponseFormatOptionSerializer(options?.responseFormat),\n metadata: options?.metadata,\n },\n });\n}\n\nexport async function _createAgentDeserialize(result: PathUncheckedResponse): Promise<Agent> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n\n return agentDeserializer(result.body);\n}\n\n/** Creates a new agent. */\nexport async function createAgent(\n context: Client,\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n): Promise<Agent> {\n const result = await _createAgentSend(context, model, options);\n return _createAgentDeserialize(result);\n}\nconst handlers = [\n { events: Object.values(ThreadStreamEvent) as string[] },\n { events: Object.values(RunStreamEvent) as string[] },\n { events: Object.values(RunStepStreamEvent) as string[] },\n { events: Object.values(MessageStreamEvent) as string[] },\n];\n\nfunction createAgentStream(stream: EventMessageStream): AgentEventMessageStream {\n const asyncIterator = toAsyncIterable(stream);\n const asyncDisposable = stream as AsyncDisposable;\n return Object.assign(asyncIterator, asyncDisposable);\n}\n\nasync function* toAsyncIterable(stream: EventMessageStream): AsyncIterable<AgentEventMessage> {\n for await (const event of stream) {\n const data = deserializeEventData(event);\n yield { data: data, event: event.event };\n }\n}\n\nfunction deserializeEventData(event: EventMessage): AgentEventStreamData {\n try {\n const jsonData = JSON.parse(event.data);\n switch (event.event) {\n case MessageStreamEvent.ThreadMessageDelta:\n return jsonData;\n case RunStepStreamEvent.ThreadRunStepDelta:\n return jsonData;\n default: {\n for (const { events } of handlers) {\n if (events.includes(event.event)) {\n return jsonData;\n }\n }\n\n return jsonData;\n }\n }\n } catch (ex) {\n logger.error(`Failed to parse event data ${event.event} - error: ${ex}`);\n return event.data;\n }\n}\n\nasync function processStream(streamResponse: StreamableMethod): Promise<AgentEventMessageStream> {\n const expectedStatuses = [\"200\"];\n const result = isNodeLike\n ? await streamResponse.asNodeStream()\n : await streamResponse.asBrowserStream();\n\n if (!expectedStatuses.includes(result.status)) {\n throw createRestError(result);\n }\n if (!result.body) {\n throw new Error(\"No body in response\");\n }\n\n const stream = isNodeLike\n ? createSseStream(result.body as IncomingMessage)\n : createSseStream(result.body as ReadableStream);\n return createAgentStream(stream);\n}\n\n/** Create a run and stream the events */\nexport async function createRunStreaming(\n context: Client,\n assistantId: string,\n threadId: string,\n options: RunsCreateRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n const streamOptions = { ...options, stream: true };\n\n return processStream(_createRunSend(context, threadId, assistantId, streamOptions));\n}\n\n/** Create a thread and run and stream the events */\nexport async function createThreadAndRunStreaming(\n context: Client,\n assistantId: string,\n options: CreateThreadAndRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n const streamOptions = { ...options, stream: true };\n return processStream(_createThreadAndRunSend(context, assistantId, streamOptions));\n}\n\nexport async function submitToolOutputsToRunStreaming(\n context: Client,\n threadId: string,\n runId: string,\n options: RunsSubmitToolOutputsToRunOptionalParams = { requestOptions: {} },\n): Promise<AgentEventMessageStream> {\n const streamOptions = { ...options, stream: true };\n\n return processStream(\n context\n .path(\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\", threadId, runId)\n .post(streamOptions),\n );\n}\n"]}
|
package/dist/esm/api/poller.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type PollerLike, type OperationState, type OperationStatus } from "@azure/core-lro";
|
|
2
|
+
/**
|
|
3
|
+
* Deserializes the state from a serialized string
|
|
4
|
+
*/
|
|
5
|
+
export declare function deserializeState<T>(serializedState: string): OperationState<T>;
|
|
6
|
+
export declare function createPoller<T>({ initOperation, pollOperation, getOperationStatus, getOperationError, intervalInMs, resumeFrom, }: {
|
|
3
7
|
initOperation: () => Promise<T>;
|
|
4
8
|
pollOperation: (currentResult: T) => Promise<T>;
|
|
5
9
|
getOperationStatus: (result: T) => OperationStatus;
|
|
6
10
|
getOperationError?: (result: T) => Error | undefined;
|
|
7
11
|
intervalInMs?: number;
|
|
12
|
+
resumeFrom?: string;
|
|
8
13
|
}): PollerLike<OperationState<T>, T>;
|
|
9
14
|
//# sourceMappingURL=poller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../../src/api/poller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../../src/api/poller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAK7F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAM9E;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,UAAU,GACX,EAAE;IACD,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAChC,aAAa,EAAE,CAAC,aAAa,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,kBAAkB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,eAAe,CAAC;IACnD,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,KAAK,GAAG,SAAS,CAAC;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAwJnC"}
|
package/dist/esm/api/poller.js
CHANGED
|
@@ -2,15 +2,33 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { delay } from "@azure/core-util";
|
|
4
4
|
const DEFAULT_POLL_INTERVAL_IN_MS = 1000;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Deserializes the state from a serialized string
|
|
7
|
+
*/
|
|
8
|
+
export function deserializeState(serializedState) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(serializedState).state;
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
throw new Error(`Unable to deserialize input state: ${serializedState}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function createPoller({ initOperation, pollOperation, getOperationStatus, getOperationError, intervalInMs, resumeFrom, }) {
|
|
17
|
+
let statePromise;
|
|
6
18
|
let state;
|
|
7
|
-
|
|
8
|
-
state =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
if (resumeFrom) {
|
|
20
|
+
state = deserializeState(resumeFrom);
|
|
21
|
+
statePromise = Promise.resolve(state);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
statePromise = initOperation().then((result) => {
|
|
25
|
+
state = {
|
|
26
|
+
result,
|
|
27
|
+
status: getOperationStatus(result),
|
|
28
|
+
};
|
|
29
|
+
return state;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
14
32
|
let resultPromise;
|
|
15
33
|
const abortController = new AbortController();
|
|
16
34
|
const handlers = new Map();
|
|
@@ -91,7 +109,7 @@ export function createPoller({ initOperation, pollOperation, getOperationStatus,
|
|
|
91
109
|
var _a, _b, _c;
|
|
92
110
|
// Check state before polling
|
|
93
111
|
await statePromise;
|
|
94
|
-
if (!state
|
|
112
|
+
if (!state) {
|
|
95
113
|
throw new Error("Poller is not initialized");
|
|
96
114
|
}
|
|
97
115
|
switch (state.status) {
|
|
@@ -106,6 +124,10 @@ export function createPoller({ initOperation, pollOperation, getOperationStatus,
|
|
|
106
124
|
if ((_b = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal) === null || _b === void 0 ? void 0 : _b.aborted) {
|
|
107
125
|
throw new Error("Operation aborted");
|
|
108
126
|
}
|
|
127
|
+
// Make sure we have a result to poll with
|
|
128
|
+
if (!state.result) {
|
|
129
|
+
throw new Error("Cannot poll with undefined result");
|
|
130
|
+
}
|
|
109
131
|
const result = await pollOperation(state.result);
|
|
110
132
|
state = {
|
|
111
133
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../src/api/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC,MAAM,UAAU,YAAY,CAAI,EAC9B,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GAOb;IACC,IAAI,KAAwB,CAAC;IAC7B,MAAM,YAAY,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACnD,KAAK,GAAG;YACN,MAAM;YACN,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;SACnC,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,aAAqC,CAAC;IAC1C,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAE9C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5C,MAAM,oBAAoB,GAAG,KAAK,IAAmB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1F,MAAM,uBAAuB,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,2BAA2B,CAAC;IAE5E,MAAM,MAAM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C,CAAC;YACvD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CACH,UAAuE;YAEvE,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,CAAC,SAA2C;YACjD,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QACD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ;KAC/B,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { delay } from \"@azure/core-util\";\nimport type { PollerLike, OperationState, OperationStatus } from \"@azure/core-lro\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nconst DEFAULT_POLL_INTERVAL_IN_MS = 1000;\n\nexport function createPoller<T>({\n initOperation,\n pollOperation,\n getOperationStatus,\n getOperationError,\n intervalInMs,\n}: {\n initOperation: () => Promise<T>;\n pollOperation: (currentResult: T) => Promise<T>;\n getOperationStatus: (result: T) => OperationStatus;\n getOperationError?: (result: T) => Error | undefined;\n intervalInMs?: number;\n}): PollerLike<OperationState<T>, T> {\n let state: OperationState<T>;\n const statePromise = initOperation().then((result) => {\n state = {\n result,\n status: getOperationStatus(result),\n };\n return state;\n });\n\n let resultPromise: Promise<T> | undefined;\n const abortController = new AbortController();\n type Handler = (state: OperationState<T>) => void;\n const handlers = new Map<symbol, Handler>();\n const handleProgressEvents = async (): Promise<void> => handlers.forEach((h) => h(state));\n const currentPollIntervalInMs = intervalInMs ?? DEFAULT_POLL_INTERVAL_IN_MS;\n\n const poller: PollerLike<OperationState<T>, T> = {\n get operationState(): OperationState<T> | undefined {\n return state;\n },\n get result(): T | undefined {\n return state?.result;\n },\n get isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state?.status ?? \"\");\n },\n onProgress: (callback: (state: OperationState<T>) => void) => {\n const s = Symbol();\n handlers.set(s, callback);\n return () => handlers.delete(s);\n },\n serialize: async () => {\n await statePromise;\n return JSON.stringify({\n state,\n });\n },\n submitted: async () => {\n await statePromise;\n },\n pollUntilDone: async (pollOptions?: { abortSignal?: AbortSignalLike }) => {\n resultPromise ??= (async () => {\n await statePromise;\n if (!state) {\n throw new Error(\"Poller is not initialized\");\n }\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n function abortListener(): void {\n abortController.abort();\n }\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, { once: true });\n }\n\n try {\n if (!poller.isDone) {\n await poller.poll({ abortSignal });\n while (!poller.isDone) {\n await delay(currentPollIntervalInMs, { abortSignal });\n await poller.poll({ abortSignal });\n }\n }\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n switch (state.status) {\n case \"succeeded\":\n return poller.result as T;\n case \"canceled\":\n throw new Error(\"Operation cancelled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n case \"notStarted\":\n case \"running\":\n throw new Error(\"Polling completed without succeeding or failing\");\n }\n })().finally(() => {\n resultPromise = undefined;\n });\n return resultPromise;\n },\n\n async poll(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<OperationState<T>> {\n // Check state before polling\n await statePromise;\n if (!state || !state.result) {\n throw new Error(\"Poller is not initialized\");\n }\n switch (state.status) {\n case \"succeeded\":\n return state;\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n }\n\n // Poll\n if (pollOptions?.abortSignal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n const result = await pollOperation(state.result);\n state = {\n result,\n status: getOperationStatus(result),\n error: getOperationError ? getOperationError(result) : undefined,\n };\n\n await handleProgressEvents();\n switch (state.status) {\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n }\n return state;\n },\n\n then<T1 = T, T2 = never>(\n onfulfilled?: ((value: T) => T1 | PromiseLike<T1>) | undefined | null,\n onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | undefined | null,\n ): Promise<T1 | T2> {\n return poller.pollUntilDone().then(onfulfilled, onrejected);\n },\n catch<T2 = never>(\n onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | undefined | null,\n ): Promise<T | T2> {\n return poller.pollUntilDone().catch(onrejected);\n },\n finally(onfinally?: (() => void) | undefined | null): Promise<T> {\n return poller.pollUntilDone().finally(onfinally);\n },\n [Symbol.toStringTag]: \"Poller\",\n };\n return poller;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../src/api/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,eAAuB;IACzD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,sCAAsC,eAAe,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,EAC9B,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,UAAU,GAQX;IACC,IAAI,YAAwC,CAAC;IAC7C,IAAI,KAAwB,CAAC;IAE7B,IAAI,UAAU,EAAE,CAAC;QAC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AAC,WAAW,CAAC,EAAE,QAAQ;KAC/B,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { delay } from \"@azure/core-util\";\nimport { type PollerLike, type OperationState, type OperationStatus } from \"@azure/core-lro\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nconst DEFAULT_POLL_INTERVAL_IN_MS = 1000;\n\n/**\n * Deserializes the state from a serialized string\n */\nexport function deserializeState<T>(serializedState: string): OperationState<T> {\n try {\n return JSON.parse(serializedState).state;\n } catch (e) {\n throw new Error(`Unable to deserialize input state: ${serializedState}`);\n }\n}\n\nexport function createPoller<T>({\n initOperation,\n pollOperation,\n getOperationStatus,\n getOperationError,\n intervalInMs,\n resumeFrom,\n}: {\n initOperation: () => Promise<T>;\n pollOperation: (currentResult: T) => Promise<T>;\n getOperationStatus: (result: T) => OperationStatus;\n getOperationError?: (result: T) => Error | undefined;\n intervalInMs?: number;\n resumeFrom?: string;\n}): PollerLike<OperationState<T>, T> {\n let statePromise: Promise<OperationState<T>>;\n let state: OperationState<T>;\n\n if (resumeFrom) {\n state = deserializeState<T>(resumeFrom);\n statePromise = Promise.resolve(state);\n } else {\n statePromise = initOperation().then((result) => {\n state = {\n result,\n status: getOperationStatus(result),\n };\n return state;\n });\n }\n\n let resultPromise: Promise<T> | undefined;\n const abortController = new AbortController();\n type Handler = (state: OperationState<T>) => void;\n const handlers = new Map<symbol, Handler>();\n const handleProgressEvents = async (): Promise<void> => handlers.forEach((h) => h(state));\n const currentPollIntervalInMs = intervalInMs ?? DEFAULT_POLL_INTERVAL_IN_MS;\n\n const poller: PollerLike<OperationState<T>, T> = {\n get operationState(): OperationState<T> | undefined {\n return state;\n },\n get result(): T | undefined {\n return state?.result;\n },\n get isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state?.status ?? \"\");\n },\n onProgress: (callback: (state: OperationState<T>) => void) => {\n const s = Symbol();\n handlers.set(s, callback);\n return () => handlers.delete(s);\n },\n serialize: async () => {\n await statePromise;\n return JSON.stringify({\n state,\n });\n },\n submitted: async () => {\n await statePromise;\n },\n pollUntilDone: async (pollOptions?: { abortSignal?: AbortSignalLike }) => {\n resultPromise ??= (async () => {\n await statePromise;\n if (!state) {\n throw new Error(\"Poller is not initialized\");\n }\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n function abortListener(): void {\n abortController.abort();\n }\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, { once: true });\n }\n\n try {\n if (!poller.isDone) {\n await poller.poll({ abortSignal });\n while (!poller.isDone) {\n await delay(currentPollIntervalInMs, { abortSignal });\n await poller.poll({ abortSignal });\n }\n }\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n switch (state.status) {\n case \"succeeded\":\n return poller.result as T;\n case \"canceled\":\n throw new Error(\"Operation cancelled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n case \"notStarted\":\n case \"running\":\n throw new Error(\"Polling completed without succeeding or failing\");\n }\n })().finally(() => {\n resultPromise = undefined;\n });\n return resultPromise;\n },\n\n async poll(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<OperationState<T>> {\n // Check state before polling\n await statePromise;\n if (!state) {\n throw new Error(\"Poller is not initialized\");\n }\n switch (state.status) {\n case \"succeeded\":\n return state;\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n }\n\n // Poll\n if (pollOptions?.abortSignal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n\n // Make sure we have a result to poll with\n if (!state.result) {\n throw new Error(\"Cannot poll with undefined result\");\n }\n\n const result = await pollOperation(state.result);\n state = {\n result,\n status: getOperationStatus(result),\n error: getOperationError ? getOperationError(result) : undefined,\n };\n\n await handleProgressEvents();\n switch (state.status) {\n case \"canceled\":\n throw new Error(\"Operation was canceled\");\n case \"failed\":\n throw state.error ?? new Error(\"Operation failed\");\n }\n return state;\n },\n\n then<T1 = T, T2 = never>(\n onfulfilled?: ((value: T) => T1 | PromiseLike<T1>) | undefined | null,\n onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | undefined | null,\n ): Promise<T1 | T2> {\n return poller.pollUntilDone().then(onfulfilled, onrejected);\n },\n catch<T2 = never>(\n onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | undefined | null,\n ): Promise<T | T2> {\n return poller.pollUntilDone().catch(onrejected);\n },\n finally(onfinally?: (() => void) | undefined | null): Promise<T> {\n return poller.pollUntilDone().finally(onfinally);\n },\n [Symbol.toStringTag]: \"Poller\",\n };\n return poller;\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AgentsContext as Client } from "../index.js";
|
|
2
|
-
import { ThreadRun, _AgentsPagedResultThreadRun, ToolOutput } from "../../models/models.js";
|
|
3
|
-
import { RunsCancelRunOptionalParams, RunsSubmitToolOutputsToRunOptionalParams, RunsUpdateRunOptionalParams, RunsGetRunOptionalParams, RunsListRunsOptionalParams, RunsCreateRunOptionalParams } from "./options.js";
|
|
4
|
-
import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js";
|
|
5
|
-
import { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client";
|
|
6
|
-
import { AgentRunResponse } from "../../models/streamingModels.js";
|
|
1
|
+
import type { AgentsContext as Client } from "../index.js";
|
|
2
|
+
import type { ThreadRun, _AgentsPagedResultThreadRun, ToolOutput } from "../../models/models.js";
|
|
3
|
+
import type { RunsCancelRunOptionalParams, RunsSubmitToolOutputsToRunOptionalParams, RunsUpdateRunOptionalParams, RunsGetRunOptionalParams, RunsListRunsOptionalParams, RunsCreateRunOptionalParams } from "./options.js";
|
|
4
|
+
import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js";
|
|
5
|
+
import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client";
|
|
6
|
+
import type { AgentRunResponse } from "../../models/streamingModels.js";
|
|
7
|
+
import type { OperationState, PollerLike } from "@azure/core-lro";
|
|
7
8
|
export declare function _cancelRunSend(context: Client, threadId: string, runId: string, options?: RunsCancelRunOptionalParams): StreamableMethod;
|
|
8
9
|
export declare function _cancelRunDeserialize(result: PathUncheckedResponse): Promise<ThreadRun>;
|
|
9
10
|
/** Cancels a run of an in‐progress thread. */
|
|
@@ -11,7 +12,7 @@ export declare function cancelRun(context: Client, threadId: string, runId: stri
|
|
|
11
12
|
export declare function _submitToolOutputsToRunSend(context: Client, threadId: string, runId: string, toolOutputs: ToolOutput[], options?: RunsSubmitToolOutputsToRunOptionalParams): StreamableMethod;
|
|
12
13
|
export declare function _submitToolOutputsToRunDeserialize(result: PathUncheckedResponse): Promise<ThreadRun>;
|
|
13
14
|
/** Submits outputs from tools as requested by tool calls in a run. */
|
|
14
|
-
export declare function submitToolOutputsToRun(context: Client, threadId: string, runId: string, toolOutputs: ToolOutput[], options?: RunsSubmitToolOutputsToRunOptionalParams):
|
|
15
|
+
export declare function submitToolOutputsToRun(context: Client, threadId: string, runId: string, toolOutputs: ToolOutput[], options?: RunsSubmitToolOutputsToRunOptionalParams): AgentRunResponse;
|
|
15
16
|
export declare function _updateRunSend(context: Client, threadId: string, runId: string, options?: RunsUpdateRunOptionalParams): StreamableMethod;
|
|
16
17
|
export declare function _updateRunDeserialize(result: PathUncheckedResponse): Promise<ThreadRun>;
|
|
17
18
|
/** Modifies an existing thread run. */
|
|
@@ -28,4 +29,5 @@ export declare function _createRunSend(context: Client, threadId: string, assist
|
|
|
28
29
|
export declare function _createRunDeserialize(result: PathUncheckedResponse): Promise<ThreadRun>;
|
|
29
30
|
/** Creates a new run for an agent thread. */
|
|
30
31
|
export declare function createRun(context: Client, threadId: string, assistantId: string, options?: RunsCreateRunOptionalParams): AgentRunResponse;
|
|
32
|
+
export declare function createRunAndPoll(context: Client, threadId: string, assistantId: string, options?: RunsCreateRunOptionalParams): PollerLike<OperationState<ThreadRun>, ThreadRun>;
|
|
31
33
|
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../../src/api/runs/operations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../../src/api/runs/operations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,2BAA2B,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWjG,OAAO,KAAK,EACV,2BAA2B,EAC3B,wCAAwC,EACxC,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAGxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEvF,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,iCAAiC,CAAC;AAEjG,OAAO,KAAK,EAAE,cAAc,EAAmB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGnF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,2BAAoD,GAC5D,gBAAgB,CAmBlB;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC,CAO7F;AAED,8CAA8C;AAC9C,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,M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