mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-19 18:43:34 -04:00
feat: add azure interpreter tool to tool factory (#1064)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user