UNPKG

adk-typescript

Version:

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

31 lines (30 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requestProcessor = void 0; /** * Gives the agent identity from the framework. */ class IdentityLlmRequestProcessor { /** * Runs the processor asynchronously. * * @param invocationContext The invocation context * @param llmRequest The LLM request to process * @returns An async generator yielding events */ async *runAsync(invocationContext, llmRequest) { const agent = invocationContext.agent; const instructions = [`You are an agent. Your internal name is "${agent.name}".`]; if (agent.description) { instructions.push(` The description about you is "${agent.description}"`); } llmRequest.appendInstructions(instructions); // This is a proper way to maintain the AsyncGenerator contract without actually yielding anything // The condition is always false, but TypeScript doesn't flag this specific pattern as an error if (Math.random() < 0) { yield {}; } } } // Export the processor instance exports.requestProcessor = new IdentityLlmRequestProcessor();