ailoy-web
    Preparing search index...

    Class Agent

    The Agent class provides a high-level interface for interacting with large language models (LLMs) in Ailoy. It abstracts the underlying runtime and VM logic, allowing users to easily send queries and receive streaming responses. Agents can be extended with external tools or APIs to provide real-time or domain-specific knowledge, enabling more powerful and context-aware interactions.

    Index

    Constructors

    Methods

    • Adds a Javascript function as a tool using callable

      Parameters

      • f: (input: any) => any

        Function will be called when the tool invocation occured

      • desc: ToolDescription

        Tool descriotion

      Returns boolean

    • Adds a custom tool to the agent

      Parameters

      • tool: Tool

        Tool instance to be added

      Returns boolean

    • Register a MCP client and add its tools to agent.

      Parameters

      • name: string

        The unique name of the MCP client. If there's already a MCP client with the same name, it throws Error.

      • transport: MCPClientTransport

        MCP client transport to use for client connection

      • Optionaloptions: MCPClientStartOptions & { toolsToAdd?: string[] }
        • OptionaltoolsToAdd?: string[]

          Optional list of tool names to add. If not specified, all tools are added.

      Returns Promise<void>

    • Loads tools from a predefined JSON preset file

      Parameters

      • presetName: string

        Name of the tool preset

      • Optionalargs: { authenticator?: ToolAuthenticator }
        • Optionalauthenticator?: ToolAuthenticator

          Optional authenticator to inject into the request

      Returns Promise<boolean>

    • Clear the history of conversation messages.

      Returns void

    • Clear the registered tools.

      Returns void

    • Defines the LLM components to the runtime. This must be called before using any other method in the class. If already defined, this is a no-op.

      Parameters

      • runtime: Runtime

        The runtime environment associated with the agent

      • model: AiloyModel

        The LLM model to use in this agent

      • Optionalargs: { systemMessage?: string }
        • OptionalsystemMessage?: string

          Optional system message to set the initial assistant context

      Returns Promise<void>

    • Delete resources in the agent. If the agent is not in an initialized state, this is a no-op.

      Returns Promise<void>

    • Get the current conversation history. Each item in the list represents a message from either the user or the assistant.

      Returns Message[]

    • Removes the MCP client and its tools from the agent.

      Parameters

      • name: string

        The unique name of the MCP client. If there's no MCP client matches the name, it throws Error.

      Returns Promise<void>