UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

95 lines 2.89 kB
/** * LiteAgent Implementation * A lightweight, performance-optimized agent implementation that focuses on minimal resource usage */ import { BaseAgent, AgentConfig, TaskExecutionResult } from './BaseAgent.js'; import { BaseTool } from '../tools/BaseTool.js'; import { Task } from '../task/Task.js'; /** * LiteAgent configuration options * Extends AgentConfig with optimization options specific to LiteAgent */ export interface LiteAgentConfig extends AgentConfig { /** * Maximum cache size for task results * @default 100 */ maxCacheSize?: number; /** * Whether to enable response caching by task hash * @default true */ enableCaching?: boolean; /** * Timeout for task execution in milliseconds * @default 60000 (1 minute) */ executionTimeout?: number; } /** * A lightweight agent implementation optimized for memory efficiency and performance. * Implements the BaseAgent interface with minimal resource usage and simpler execution patterns. */ export declare class LiteAgent implements BaseAgent { readonly id: string; readonly role: string; readonly goal: string; readonly backstory?: string; private _llm?; private _functionCallingLlm?; private _tools; private _verbose; private _allowDelegation; private _maxIterations; private _maxCacheSize; private _enableCaching; private _executionTimeout; private _useSystemPrompt; private _systemPrompt?; private _resultCache; /** * Create a new LiteAgent instance * @param config Configuration for the agent */ constructor(config: LiteAgentConfig); /** * Execute a task with this agent * @param task Task to execute * @param context Additional context for the task * @param tools Optional tools for the task * @returns Promise resolving to TaskExecutionResult */ executeTask(task: Task, context?: string, tools?: BaseTool[]): Promise<TaskExecutionResult>; /** * Get tools for delegating tasks to other agents * @param agents Agents that can be delegated to * @returns Array of BaseTool instances for delegation */ getDelegationTools(agents: BaseAgent[]): BaseTool[]; /** * Set knowledge for the agent * @param knowledge Knowledge sources or embeddings */ setKnowledge(knowledge: unknown): Promise<void>; /** * Create a hash for the task, context, and tools for caching purposes * @private */ private _hashTask; /** * Add a result to the cache, managing cache size * @private */ private _addToCache; /** * Create a prompt for the task * @private */ private _createTaskPrompt; /** * Execute the task with the LLM * @private */ private _executeTaskWithLLM; } //# sourceMappingURL=LiteAgent.d.ts.map