vovk 3.0.0-draft.172 → 3.0.0-draft.174
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.
|
@@ -22,17 +22,19 @@ declare const defaultCallControllerMethod: ({ handler, body, query, params, }: {
|
|
|
22
22
|
query?: KnownAny;
|
|
23
23
|
params?: KnownAny;
|
|
24
24
|
}) => Promise<any>;
|
|
25
|
-
export declare function createLLMFunctions({ modules, callRPCMethod, callControllerMethod, }: {
|
|
25
|
+
export declare function createLLMFunctions({ modules, callRPCMethod, callControllerMethod, onSuccess, onError, }: {
|
|
26
26
|
modules: Record<string, Record<string, (...args: KnownAny[]) => KnownAny>>;
|
|
27
27
|
callRPCMethod?: typeof defaultCallRPCMethod;
|
|
28
28
|
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
29
|
+
onSuccess?: (result: KnownAny) => void;
|
|
30
|
+
onError?: (error: Error) => void;
|
|
29
31
|
}): {
|
|
30
32
|
functions: {
|
|
31
|
-
execute: (input:
|
|
33
|
+
execute: (input: {
|
|
32
34
|
body?: KnownAny;
|
|
33
35
|
query?: KnownAny;
|
|
34
36
|
params?: KnownAny;
|
|
35
|
-
}
|
|
37
|
+
}, { toolCallId }: {
|
|
36
38
|
toolCallId: string;
|
|
37
39
|
}) => Promise<any>;
|
|
38
40
|
name: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, }) => {
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, onSuccess, onError, }) => {
|
|
5
5
|
const { schema } = handler;
|
|
6
6
|
const execute = (input, { toolCallId }) => {
|
|
7
|
-
const { body, query, params } = input
|
|
7
|
+
const { body, query, params } = input;
|
|
8
8
|
const module = modules[rpcModuleName];
|
|
9
9
|
if (!module) {
|
|
10
10
|
throw new Error(`Module "${rpcModuleName}" not found.`);
|
|
@@ -25,7 +25,9 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
25
25
|
body,
|
|
26
26
|
query,
|
|
27
27
|
params,
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
|
+
.then((data) => onSuccess(data) ?? data)
|
|
30
|
+
.catch(onError);
|
|
29
31
|
}
|
|
30
32
|
return callControllerMethod({
|
|
31
33
|
toolCallId,
|
|
@@ -34,7 +36,9 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
34
36
|
body,
|
|
35
37
|
query,
|
|
36
38
|
params,
|
|
37
|
-
})
|
|
39
|
+
})
|
|
40
|
+
.then((data) => onSuccess(data) ?? data)
|
|
41
|
+
.catch(onError);
|
|
38
42
|
};
|
|
39
43
|
const parametersProperties = {
|
|
40
44
|
...(schema?.validation?.body
|
|
@@ -81,12 +85,21 @@ const defaultCallControllerMethod = async ({ handler, body, query, params, }) =>
|
|
|
81
85
|
params,
|
|
82
86
|
}));
|
|
83
87
|
};
|
|
84
|
-
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, }) {
|
|
88
|
+
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, onSuccess = (result) => result, onError = () => { }, }) {
|
|
85
89
|
const functions = Object.entries(modules)
|
|
86
90
|
.map(([rpcModuleName, module]) => {
|
|
87
91
|
return Object.entries(module)
|
|
88
92
|
.filter(([, handler]) => handler.schema?.openapi)
|
|
89
|
-
.map(([handlerName, handler]) => createLLMFunction({
|
|
93
|
+
.map(([handlerName, handler]) => createLLMFunction({
|
|
94
|
+
rpcModuleName,
|
|
95
|
+
handlerName,
|
|
96
|
+
handler,
|
|
97
|
+
callRPCMethod,
|
|
98
|
+
callControllerMethod,
|
|
99
|
+
modules,
|
|
100
|
+
onSuccess,
|
|
101
|
+
onError,
|
|
102
|
+
}));
|
|
90
103
|
})
|
|
91
104
|
.flat();
|
|
92
105
|
return {
|
|
@@ -22,17 +22,19 @@ declare const defaultCallControllerMethod: ({ handler, body, query, params, }: {
|
|
|
22
22
|
query?: KnownAny;
|
|
23
23
|
params?: KnownAny;
|
|
24
24
|
}) => Promise<any>;
|
|
25
|
-
export declare function createLLMFunctions({ modules, callRPCMethod, callControllerMethod, }: {
|
|
25
|
+
export declare function createLLMFunctions({ modules, callRPCMethod, callControllerMethod, onSuccess, onError, }: {
|
|
26
26
|
modules: Record<string, Record<string, (...args: KnownAny[]) => KnownAny>>;
|
|
27
27
|
callRPCMethod?: typeof defaultCallRPCMethod;
|
|
28
28
|
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
29
|
+
onSuccess?: (result: KnownAny) => void;
|
|
30
|
+
onError?: (error: Error) => void;
|
|
29
31
|
}): {
|
|
30
32
|
functions: {
|
|
31
|
-
execute: (input:
|
|
33
|
+
execute: (input: {
|
|
32
34
|
body?: KnownAny;
|
|
33
35
|
query?: KnownAny;
|
|
34
36
|
params?: KnownAny;
|
|
35
|
-
}
|
|
37
|
+
}, { toolCallId }: {
|
|
36
38
|
toolCallId: string;
|
|
37
39
|
}) => Promise<any>;
|
|
38
40
|
name: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, }) => {
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod, callControllerMethod, modules, onSuccess, onError, }) => {
|
|
5
5
|
const { schema } = handler;
|
|
6
6
|
const execute = (input, { toolCallId }) => {
|
|
7
|
-
const { body, query, params } = input
|
|
7
|
+
const { body, query, params } = input;
|
|
8
8
|
const module = modules[rpcModuleName];
|
|
9
9
|
if (!module) {
|
|
10
10
|
throw new Error(`Module "${rpcModuleName}" not found.`);
|
|
@@ -25,7 +25,9 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
25
25
|
body,
|
|
26
26
|
query,
|
|
27
27
|
params,
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
|
+
.then((data) => onSuccess(data) ?? data)
|
|
30
|
+
.catch(onError);
|
|
29
31
|
}
|
|
30
32
|
return callControllerMethod({
|
|
31
33
|
toolCallId,
|
|
@@ -34,7 +36,9 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
34
36
|
body,
|
|
35
37
|
query,
|
|
36
38
|
params,
|
|
37
|
-
})
|
|
39
|
+
})
|
|
40
|
+
.then((data) => onSuccess(data) ?? data)
|
|
41
|
+
.catch(onError);
|
|
38
42
|
};
|
|
39
43
|
const parametersProperties = {
|
|
40
44
|
...(schema?.validation?.body
|
|
@@ -81,12 +85,21 @@ const defaultCallControllerMethod = async ({ handler, body, query, params, }) =>
|
|
|
81
85
|
params,
|
|
82
86
|
}));
|
|
83
87
|
};
|
|
84
|
-
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, }) {
|
|
88
|
+
function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, callControllerMethod = defaultCallControllerMethod, onSuccess = (result) => result, onError = () => { }, }) {
|
|
85
89
|
const functions = Object.entries(modules)
|
|
86
90
|
.map(([rpcModuleName, module]) => {
|
|
87
91
|
return Object.entries(module)
|
|
88
92
|
.filter(([, handler]) => handler.schema?.openapi)
|
|
89
|
-
.map(([handlerName, handler]) => createLLMFunction({
|
|
93
|
+
.map(([handlerName, handler]) => createLLMFunction({
|
|
94
|
+
rpcModuleName,
|
|
95
|
+
handlerName,
|
|
96
|
+
handler,
|
|
97
|
+
callRPCMethod,
|
|
98
|
+
callControllerMethod,
|
|
99
|
+
modules,
|
|
100
|
+
onSuccess,
|
|
101
|
+
onError,
|
|
102
|
+
}));
|
|
90
103
|
})
|
|
91
104
|
.flat();
|
|
92
105
|
return {
|