UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

90 lines (89 loc) 4.08 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SingleFlow = void 0; const BaseLlmFlow_1 = require("./BaseLlmFlow"); const basic = __importStar(require("./basic")); const identity = __importStar(require("./identity")); const instructions = __importStar(require("./instructions")); const contents = __importStar(require("./contents")); const nlPlanning = __importStar(require("./NlPlanning")); const codeExecution = __importStar(require("./CodeExecution")); /** * A simple flow that only executes one LLM call. * * This is the TypeScript equivalent of the Python SingleFlow implementation, * which automatically includes several request and response processors. */ class SingleFlow extends BaseLlmFlow_1.BaseLlmFlow { /** * Constructs a new SingleFlow with the given request processors. * * @param additionalRequestProcessors Additional request processors to use * @param additionalResponseProcessors Additional response processors to use */ constructor(additionalRequestProcessors = [], additionalResponseProcessors = []) { super(); // Initialize with default request processors (matching Python implementation) this.requestProcessors = [ basic.requestProcessor, // Adds user content // auth_preprocessor.requestProcessor is not included in TS implementation yet instructions.requestProcessor, // Adds agent instructions identity.requestProcessor, // Adds agent identity contents.requestProcessor, // Adds content // Some implementations of NL Planning mark planning contents as thoughts // in the post processor. Since these need to be unmarked, NL Planning // should be after contents. nlPlanning.requestProcessor, // Adds NL planning // Code execution should be after the contents as it mutates the contents // to optimize data files. codeExecution.requestProcessor // Adds code execution ]; // Initialize response processors (matching Python implementation) this.responseProcessors = [ nlPlanning.responseProcessor, // Processes NL planning codeExecution.responseProcessor // Processes code execution ]; // Add any additional request processors if (additionalRequestProcessors.length > 0) { this.requestProcessors.push(...additionalRequestProcessors); } // Add any additional response processors if (additionalResponseProcessors.length > 0) { this.responseProcessors.push(...additionalResponseProcessors); } } } exports.SingleFlow = SingleFlow;