Interface IHttpLlmController<Model>

Controller of HTTP LLM function calling.

IHttpLlmController is a controller of HTTP LLM function calling, containing not only the application of function calling schemas, but also identifier name of the application and executor of its HTTP functions.

Here is an example of using IHttpLlmController type for AI agent development of performing AI function calling to e-commerce API functions through @agentica.

import { Agentica } from "@agentica/core";
import { HttpLlm, OpenApi } from "@samchon/openapi";

const agentica = new Agentica({
model: "chatgpt",
vendor: {
api: new OpenAI({ apiKey: "********" }),
model: "gpt-4o-mini",
},
controllers: [
{
protocol: "http",
name: "shopping",
application: HttpLlm.application(
model: "chatgpt",
document: await fetch(
"https://shopping-be.wrtn.io/editor/swagger.json",
).then((r) => r.json()),
),
connection: {
host: "https://shopping-be.wrtn.io",
headers: {
Authorization: "Bearer ********",
},
},
},
],
});
await agentica.conversate("I wanna buy a new phone.");

For reference, this IHttpLlmController type is designed for HTTP API servers. If you want to make a controller of another protocol like MCP or TypeScript, use below types instead:

interface IHttpLlmController<Model extends Model> {
    application: IHttpLlmApplication<Model>;
    connection: IHttpConnection;
    execute?: (
        props: {
            application: IHttpLlmApplication<Model>;
            arguments: object;
            connection: IHttpConnection;
            function: IHttpLlmFunction<Model>;
        },
    ) => Promise<IHttpResponse>;
    name: string;
    protocol: "http";
}

Type Parameters

  • Model extends Model

    Type of the LLM model

Properties

Application schema of function calling.

connection: IHttpConnection

Connection to the server.

Connection to the API server including the URL and headers.

execute?: (
    props: {
        application: IHttpLlmApplication<Model>;
        arguments: object;
        connection: IHttpConnection;
        function: IHttpLlmFunction<Model>;
    },
) => Promise<IHttpResponse>

Executor of the API function.

Default executor is HttpLlm.execute function, and you can override it with your own function.

Type declaration

name: string

Identifier name of the controller.

protocol: "http"

Protocol discriminator.