UNPKG

jorel

Version:

A unified wrapper for working with LLMs from multiple providers, including streams, images, documents & automatic tool use.

112 lines (111 loc) 3.54 kB
import { CreateLlmDocument, LlmDocument, LlmDocumentCollection, LlmTool } from "../index"; import { Nullable } from "../shared"; import { JorElAgentManager } from "../jorel/jorel.team"; /** * Agent-specific error */ export declare class AgentError extends Error { readonly agentName: string; constructor(message: string, agentName: string); } export interface LlmAgentDefinition { name: string; description: string; systemMessageTemplate: string; delegateTemplate?: string; documents?: (LlmDocument | CreateLlmDocument)[] | LlmDocumentCollection; model?: string; allowedTools?: string[]; canDelegateTo?: string[]; canTransferTo?: string[]; responseType?: "text" | "json"; temperature?: number; } /** * Represents an agent that can process requests, consider documents, * delegate to other agents, and use tools. */ export declare class LlmAgent { readonly name: string; description: string; model: Nullable<string>; systemMessageTemplate: string; delegateTemplate: string; documents: LlmDocumentCollection; responseType: "text" | "json"; temperature: number; /** * Creates a new LLM Agent * @param agentDefinition - The configuration for this agent * @param jorEl - The agent manager instance * @throws {AgentError} If the agent configuration is invalid */ constructor(agentDefinition: LlmAgentDefinition, jorEl: JorElAgentManager); /** * Get the list of tools that this agent can use */ get allowedToolNames(): string[]; /** * Get the list of agent names that this agent can delegate to */ get allowedDelegateNames(): string[]; /** * Get the list of agent names that this agent can transfer to */ get allowedTransferAgentNames(): string[]; /** * Get the list of tools that this agent can use */ get availableTools(): LlmTool[]; /** * Get the list of delegates that this agent can delegate to */ get availableDelegateAgents(): LlmAgent[]; /** * Get the list of transfer agents that this agent can transfer to */ get availableTransferAgents(): LlmAgent[]; /** * Get the agent definition */ get definition(): LlmAgentDefinition; /** * Get the system message for this agent with the delegates and documents filled in */ get systemMessage(): string; /** * Representation of this agent to be used in other agents' system messages */ get systemMessageRepresentation(): string; /** * Get a delegate agent by name * @param agentName * @param type */ getDelegate(agentName: string, type?: "delegate" | "transfer"): LlmAgent; /** * Add an agent that this agent can delegate to * @param agent * @param type */ addDelegate(agent: LlmAgent | LlmAgentDefinition | string, type?: "delegate" | "transfer"): LlmAgent; /** * Remove an agent from the list of agents that this agent can delegate to * @param agent */ removeDelegate(agent: LlmAgent | string): void; /** * Add a tool that this agent can use. If the tool does not exist, it will be registered * @param tool */ addToolAccess(tool: LlmTool | string): void; /** * Remove a tool from the list of tools that this agent can use * @param tool */ removeToolAccess(tool: LlmTool | string): void; /** * Set this agent as the default agent for the team */ setAsDefault(): void; }