diff --git a/.changeset/tasty-seahorses-sit.md b/.changeset/tasty-seahorses-sit.md new file mode 100644 index 0000000000000000000000000000000000000000..259d33d334f0d4642b353689f7764b4d0fb9e0d5 --- /dev/null +++ b/.changeset/tasty-seahorses-sit.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +Add azure interpreter tool to tool factory diff --git a/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts b/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts index aaf6bb7c58f5d32a1bdbc19371cc6d6149f45114..c83c362b5dcaa81cf8c2e28b3c44f912139d6d4a 100644 --- a/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts +++ b/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts @@ -177,7 +177,7 @@ export class AzureDynamicSessionTool /** * The endpoint of the Azure pool management service. * This is where the tool will send requests to interact with the session pool. - * If not provided, the tool will use the value of the `AZURE_CONTAINER_APP_SESSION_POOL_MANAGEMENT_ENDPOINT` environment variable. + * If not provided, the tool will use the value of the `AZURE_POOL_MANAGEMENT_ENDPOINT` environment variable. */ private poolManagementEndpoint: string; @@ -191,14 +191,12 @@ export class AzureDynamicSessionTool this.sessionId = params?.sessionId || randomUUID(); this.poolManagementEndpoint = params?.poolManagementEndpoint || - (getEnv("AZURE_CONTAINER_APP_SESSION_POOL_MANAGEMENT_ENDPOINT") ?? ""); + (getEnv("AZURE_POOL_MANAGEMENT_ENDPOINT") ?? ""); this.azureADTokenProvider = params?.azureADTokenProvider ?? getAzureADTokenProvider(); if (!this.poolManagementEndpoint) { - throw new Error( - "AZURE_CONTAINER_APP_SESSION_POOL_MANAGEMENT_ENDPOINT must be defined.", - ); + throw new Error("AZURE_POOL_MANAGEMENT_ENDPOINT must be defined."); } } diff --git a/packages/llamaindex/src/tools/ToolsFactory.ts b/packages/llamaindex/src/tools/ToolsFactory.ts index eb650463f24672f66c55b5f33a230fb9e584706d..791ee84569120a1b9eca3730809b054e897d1ba5 100644 --- a/packages/llamaindex/src/tools/ToolsFactory.ts +++ b/packages/llamaindex/src/tools/ToolsFactory.ts @@ -1,12 +1,18 @@ -import { WikipediaTool } from "./WikipediaTool.js"; +import { + AzureDynamicSessionTool, + type AzureDynamicSessionToolParams, +} from "./AzureDynamicSessionTool.node.js"; +import { WikipediaTool, type WikipediaToolParams } from "./WikipediaTool.js"; export namespace ToolsFactory { type ToolsMap = { [Tools.Wikipedia]: typeof WikipediaTool; + [Tools.AzureCodeInterpreter]: typeof AzureDynamicSessionTool; }; export enum Tools { Wikipedia = "wikipedia.WikipediaToolSpec", + AzureCodeInterpreter = "azure_code_interpreter.AzureCodeInterpreterToolSpec", } export async function createTool<Tool extends Tools>( @@ -14,7 +20,15 @@ export namespace ToolsFactory { ...params: ConstructorParameters<ToolsMap[Tool]> ): Promise<InstanceType<ToolsMap[Tool]>> { if (key === Tools.Wikipedia) { - return new WikipediaTool(...params) as InstanceType<ToolsMap[Tool]>; + return new WikipediaTool( + ...(params as WikipediaToolParams[]), + ) as InstanceType<ToolsMap[Tool]>; + } + + if (key === Tools.AzureCodeInterpreter) { + return new AzureDynamicSessionTool( + ...(params as AzureDynamicSessionToolParams[]), + ) as InstanceType<ToolsMap[Tool]>; } throw new Error(