@agentica/core 0.22.0 → 0.23.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 +10 -11
- package/lib/MicroAgentica.d.ts +10 -0
- package/lib/MicroAgentica.js +11 -0
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/functional/assertHttpController.d.ts +75 -0
- package/lib/functional/assertHttpController.js +9622 -0
- package/lib/functional/assertHttpController.js.map +1 -0
- package/lib/functional/assertHttpLlmApplication.d.ts +1 -0
- package/lib/functional/assertHttpLlmApplication.js +1 -0
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/assertMcpController.d.ts +1 -1
- package/lib/functional/assertMcpController.js +1 -1
- package/lib/functional/assertMcpController.js.map +1 -1
- package/lib/functional/validateHttpController.d.ts +75 -0
- package/lib/functional/validateHttpController.js +7952 -0
- package/lib/functional/validateHttpController.js.map +1 -0
- package/lib/functional/validateHttpLlmApplication.d.ts +1 -0
- package/lib/functional/validateHttpLlmApplication.js +1 -0
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateMcpController.d.ts +24 -0
- package/lib/functional/validateMcpController.js +3034 -0
- package/lib/functional/validateMcpController.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +25721 -5730
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/MicroAgentica.ts +13 -0
- package/src/functional/assertHttpController.ts +112 -0
- package/src/functional/assertHttpLlmApplication.ts +1 -0
- package/src/functional/assertMcpController.ts +1 -2
- package/src/functional/validateHttpController.ts +118 -0
- package/src/functional/validateHttpLlmApplication.ts +1 -1
- package/src/functional/validateMcpController.ts +56 -0
- package/src/index.ts +3 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Are you a TypeScript developer? Then you're already an AI developer. Familiar wi
|
|
|
26
26
|
<!-- eslint-skip -->
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
-
import { Agentica,
|
|
29
|
+
import { Agentica, assertHttpController } from "@agentica/core";
|
|
30
30
|
import OpenAI from "openai";
|
|
31
31
|
import typia from "typia";
|
|
32
32
|
|
|
@@ -40,24 +40,23 @@ const agent = new Agentica({
|
|
|
40
40
|
controllers: [
|
|
41
41
|
// functions from TypeScript class
|
|
42
42
|
{
|
|
43
|
-
protocol: "
|
|
43
|
+
protocol: "class",
|
|
44
|
+
name: "filesystem",
|
|
44
45
|
application: typia.llm.application<MobileFileSystem, "chatgpt">(),
|
|
45
46
|
execute: new MobileFileSystem(),
|
|
46
47
|
},
|
|
47
48
|
// functions from Swagger/OpenAPI
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
).then(r => r.json()),
|
|
55
|
-
}),
|
|
49
|
+
assertHttpController({
|
|
50
|
+
name: "shopping",
|
|
51
|
+
model: "chatgpt",
|
|
52
|
+
document: await fetch(
|
|
53
|
+
"https://shopping-be.wrtn.ai/editor/swagger.json",
|
|
54
|
+
).then(r => r.json()),
|
|
56
55
|
connection: {
|
|
57
56
|
host: "https://shopping-be.wrtn.ai",
|
|
58
57
|
headers: { Authorization: "Bearer ********" },
|
|
59
58
|
},
|
|
60
|
-
},
|
|
59
|
+
}),
|
|
61
60
|
],
|
|
62
61
|
});
|
|
63
62
|
await agent.conversate("I wanna buy MacBook Pro");
|
package/lib/MicroAgentica.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { AgenticaOperation } from "./context/AgenticaOperation";
|
|
2
3
|
import type { MicroAgenticaEvent } from "./events/MicroAgenticaEvent";
|
|
3
4
|
import type { AgenticaUserInputHistory } from "./histories/AgenticaUserInputHistory";
|
|
4
5
|
import type { MicroAgenticaHistory } from "./histories/MicroAgenticaHistory";
|
|
@@ -70,6 +71,15 @@ export declare class MicroAgentica<Model extends ILlmSchema.Model> {
|
|
|
70
71
|
* Get LLM vendor.
|
|
71
72
|
*/
|
|
72
73
|
getVendor(): IAgenticaVendor;
|
|
74
|
+
/**
|
|
75
|
+
* Get operations.
|
|
76
|
+
*
|
|
77
|
+
* Get list of operations, which has capsuled the pair of controller
|
|
78
|
+
* and function from the {@link getControllers controllers}.
|
|
79
|
+
*
|
|
80
|
+
* @returns List of operations
|
|
81
|
+
*/
|
|
82
|
+
getOperations(): ReadonlyArray<AgenticaOperation<Model>>;
|
|
73
83
|
/**
|
|
74
84
|
* Get controllers.
|
|
75
85
|
*
|
package/lib/MicroAgentica.js
CHANGED
|
@@ -138,6 +138,17 @@ class MicroAgentica {
|
|
|
138
138
|
getVendor() {
|
|
139
139
|
return this.props.vendor;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Get operations.
|
|
143
|
+
*
|
|
144
|
+
* Get list of operations, which has capsuled the pair of controller
|
|
145
|
+
* and function from the {@link getControllers controllers}.
|
|
146
|
+
*
|
|
147
|
+
* @returns List of operations
|
|
148
|
+
*/
|
|
149
|
+
getOperations() {
|
|
150
|
+
return this.operations_.array;
|
|
151
|
+
}
|
|
141
152
|
/**
|
|
142
153
|
* Get controllers.
|
|
143
154
|
*
|
package/lib/MicroAgentica.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAeA,qEAAkE;AAClE,4FAAyF;AACzF,kGAA+F;AAC/F,uCAAmD;AACnD,6CAA4E;AAC5E,+CAA+C;AAC/C,0FAAuF;AACvF,mDAAgD;AAChD,uFAAoF;AACpF,mDAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH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SwaggerV2 } from "@samchon/openapi";
|
|
2
|
+
import { OpenApi } from "@samchon/openapi";
|
|
3
|
+
import type { IAgenticaController } from "../structures/IAgenticaController";
|
|
4
|
+
/**
|
|
5
|
+
* Create an HTTP controller with type assertion.
|
|
6
|
+
*
|
|
7
|
+
* Create an {@link IAgenticaController.IHttp} instance which represents
|
|
8
|
+
* the HTTP controller from the given Swagger/OpenAPI document and the
|
|
9
|
+
* target LLM model with connection information.
|
|
10
|
+
*
|
|
11
|
+
* By the way, even though this `assertHttpController` function
|
|
12
|
+
* supports every version of Swagger/OpenAPI specification, there can
|
|
13
|
+
* be a type error in the given document. In that case, the function
|
|
14
|
+
* will throw an error with detailed type error tracing information.
|
|
15
|
+
*
|
|
16
|
+
* @param props Properties to create the HTTP controller instance
|
|
17
|
+
* @returns HTTP controller instance
|
|
18
|
+
* @throws {@link TypeGuardError} when the given document is invalid
|
|
19
|
+
* @author Samchon
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertHttpController<Model extends ILlmSchema.Model>(props: {
|
|
22
|
+
/**
|
|
23
|
+
* Name of the controller.
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Target LLM model.
|
|
28
|
+
*/
|
|
29
|
+
model: Model;
|
|
30
|
+
/**
|
|
31
|
+
* Swagger/OpenAPI document.
|
|
32
|
+
*/
|
|
33
|
+
document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument | unknown;
|
|
34
|
+
/**
|
|
35
|
+
* Connection to the server.
|
|
36
|
+
*
|
|
37
|
+
* Connection to the API server including the URL and headers.
|
|
38
|
+
*/
|
|
39
|
+
connection: IHttpConnection;
|
|
40
|
+
/**
|
|
41
|
+
* Options for the LLM function calling schema composition.
|
|
42
|
+
*/
|
|
43
|
+
options?: Partial<IHttpLlmApplication.IOptions<Model>>;
|
|
44
|
+
/**
|
|
45
|
+
* Executor of the API function.
|
|
46
|
+
*
|
|
47
|
+
* @param props Properties of the API function call
|
|
48
|
+
* @returns HTTP response of the API function call
|
|
49
|
+
*/
|
|
50
|
+
execute?: (props: {
|
|
51
|
+
/**
|
|
52
|
+
* Connection to the server.
|
|
53
|
+
*/
|
|
54
|
+
connection: IHttpConnection;
|
|
55
|
+
/**
|
|
56
|
+
* Application schema.
|
|
57
|
+
*/
|
|
58
|
+
application: IHttpLlmApplication<Model>;
|
|
59
|
+
/**
|
|
60
|
+
* Function schema.
|
|
61
|
+
*/
|
|
62
|
+
function: IHttpLlmFunction<Model>;
|
|
63
|
+
/**
|
|
64
|
+
* Arguments of the function calling.
|
|
65
|
+
*
|
|
66
|
+
* It is an object of key-value pairs of the API function's parameters.
|
|
67
|
+
* The property keys are composed by below rules:
|
|
68
|
+
*
|
|
69
|
+
* - parameter names
|
|
70
|
+
* - query parameter as an object type if exists
|
|
71
|
+
* - body parameter if exists
|
|
72
|
+
*/
|
|
73
|
+
arguments: object;
|
|
74
|
+
}) => Promise<IHttpResponse>;
|
|
75
|
+
}): IAgenticaController.IHttp<Model>;
|