adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
86 lines (85 loc) • 2.62 kB
TypeScript
/**
* A code executor that uses Vertex AI Code Interpreter Extension to execute code.
*/
import { InvocationContext } from "../agents/InvocationContext";
import { BaseCodeExecutor } from "./baseCodeExecutor";
import { CodeExecutionInput, CodeExecutionResult } from "./codeExecutionUtils";
interface Extension {
execute(options: {
operationId: string;
operationParams: Record<string, any>;
}): Promise<any>;
gcaResource?: {
name: string;
};
}
interface ExtensionFactory {
fromHub(extensionId: string): Extension;
}
/**
* Options for initializing a VertexAiCodeExecutor
*/
export interface VertexAiCodeExecutorOptions {
/**
* If set, load the existing resource name of the code interpreter extension
* instead of creating a new one.
* Format: projects/123/locations/us-central1/extensions/456
*/
resourceName?: string;
/**
* The Vertex AI extension client to use
*/
extensionClient?: ExtensionFactory;
/**
* Other BaseCodeExecutor options
*/
stateful?: boolean;
optimizeDataFile?: boolean;
errorRetryAttempts?: number;
codeBlockDelimiters?: [string, string][];
executionResultDelimiters?: [string, string];
}
/**
* A code executor that uses Vertex AI Code Interpreter Extension to execute code.
*/
export declare class VertexAiCodeExecutor extends BaseCodeExecutor {
/**
* If set, load the existing resource name of the code interpreter extension
* instead of creating a new one.
* Format: projects/123/locations/us-central1/extensions/456
*/
resourceName?: string;
/**
* The Vertex AI extension client
*/
private extensionClient?;
/**
* The code interpreter extension
*/
private codeInterpreterExtension?;
/**
* Initializes the VertexAiCodeExecutor.
*/
constructor(options?: VertexAiCodeExecutorOptions);
/**
* Initialize the code interpreter extension
*/
private initializeExtension;
/**
* Executes code and returns the code execution result.
*
* @param invocationContext - The invocation context of the code execution.
* @param codeExecutionInput - The code execution input.
* @returns The code execution result.
*/
executeCode(invocationContext: InvocationContext, codeExecutionInput: CodeExecutionInput): Promise<CodeExecutionResult>;
/**
* Executes the code interpreter extension.
*/
private executeCodeInterpreter;
/**
* Builds the code string with built-in imports.
*/
private getCodeWithImports;
}
export {};