@agentica/rpc 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -251
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,293 +1,165 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agentica, AI Function Calling Framework
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!-- https://github.com/user-attachments/assets/5326cc59-5129-470d-abcb-c3f458b5c488 -->
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/@agentica/rpc)
|
|
7
|
-
[](https://www.npmjs.com/package/@agentica/rpc)
|
|
8
|
-
[](https://github.com/wrtnlabs/agentica/actions?query=workflow%3Abuild)
|
|
9
|
-
|
|
10
|
-
RPC module of Agentica for WebSocket Communication
|
|
11
|
-
|
|
12
|
-
Agentica is the simplest Agentic AI library specialized in **LLM Function Calling**, and `@agentica/rpc` is an RPC (Remote Procedure Call) wrapper module. If you combine the RPC wrapper module with [`TGrid`](https://github.com/samchon/tgrid), you can develop the WebSocket AI Chatbot.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
|
|
16
|
-
import { Driver, WebSocketConnector } from "tgrid";
|
|
17
|
-
|
|
18
|
-
const connector: WebSocketConnector<
|
|
19
|
-
null,
|
|
20
|
-
IAgenticaRpcListener,
|
|
21
|
-
IAgenticaRpcService
|
|
22
|
-
> = new WebSocketConnector(null, {
|
|
23
|
-
text: async (evt) => {
|
|
24
|
-
console.log(evt.role, evt.text);
|
|
25
|
-
},
|
|
26
|
-
describe: async (evt) => {
|
|
27
|
-
console.log("describer", evt.text);
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
await connector.connect("ws://localhost:3001");
|
|
31
|
-
|
|
32
|
-
const driver: Driver<IAgenticaRpcService> = connector.getDriver();
|
|
33
|
-
await driver.conversate("Hello, what you can do?");
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## How to use
|
|
37
|
-
|
|
38
|
-
### Setup
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# SERVER APPLICATION
|
|
42
|
-
npm install @agentica/core @agentica/rpc @samchon/openapi tgrid typia
|
|
43
|
-
npx typia setup
|
|
5
|
+

|
|
44
6
|
|
|
45
|
-
|
|
46
|
-
npm
|
|
47
|
-
|
|
7
|
+
[](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
|
|
8
|
+
[](https://www.npmjs.com/package/@agentica/core)
|
|
9
|
+
[](https://www.npmjs.com/package/@agentica/core)
|
|
10
|
+
[](https://github.com/wrtnlabs/agentica/actions?query=workflow%3Abuild)
|
|
11
|
+
[](https://wrtnlabs.io/agentica/)
|
|
12
|
+
[](https://discord.gg/aMhRmzkqCx)
|
|
48
13
|
|
|
49
|
-
|
|
14
|
+
Agentic AI framework specialized in AI Function Calling.
|
|
50
15
|
|
|
51
|
-
|
|
16
|
+
Don't be afraid of AI agent development. Just list functions from three protocols below. This is everything you should do for AI agent development.
|
|
52
17
|
|
|
53
|
-
|
|
18
|
+
- TypeScript Class
|
|
19
|
+
- Swagger/OpenAPI Document
|
|
20
|
+
- MCP (Model Context Protocol) Server
|
|
54
21
|
|
|
55
|
-
|
|
22
|
+
Wanna make an e-commerce agent? Bring in e-commerce functions. Need a newspaper agent? Get API functions from the newspaper company. Just prepare any functions that you need, then it becomes an AI agent.
|
|
56
23
|
|
|
57
|
-
|
|
24
|
+
Are you a TypeScript developer? Then you're already an AI developer. Familiar with backend development? You're already well-versed in AI development. Anyone who can make functions can make AI agents.
|
|
58
25
|
|
|
59
26
|
<!-- eslint-skip -->
|
|
60
27
|
|
|
61
28
|
```typescript
|
|
62
|
-
import { Agentica } from "@agentica/core";
|
|
63
|
-
import
|
|
64
|
-
|
|
65
|
-
IAgenticaRpcListener,
|
|
66
|
-
IAgenticaRpcService,
|
|
67
|
-
} from "@agentica/rpc";
|
|
68
|
-
import { WebSocketServer } from "tgrid";
|
|
69
|
-
|
|
70
|
-
const server: WebSocketServer<
|
|
71
|
-
null,
|
|
72
|
-
IAgenticaRpcService,
|
|
73
|
-
IAgenticaRpcListener
|
|
74
|
-
> = new WebSocketServer();
|
|
75
|
-
await server.open(3001, async (acceptor) => {
|
|
76
|
-
await acceptor.accept(
|
|
77
|
-
new AgenticaRpcService({
|
|
78
|
-
agent: new Agentica({ ... }),
|
|
79
|
-
listener: acceptor.getDriver(),
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
```
|
|
29
|
+
import { Agentica, assertHttpLlmApplication } from "@agentica/core";
|
|
30
|
+
import OpenAI from "openai";
|
|
31
|
+
import typia from "typia";
|
|
84
32
|
|
|
85
|
-
|
|
33
|
+
import { MobileFileSystem } from "./services/MobileFileSystem";
|
|
86
34
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { IAgenticaRpcListener, IAgenticaRpcService } from "@agentica/rpc";
|
|
93
|
-
import { Driver, WebSocketConnector } from "tgrid";
|
|
94
|
-
|
|
95
|
-
const connector: WebSocketConnector<
|
|
96
|
-
null,
|
|
97
|
-
IAgenticaRpcListener,
|
|
98
|
-
IAgenticaRpcService
|
|
99
|
-
> = new WebSocketConnector(null, {
|
|
100
|
-
text: async (evt) => {
|
|
101
|
-
console.log(evt.role, evt.text);
|
|
102
|
-
},
|
|
103
|
-
describe: async (evt) => {
|
|
104
|
-
console.log("describer", evt.text);
|
|
35
|
+
const agent = new Agentica({
|
|
36
|
+
vendor: {
|
|
37
|
+
api: new OpenAI({ apiKey: "********" }),
|
|
38
|
+
model: "gpt-4o-mini",
|
|
105
39
|
},
|
|
40
|
+
controllers: [
|
|
41
|
+
// functions from TypeScript class
|
|
42
|
+
{
|
|
43
|
+
protocol: "http",
|
|
44
|
+
application: typia.llm.application<MobileFileSystem, "chatgpt">(),
|
|
45
|
+
execute: new MobileFileSystem(),
|
|
46
|
+
},
|
|
47
|
+
// functions from Swagger/OpenAPI
|
|
48
|
+
{
|
|
49
|
+
protocol: "http",
|
|
50
|
+
application: assertHttpLlmApplication({
|
|
51
|
+
model: "chatgpt",
|
|
52
|
+
document: await fetch(
|
|
53
|
+
"https://shopping-be.wrtn.ai/editor/swagger.json",
|
|
54
|
+
).then(r => r.json()),
|
|
55
|
+
}),
|
|
56
|
+
connection: {
|
|
57
|
+
host: "https://shopping-be.wrtn.ai",
|
|
58
|
+
headers: { Authorization: "Bearer ********" },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
106
62
|
});
|
|
107
|
-
await
|
|
108
|
-
|
|
109
|
-
const driver: Driver<IAgenticaRpcService> = connector.getDriver();
|
|
110
|
-
await driver.conversate("Hello, what you can do?");
|
|
63
|
+
await agent.conversate("I wanna buy MacBook Pro");
|
|
111
64
|
```
|
|
112
65
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Otherwise you're developing WebSocket protocol client application, connect to the websocket backend server with its URL address, and provide `IAgenticaRpcListener` instance for event listening.
|
|
116
|
-
|
|
117
|
-
And then call the backend server's function `IAgenticaRpcService.conversate()` remotely through the `Driver<IAgenticaRpcService>` wrapping. The backend server will call your `IAgenticaRpcListener` functions remotely through the RPC paradigm.
|
|
118
|
-
|
|
119
|
-
## NestJS Application
|
|
120
|
-
|
|
121
|
-
### Bootstrap
|
|
66
|
+
## 📦 Setup
|
|
122
67
|
|
|
123
68
|
```bash
|
|
124
|
-
npx
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
public async open(): Promise<void> {
|
|
147
|
-
//----
|
|
148
|
-
// OPEN THE BACKEND SERVER
|
|
149
|
-
//----
|
|
150
|
-
// MOUNT CONTROLLERS
|
|
151
|
-
this.application_ = await NestFactory.create(MyModule, { logger: false });
|
|
152
|
-
WebSocketAdaptor.upgrade(this.application_);
|
|
69
|
+
$ npx agentica start <directory>
|
|
70
|
+
|
|
71
|
+
----------------------------------------
|
|
72
|
+
Agentica Setup Wizard
|
|
73
|
+
----------------------------------------
|
|
74
|
+
? Package Manager (use arrow keys)
|
|
75
|
+
> npm
|
|
76
|
+
pnpm
|
|
77
|
+
yarn (berry is not supported)
|
|
78
|
+
? Project Type
|
|
79
|
+
NodeJS Agent Server
|
|
80
|
+
> NestJS Agent Server
|
|
81
|
+
React Client Application
|
|
82
|
+
Standalone Application
|
|
83
|
+
? Embedded Controllers (multi-selectable)
|
|
84
|
+
(none)
|
|
85
|
+
Google Calendar
|
|
86
|
+
Google News
|
|
87
|
+
> Github
|
|
88
|
+
Reddit
|
|
89
|
+
Slack
|
|
153
90
|
...
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
91
|
```
|
|
157
92
|
|
|
158
|
-
|
|
93
|
+
The setup wizard helps you create a new project tailored to your needs.
|
|
159
94
|
|
|
160
|
-
|
|
95
|
+
For reference, when selecting a project type, any option other than "Standalone Application" will implement the [WebSocket Protocol](https://wrtnlabs.io/agentica/docs/websocket/) for client-server communication.
|
|
161
96
|
|
|
162
|
-
|
|
97
|
+
For comprehensive setup instructions, visit our [Getting Started](https://wrtnlabs.io/agentica/docs/) guide.
|
|
163
98
|
|
|
164
|
-
|
|
165
|
-
import { AgenticaRpcService, IAgenticaRpcListener } from "@agentica/rpc";
|
|
166
|
-
import { WebSocketRoute } from "@nestia/core";
|
|
167
|
-
import { Controller } from "@nestjs/common";
|
|
168
|
-
import { WebSocketAcceptor } from "tgrid";
|
|
169
|
-
|
|
170
|
-
@Controller("chat")
|
|
171
|
-
export class ChatController {
|
|
172
|
-
@WebSocketRoute()
|
|
173
|
-
public async start(
|
|
174
|
-
// @WebSocketRoute.Param("id") id: string,
|
|
175
|
-
@WebSocketRoute.Acceptor()
|
|
176
|
-
acceptor: WebSocketAcceptor<
|
|
177
|
-
null, // header
|
|
178
|
-
AgenticaRpcService,
|
|
179
|
-
IAgenticaRpcListener
|
|
180
|
-
>,
|
|
181
|
-
): Promise<void> {
|
|
182
|
-
await acceptor.accept(
|
|
183
|
-
new AgenticaRpcService({
|
|
184
|
-
agent: new Agentica({ ... }),
|
|
185
|
-
listener: acceptor.getDriver(),
|
|
186
|
-
}),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
```
|
|
99
|
+
## 💻 Playground
|
|
191
100
|
|
|
192
|
-
|
|
101
|
+
Experience Agentica firsthand through our [interactive playground](https://wrtnlabs.io/agentica/playground) before installing.
|
|
193
102
|
|
|
194
|
-
|
|
103
|
+
Our demonstrations showcase the power and simplicity of Agentica's function calling capabilities across different integration methods.
|
|
195
104
|
|
|
196
|
-
|
|
105
|
+
- [TypeScript Class](https://wrtnlabs.io/agentica/playground/bbs)
|
|
106
|
+
- [Swagger/OpenAPI Document](https://wrtnlabs.io/agentica/playground/swagger)
|
|
107
|
+
- [Enterprise E-commerce Agent](https://wrtnlabs.io/agentica/playground/shopping)
|
|
197
108
|
|
|
198
|
-
|
|
109
|
+
<!--
|
|
110
|
+
@todo this section would be changed after making tutorial playground
|
|
111
|
+
-->
|
|
199
112
|
|
|
200
|
-
|
|
201
|
-
npx nestia sdk
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
When backend server development has been completed, you can generate SDK (Software Development Kit) library for client developers by running `npx nestia sdk` command.
|
|
113
|
+
## 📚 Documentation Resources
|
|
205
114
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
import { IAgenticaRpcListener } from "@agentica/rpc";
|
|
210
|
-
import api from "@ORGANIZATION/PROJECT-api";
|
|
211
|
-
|
|
212
|
-
const { connector, driver } = await api.functional.chat.start(
|
|
213
|
-
{
|
|
214
|
-
host: "http://localhost:3000",
|
|
215
|
-
} satisfies api.IConnection,
|
|
216
|
-
{
|
|
217
|
-
text: async (evt) => {
|
|
218
|
-
console.log(evt.role, evt.text);
|
|
219
|
-
},
|
|
220
|
-
describe: async (evt) => {
|
|
221
|
-
console.log("describer", evt.text);
|
|
222
|
-
},
|
|
223
|
-
} satisfies IAgenticaRpcListener,
|
|
224
|
-
);
|
|
225
|
-
await driver.conversate("Hello, what you can do?");
|
|
226
|
-
```
|
|
115
|
+
Find comprehensive resources at our [official website](https://wrtnlabs.io/agentica).
|
|
227
116
|
|
|
228
|
-
|
|
117
|
+
- [Home](https://wrtnlabs.io/agentica)
|
|
118
|
+
- [Guide Documents](https://wrtnlabs.io/agentica/docs)
|
|
119
|
+
- [Tutorial](https://wrtnlabs.io/agentica/tutorial)
|
|
120
|
+
- [API Documents](https://wrtnlabs.io/agentica/api)
|
|
121
|
+
- [Youtube](https://www.youtube.com/@wrtnlabs)
|
|
122
|
+
- [Paper](https://wrtnlabs.io/agentica/paper)
|
|
229
123
|
|
|
230
|
-
|
|
124
|
+
## 🌟 Why Agentica?
|
|
231
125
|
|
|
232
126
|
```mermaid
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
Acceptor->>Provider: 4. calls the function
|
|
253
|
-
Provider->>Acceptor: 5. returns a value
|
|
254
|
-
Acceptor-->>Connector: 6. sends a protocolized<br/>network message<br/>meaning a return value
|
|
255
|
-
Deactivate Acceptor
|
|
256
|
-
Activate Connector
|
|
257
|
-
Connector->>Driver: 7. delivers the return value
|
|
258
|
-
Deactivate Connector
|
|
259
|
-
Activate Driver
|
|
260
|
-
Driver->>User: 8. returns the value
|
|
261
|
-
Deactivate Driver
|
|
262
|
-
Deactivate User
|
|
127
|
+
flowchart
|
|
128
|
+
subgraph "JSON Schema Specification"
|
|
129
|
+
schemav4("JSON Schema v4 ~ v7") --upgrades--> emended[["OpenAPI v3.1 (emended)"]]
|
|
130
|
+
schema2910("JSON Schema 2019-03") --upgrades--> emended
|
|
131
|
+
schema2020("JSON Schema 2020-12") --emends--> emended
|
|
132
|
+
end
|
|
133
|
+
subgraph "Agentica"
|
|
134
|
+
emended --"Artificial Intelligence"--> fc{{"AI Function Calling"}}
|
|
135
|
+
fc --"OpenAI"--> chatgpt("ChatGPT")
|
|
136
|
+
fc --"Google"--> gemini("Gemini")
|
|
137
|
+
fc --"Anthropic"--> claude("Claude")
|
|
138
|
+
fc --"High-Flyer"--> deepseek("DeepSeek")
|
|
139
|
+
fc --"Meta"--> llama("Llama")
|
|
140
|
+
chatgpt --"3.1"--> custom(["Custom JSON Schema"])
|
|
141
|
+
gemini --"3.0"--> custom(["Custom JSON Schema"])
|
|
142
|
+
claude --"3.1"--> standard(["Standard JSON Schema"])
|
|
143
|
+
deepseek --"3.1"--> standard
|
|
144
|
+
llama --"3.1"--> standard
|
|
145
|
+
end
|
|
263
146
|
```
|
|
264
147
|
|
|
265
|
-
|
|
148
|
+
Agentica enhances AI function calling by the following strategies:
|
|
266
149
|
|
|
267
|
-
|
|
150
|
+
- [**Compiler Driven Development**](https://wrtnlabs.io/agentica/docs/concepts/compiler-driven-development): constructs function calling schema automatically by compiler skills without hand-writing.
|
|
151
|
+
- [**JSON Schema Conversion**](https://wrtnlabs.io/agentica/docs/core/vendor/#schema-specification): automatically handles specification differences between LLM vendors, ensuring seamless integration regardless of your chosen AI model.
|
|
152
|
+
- [**Validation Feedback**](https://wrtnlabs.io/agentica/docs/concepts/function-calling#validation-feedback): detects and corrects AI mistakes in argument composition, dramatically reducing errors and improving reliability.
|
|
153
|
+
- [**Selector Agent**](https://wrtnlabs.io/agentica/docs/concepts/function-calling#orchestration-strategy): filtering candidate functions to minimize context usage, optimize performance, and reduce token consumption.
|
|
268
154
|
|
|
269
|
-
|
|
155
|
+
Thanks to these innovations, Agentica makes AI function calling easier, safer, and more accurate than before. Development becomes more intuitive since you only need to prepare functions relevant to your specific use case, and scaling your agent's capabilities is as simple as adding or removing functions.
|
|
270
156
|
|
|
271
|
-
|
|
157
|
+
In 2023, when OpenAI announced function calling, many predicted that function calling-driven AI development would become the mainstream. However, in reality, due to the difficulty and instability of function calling, the trend in AI development became agent workflow. Agent workflow, which is inflexible and must be created for specific purposes, has conquered the AI agent ecosystem.
|
|
158
|
+
By the way, as Agentica has resolved the difficulty and instability problems of function calling, the time has come to embrace function-driven AI development once again.
|
|
272
159
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
IAgenticaRpcListener,
|
|
280
|
-
IAgenticaRpcService
|
|
281
|
-
> = new WebSocketConnector(null, {
|
|
282
|
-
text: async (evt) => {
|
|
283
|
-
console.log(evt.role, evt.text);
|
|
284
|
-
},
|
|
285
|
-
describe: async (evt) => {
|
|
286
|
-
console.log("describer", evt.text);
|
|
287
|
-
},
|
|
288
|
-
});
|
|
289
|
-
await connector.connect("ws://localhost:3001");
|
|
290
|
-
|
|
291
|
-
const driver: Driver<IAgenticaRpcService> = connector.getDriver();
|
|
292
|
-
await driver.conversate("Hello, what you can do?");
|
|
293
|
-
```
|
|
160
|
+
| Type | Workflow | Vanilla Function Calling | Agentica Function Calling |
|
|
161
|
+
| ----------- | ------------- | ------------------------ | ------------------------- |
|
|
162
|
+
| Purpose | ❌ Specific | 🟢 General | 🟢 General |
|
|
163
|
+
| Difficulty | ❌ Difficult | ❌ Difficult | 🟢 Easy |
|
|
164
|
+
| Stability | 🟢 Stable | ❌ Unstable | 🟢 Stable |
|
|
165
|
+
| Flexibility | ❌ Inflexible | 🟢 Flexible | 🟢 Flexible |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/rpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
5
5
|
"author": "Wrtn Technologies",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"src"
|
|
36
36
|
],
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@agentica/core": "^0.
|
|
38
|
+
"@agentica/core": "^0.21.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@samchon/openapi": "^4.2.0",
|
|
42
42
|
"typia": "^9.0.1",
|
|
43
|
-
"@agentica/core": "^0.
|
|
43
|
+
"@agentica/core": "^0.21.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-terser": "^0.4.4",
|