halo - v1.0.0
    Preparing search index...

    Interface AiAgentConfig<ExtraModelID>

    Represents the configuration for an AI agent. This configuration is used to connect to an AI service and define the model and tools available for the agent. It includes the agent URL, API key, model ID, fallback model, system prompt file, and a set of tools.

    The type parameter <MODELID> represents the model identifier type for the AI agent. It is used to specify which model the agent should use, such as a Google Gemini model (e.g., "gemini-1.5-flash") or an OpenAI model (e.g., "gpt-4o"). This allows the AiAgentConfig interface to be generic and flexible, supporting different model ID types depending on the AI service being integrated.

    type ExtraModelID = "gpt-4o" | "gpt-3.5-turbo";
    const agentConfig: AiAgentConfig<typeof ExtraModelID> = {
    agentUrl: "https://api.example.com/ai",
    apiKey: "your-api-key",
    model: "gpt-4o",
    fallbackModel: "gpt-3.5-turbo",
    systemPrompt: {
    text: "You are a helpful assistant. Answer the questions as best you can.",
    },
    tools: {
    getCurrentTime: TaskHandler.getCurrentTime
    }
    }
    const systemPrompt = {
    text: "You are a helpful assistant. Answer the questions as best you can."
    }
    interface AiAgentConfig<ExtraModelID extends string = ModelID> {
        agentUrl: string;
        apiKey: string;
        fallbackModel: ModelID | ExtraModelID;
        model: ModelID | ExtraModelID;
        systemPrompt?: OnlyOne<{ file: string; text: string }>;
        tools?: ToolSet;
    }

    Type Parameters

    • ExtraModelID extends string = ModelID

      A string type that extends the model ID. This allows for additional model IDs to be specified beyond the default set.

    Index

    Properties

    agentUrl: string

    The URL of the AI agent service. This is required to connect to the AI service.

    apiKey: string

    The API key for the AI agent. This is required to authenticate requests to the AI service.

    fallbackModel: ModelID | ExtraModelID

    fallbackModel is an model ID that can be used as a fallback if the primary model fails or is not available.

    The model ID to use for the AI agent. It can be a Google Gemini model (e.g., "gemini-1.5-flash") or an OpenAI model (e.g., "gpt-4o"). If not provided, defaults to "gpt-4o".

    systemPrompt?: OnlyOne<{ file: string; text: string }>

    The system prompt text to be used by the AI agent. This can be a string or a file containing the prompt. If not provided, the system prompt will be empty. You can use either systemPromptFile or systemPrompt.text, but not both.

    const systemPrompt = {
    text: "You are a helpful assistant. Answer the questions as best you can."
    }
    tools?: ToolSet

    A set of tools that the AI agent can use to perform specific tasks. These tools can be used to interact with external services or perform actions. The tools are defined using the tool function from the ai library. For example, you can define tools like getCurrentTime or fetchData.

    const tools: ToolSet = {
    getCurrentTime: tool({
    description: "Get the current time",
    parameters: [],
    handler: async () => {
    return new Date().toISOString();
    }
    }),
    fetchData: tool({
    description: "Fetch data from an API",
    parameters: ["url"],
    handler: async (url: string) => {
    const response = await fetch(url);
    return response.json();
    }
    })
    }