Interface IHttpLlmController

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({
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 {
    application: IHttpLlmApplication;
    connection: IHttpConnection;
    execute?: (
        props: {
            application: IHttpLlmApplication;
            arguments: object;
            connection: IHttpConnection;
            function: IHttpLlmFunction;
        },
    ) => Promise<IHttpResponse>;
    name: string;
    protocol: "http";
}

Properties

application: IHttpLlmApplication

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;
        arguments: object;
        connection: IHttpConnection;
        function: IHttpLlmFunction;
    },
) => Promise<IHttpResponse>

Executor of the API function.

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

Type declaration

    • (
          props: {
              application: IHttpLlmApplication;
              arguments: object;
              connection: IHttpConnection;
              function: IHttpLlmFunction;
          },
      ): Promise<IHttpResponse>
    • Parameters

      • props: {
            application: IHttpLlmApplication;
            arguments: object;
            connection: IHttpConnection;
            function: IHttpLlmFunction;
        }

        Properties of the API function call

        • application: IHttpLlmApplication

          Application schema.

        • arguments: object

          Arguments of the function calling.

          It is an object of key-value pairs of the API function's parameters. The property keys are composed by below rules:

          • Parameter names
          • Query parameter as an object type if exists
          • Body parameter if exists
        • connection: IHttpConnection

          Connection to the server.

        • function: IHttpLlmFunction

          Function schema.

      Returns Promise<IHttpResponse>

      HTTP response of the API function call

name: string

Identifier name of the controller.

protocol: "http"

Protocol discriminator.