RPC interface of Micro agent listener.

IMicroAgenticaRpcListener is an interface defining an AI agent listener provided from the client to server through the RPC (Remote Procedure Call) paradigm in the websocket protocol.

It has defined the event listener functions of MicroAgenticaEvent types. If you skip some event typed functions' implementations, the skipped event would be ignored.

Also, the event like listener functions of IMicroAgenticaRpcListener type are remotely called when a client calls the IAgenticaRpcService.conversate function remotely, so that the server responses to the client by the event listener functions.

You can connect to the WebSocket server of the AI agent like below:

import {
IMicroAgenticaRpcListener,
IAgenticaRpcService
} from "@agentica/core";
import { Driver, WebSocketConnector } from "tgrid";

const connector: WebSocketConnector<
null,
IMicroAgenticaRpcListener,
IAgenticaRpcService
> = new WebSocketConnector(null, {
text: async (evt) => {
console.log(evt.role, evt.text);
},
describe: async (evt) => {
console.log("describer", evt.text);
},
});
await connector.connect("ws://localhost:3001");

const driver: Driver<IAgenticaRpcService> = connector.getDriver();
await driver.conversate("Hello, what you can do?");

Samchon

interface IMicroAgenticaRpcListener {
    call?: (evt: ICall) => Promise<undefined | null | void | object>;
    describe: (evt: IAgenticaEventJson.IDescribe) => Promise<void>;
    execute?: (evt: IAgenticaEventJson.IExecute) => Promise<void>;
    text: (evt: IAgenticaEventJson.IText) => Promise<void>;
}

Properties

call?: (evt: ICall) => Promise<undefined | null | void | object>

Call a function.

Informs a function calling from the AI agent server to client.

This event comes before the function execution, so that if you return a different value from the original IAgenticaEventJson.ICall.arguments, you can modify the arguments of the function calling.

Otherwise you do not return anything (undefined) or null value, the arguments of the function calling would not be modified. Also, if you are not interested in the function calling event, you can skit its implementation.

Type declaration

    • (evt: ICall): Promise<undefined | null | void | object>
    • Parameters

      • evt: ICall

        Event of a function calling

      Returns Promise<undefined | null | void | object>

      New arguments if you want to modify, otherwise null or undefined

describe: (evt: IAgenticaEventJson.IDescribe) => Promise<void>

Describe the function executions' results.

Inform description message of the function execution's results from the AI agent server to client.

Type declaration

execute?: (evt: IAgenticaEventJson.IExecute) => Promise<void>

Executition of a function.

Informs a function execution from the AI agent server to client.

Type declaration

text: (evt: IAgenticaEventJson.IText) => Promise<void>

Text conversation message.

Type declaration