Skip to content
Snippets Groups Projects
Unverified Commit d917cdc3 authored by Thuc Pham's avatar Thuc Pham Committed by GitHub
Browse files

feat: add azure interpreter tool to tool factory (#1064)

parent b370edf3
No related branches found
No related tags found
No related merge requests found
---
"llamaindex": patch
---
Add azure interpreter tool to tool factory
......@@ -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.");
}
}
......
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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment