vovk 3.0.0-draft.157 → 3.0.0-draft.158
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.
|
@@ -25,11 +25,6 @@ export declare function createLLMFunctions({ modules, callRPCMethod, callControl
|
|
|
25
25
|
callRPCMethod?: typeof defaultCallRPCMethod;
|
|
26
26
|
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
27
27
|
}): {
|
|
28
|
-
|
|
29
|
-
run: (functionName: string, input: [{
|
|
30
|
-
body?: KnownAny;
|
|
31
|
-
query?: KnownAny;
|
|
32
|
-
params?: KnownAny;
|
|
33
|
-
}]) => Promise<any>;
|
|
28
|
+
tools: void[];
|
|
34
29
|
};
|
|
35
30
|
export {};
|
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = (rpcModuleName, handlerName,
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, }) => {
|
|
5
|
+
const { schema } = handler;
|
|
6
|
+
const execute = (functionName, input) => {
|
|
7
|
+
const [moduleName, handlerName] = functionName.split('.');
|
|
8
|
+
const { body, query, params } = input[0];
|
|
9
|
+
const module = modules[moduleName];
|
|
10
|
+
if (!module) {
|
|
11
|
+
throw new Error(`Module "${moduleName}" not found.`);
|
|
12
|
+
}
|
|
13
|
+
const handler = module[handlerName];
|
|
14
|
+
if (!handler) {
|
|
15
|
+
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
16
|
+
}
|
|
17
|
+
const { schema, isRPC } = handler;
|
|
18
|
+
if (!schema) {
|
|
19
|
+
throw new Error(`Schema for handler "${handlerName}" in module "${moduleName}" not found.`);
|
|
20
|
+
}
|
|
21
|
+
if (isRPC) {
|
|
22
|
+
return callRPCMethod({
|
|
23
|
+
schema,
|
|
24
|
+
handler,
|
|
25
|
+
body,
|
|
26
|
+
query,
|
|
27
|
+
params,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return callControllerMethod({
|
|
31
|
+
schema,
|
|
32
|
+
handler,
|
|
33
|
+
body,
|
|
34
|
+
query,
|
|
35
|
+
params,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
5
38
|
return {
|
|
39
|
+
execute,
|
|
6
40
|
name: `${rpcModuleName}.${handlerName}`,
|
|
7
41
|
description: [schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName,
|
|
8
42
|
parameters: {
|
|
@@ -48,49 +82,16 @@ const defaultCallControllerMethod = async ({ handler, body, query, params, }) =>
|
|
|
48
82
|
});
|
|
49
83
|
};
|
|
50
84
|
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, }) {
|
|
51
|
-
const
|
|
52
|
-
.map(([
|
|
85
|
+
const tools = Object.entries(modules)
|
|
86
|
+
.map(([rpcModuleName, module]) => {
|
|
53
87
|
return Object.entries(module)
|
|
54
88
|
.filter(([, handler]) => handler.schema)
|
|
55
89
|
.map(([handlerName, handler]) => {
|
|
56
|
-
createLLMFunction(
|
|
90
|
+
createLLMFunction({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules });
|
|
57
91
|
});
|
|
58
92
|
})
|
|
59
93
|
.flat();
|
|
60
|
-
const run = (functionName, input) => {
|
|
61
|
-
const [moduleName, handlerName] = functionName.split('.');
|
|
62
|
-
const { body, query, params } = input[0];
|
|
63
|
-
const module = modules[moduleName];
|
|
64
|
-
if (!module) {
|
|
65
|
-
throw new Error(`Module "${moduleName}" not found.`);
|
|
66
|
-
}
|
|
67
|
-
const handler = module[handlerName];
|
|
68
|
-
if (!handler) {
|
|
69
|
-
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
70
|
-
}
|
|
71
|
-
const { schema, isRPC } = handler;
|
|
72
|
-
if (!schema) {
|
|
73
|
-
throw new Error(`Schema for handler "${handlerName}" in module "${moduleName}" not found.`);
|
|
74
|
-
}
|
|
75
|
-
if (isRPC) {
|
|
76
|
-
return callRPCMethod({
|
|
77
|
-
schema,
|
|
78
|
-
handler,
|
|
79
|
-
body,
|
|
80
|
-
query,
|
|
81
|
-
params,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return callControllerMethod({
|
|
85
|
-
schema,
|
|
86
|
-
handler,
|
|
87
|
-
body,
|
|
88
|
-
query,
|
|
89
|
-
params,
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
94
|
return {
|
|
93
|
-
|
|
94
|
-
run,
|
|
95
|
+
tools,
|
|
95
96
|
};
|
|
96
97
|
}
|
|
@@ -25,11 +25,6 @@ export declare function createLLMFunctions({ modules, callRPCMethod, callControl
|
|
|
25
25
|
callRPCMethod?: typeof defaultCallRPCMethod;
|
|
26
26
|
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
27
27
|
}): {
|
|
28
|
-
|
|
29
|
-
run: (functionName: string, input: [{
|
|
30
|
-
body?: KnownAny;
|
|
31
|
-
query?: KnownAny;
|
|
32
|
-
params?: KnownAny;
|
|
33
|
-
}]) => Promise<any>;
|
|
28
|
+
tools: void[];
|
|
34
29
|
};
|
|
35
30
|
export {};
|
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = (rpcModuleName, handlerName,
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, }) => {
|
|
5
|
+
const { schema } = handler;
|
|
6
|
+
const execute = (functionName, input) => {
|
|
7
|
+
const [moduleName, handlerName] = functionName.split('.');
|
|
8
|
+
const { body, query, params } = input[0];
|
|
9
|
+
const module = modules[moduleName];
|
|
10
|
+
if (!module) {
|
|
11
|
+
throw new Error(`Module "${moduleName}" not found.`);
|
|
12
|
+
}
|
|
13
|
+
const handler = module[handlerName];
|
|
14
|
+
if (!handler) {
|
|
15
|
+
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
16
|
+
}
|
|
17
|
+
const { schema, isRPC } = handler;
|
|
18
|
+
if (!schema) {
|
|
19
|
+
throw new Error(`Schema for handler "${handlerName}" in module "${moduleName}" not found.`);
|
|
20
|
+
}
|
|
21
|
+
if (isRPC) {
|
|
22
|
+
return callRPCMethod({
|
|
23
|
+
schema,
|
|
24
|
+
handler,
|
|
25
|
+
body,
|
|
26
|
+
query,
|
|
27
|
+
params,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return callControllerMethod({
|
|
31
|
+
schema,
|
|
32
|
+
handler,
|
|
33
|
+
body,
|
|
34
|
+
query,
|
|
35
|
+
params,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
5
38
|
return {
|
|
39
|
+
execute,
|
|
6
40
|
name: `${rpcModuleName}.${handlerName}`,
|
|
7
41
|
description: [schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName,
|
|
8
42
|
parameters: {
|
|
@@ -48,49 +82,16 @@ const defaultCallControllerMethod = async ({ handler, body, query, params, }) =>
|
|
|
48
82
|
});
|
|
49
83
|
};
|
|
50
84
|
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, }) {
|
|
51
|
-
const
|
|
52
|
-
.map(([
|
|
85
|
+
const tools = Object.entries(modules)
|
|
86
|
+
.map(([rpcModuleName, module]) => {
|
|
53
87
|
return Object.entries(module)
|
|
54
88
|
.filter(([, handler]) => handler.schema)
|
|
55
89
|
.map(([handlerName, handler]) => {
|
|
56
|
-
createLLMFunction(
|
|
90
|
+
createLLMFunction({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules });
|
|
57
91
|
});
|
|
58
92
|
})
|
|
59
93
|
.flat();
|
|
60
|
-
const run = (functionName, input) => {
|
|
61
|
-
const [moduleName, handlerName] = functionName.split('.');
|
|
62
|
-
const { body, query, params } = input[0];
|
|
63
|
-
const module = modules[moduleName];
|
|
64
|
-
if (!module) {
|
|
65
|
-
throw new Error(`Module "${moduleName}" not found.`);
|
|
66
|
-
}
|
|
67
|
-
const handler = module[handlerName];
|
|
68
|
-
if (!handler) {
|
|
69
|
-
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
70
|
-
}
|
|
71
|
-
const { schema, isRPC } = handler;
|
|
72
|
-
if (!schema) {
|
|
73
|
-
throw new Error(`Schema for handler "${handlerName}" in module "${moduleName}" not found.`);
|
|
74
|
-
}
|
|
75
|
-
if (isRPC) {
|
|
76
|
-
return callRPCMethod({
|
|
77
|
-
schema,
|
|
78
|
-
handler,
|
|
79
|
-
body,
|
|
80
|
-
query,
|
|
81
|
-
params,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return callControllerMethod({
|
|
85
|
-
schema,
|
|
86
|
-
handler,
|
|
87
|
-
body,
|
|
88
|
-
query,
|
|
89
|
-
params,
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
94
|
return {
|
|
93
|
-
|
|
94
|
-
run,
|
|
95
|
+
tools,
|
|
95
96
|
};
|
|
96
97
|
}
|