vovk 3.0.0-draft.175 → 3.0.0-draft.176
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.
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import { KnownAny } from '../types';
|
|
2
|
-
declare
|
|
3
|
-
toolCallId: string;
|
|
4
|
-
schema: KnownAny;
|
|
5
|
-
handler: (options: {
|
|
6
|
-
body?: KnownAny;
|
|
7
|
-
query?: KnownAny;
|
|
8
|
-
params?: KnownAny;
|
|
9
|
-
[key: string]: KnownAny;
|
|
10
|
-
}) => Promise<KnownAny>;
|
|
11
|
-
body?: KnownAny;
|
|
12
|
-
query?: KnownAny;
|
|
13
|
-
params?: KnownAny;
|
|
14
|
-
}) => Promise<any>;
|
|
15
|
-
declare const defaultCallControllerMethod: ({ handler, body, query, params, }: {
|
|
16
|
-
toolCallId: string;
|
|
17
|
-
schema?: KnownAny;
|
|
1
|
+
import { KnownAny, VovkHandlerSchema } from '../types';
|
|
2
|
+
declare function defaultCaller({ handler, body, query, params, }: {
|
|
18
3
|
handler: ((...args: KnownAny[]) => KnownAny) & {
|
|
19
|
-
func
|
|
4
|
+
func?: (req: KnownAny) => KnownAny;
|
|
5
|
+
isRPC?: boolean;
|
|
20
6
|
};
|
|
21
|
-
body
|
|
22
|
-
query
|
|
23
|
-
params
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
body: KnownAny;
|
|
8
|
+
query: KnownAny;
|
|
9
|
+
params: KnownAny;
|
|
10
|
+
schema: VovkHandlerSchema;
|
|
11
|
+
}, options: KnownAny): Promise<any>;
|
|
12
|
+
export declare function createLLMFunctions({ modules, caller, onSuccess, onError, }: {
|
|
26
13
|
modules: Record<string, Record<string, (...args: KnownAny[]) => KnownAny>>;
|
|
27
|
-
|
|
28
|
-
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
14
|
+
caller?: typeof defaultCaller;
|
|
29
15
|
onSuccess?: (result: KnownAny) => void;
|
|
30
16
|
onError?: (error: Error) => void;
|
|
31
17
|
}): {
|
|
@@ -34,9 +20,7 @@ export declare function createLLMFunctions({ modules, callRPCMethod, callControl
|
|
|
34
20
|
body?: KnownAny;
|
|
35
21
|
query?: KnownAny;
|
|
36
22
|
params?: KnownAny;
|
|
37
|
-
},
|
|
38
|
-
toolCallId: string;
|
|
39
|
-
}) => Promise<any>;
|
|
23
|
+
}, options: KnownAny) => Promise<any>;
|
|
40
24
|
name: string;
|
|
41
25
|
description: string;
|
|
42
26
|
parameters: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = ({ rpcModuleName, handlerName, handler,
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, caller, modules, onSuccess, onError, }) => {
|
|
5
5
|
const { schema } = handler;
|
|
6
|
-
const execute = (input,
|
|
6
|
+
const execute = (input, options) => {
|
|
7
7
|
const { body, query, params } = input;
|
|
8
8
|
const module = modules[rpcModuleName];
|
|
9
9
|
if (!module) {
|
|
@@ -13,32 +13,22 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
13
13
|
if (!handler) {
|
|
14
14
|
throw new Error(`Handler "${handlerName}" not found in module "${rpcModuleName}".`);
|
|
15
15
|
}
|
|
16
|
-
const { schema
|
|
16
|
+
const { schema } = handler;
|
|
17
17
|
if (!schema) {
|
|
18
18
|
throw new Error(`Schema for handler "${handlerName}" in module "${rpcModuleName}" not found.`);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
return callRPCMethod({
|
|
22
|
-
toolCallId,
|
|
23
|
-
schema,
|
|
24
|
-
handler,
|
|
25
|
-
body,
|
|
26
|
-
query,
|
|
27
|
-
params,
|
|
28
|
-
})
|
|
29
|
-
.then((data) => onSuccess(data) ?? data)
|
|
30
|
-
.catch(onError);
|
|
31
|
-
}
|
|
32
|
-
return callControllerMethod({
|
|
33
|
-
toolCallId,
|
|
20
|
+
return caller({
|
|
34
21
|
schema,
|
|
35
22
|
handler,
|
|
36
23
|
body,
|
|
37
24
|
query,
|
|
38
25
|
params,
|
|
39
|
-
})
|
|
26
|
+
}, options)
|
|
40
27
|
.then((data) => onSuccess(data) ?? data)
|
|
41
|
-
.catch(
|
|
28
|
+
.catch((error) => {
|
|
29
|
+
onError?.(error);
|
|
30
|
+
throw error;
|
|
31
|
+
});
|
|
42
32
|
};
|
|
43
33
|
const parametersProperties = {
|
|
44
34
|
...(schema?.validation?.body
|
|
@@ -71,21 +61,26 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
71
61
|
: { type: 'object', properties: {}, additionalProperties: false },
|
|
72
62
|
};
|
|
73
63
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
async function defaultCaller({ handler, body, query, params, }, options) {
|
|
65
|
+
((o) => o)(options); // no-op
|
|
66
|
+
if (handler.isRPC) {
|
|
67
|
+
return handler({
|
|
68
|
+
handler,
|
|
69
|
+
body,
|
|
70
|
+
query,
|
|
71
|
+
params,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (handler.func) {
|
|
75
|
+
return handler.func({
|
|
76
|
+
body,
|
|
77
|
+
query,
|
|
78
|
+
params,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Handler is not a valid RPC or controller method');
|
|
82
|
+
}
|
|
83
|
+
function createLLMFunctions({ modules, caller = defaultCaller, onSuccess = (result) => result, onError = () => { }, }) {
|
|
89
84
|
const functions = Object.entries(modules)
|
|
90
85
|
.map(([rpcModuleName, module]) => {
|
|
91
86
|
return Object.entries(module)
|
|
@@ -94,8 +89,7 @@ function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, cal
|
|
|
94
89
|
rpcModuleName,
|
|
95
90
|
handlerName,
|
|
96
91
|
handler,
|
|
97
|
-
|
|
98
|
-
callControllerMethod,
|
|
92
|
+
caller,
|
|
99
93
|
modules,
|
|
100
94
|
onSuccess,
|
|
101
95
|
onError,
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import { KnownAny } from '../types';
|
|
2
|
-
declare
|
|
3
|
-
toolCallId: string;
|
|
4
|
-
schema: KnownAny;
|
|
5
|
-
handler: (options: {
|
|
6
|
-
body?: KnownAny;
|
|
7
|
-
query?: KnownAny;
|
|
8
|
-
params?: KnownAny;
|
|
9
|
-
[key: string]: KnownAny;
|
|
10
|
-
}) => Promise<KnownAny>;
|
|
11
|
-
body?: KnownAny;
|
|
12
|
-
query?: KnownAny;
|
|
13
|
-
params?: KnownAny;
|
|
14
|
-
}) => Promise<any>;
|
|
15
|
-
declare const defaultCallControllerMethod: ({ handler, body, query, params, }: {
|
|
16
|
-
toolCallId: string;
|
|
17
|
-
schema?: KnownAny;
|
|
1
|
+
import { KnownAny, VovkHandlerSchema } from '../types';
|
|
2
|
+
declare function defaultCaller({ handler, body, query, params, }: {
|
|
18
3
|
handler: ((...args: KnownAny[]) => KnownAny) & {
|
|
19
|
-
func
|
|
4
|
+
func?: (req: KnownAny) => KnownAny;
|
|
5
|
+
isRPC?: boolean;
|
|
20
6
|
};
|
|
21
|
-
body
|
|
22
|
-
query
|
|
23
|
-
params
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
body: KnownAny;
|
|
8
|
+
query: KnownAny;
|
|
9
|
+
params: KnownAny;
|
|
10
|
+
schema: VovkHandlerSchema;
|
|
11
|
+
}, options: KnownAny): Promise<any>;
|
|
12
|
+
export declare function createLLMFunctions({ modules, caller, onSuccess, onError, }: {
|
|
26
13
|
modules: Record<string, Record<string, (...args: KnownAny[]) => KnownAny>>;
|
|
27
|
-
|
|
28
|
-
callControllerMethod?: typeof defaultCallControllerMethod;
|
|
14
|
+
caller?: typeof defaultCaller;
|
|
29
15
|
onSuccess?: (result: KnownAny) => void;
|
|
30
16
|
onError?: (error: Error) => void;
|
|
31
17
|
}): {
|
|
@@ -34,9 +20,7 @@ export declare function createLLMFunctions({ modules, callRPCMethod, callControl
|
|
|
34
20
|
body?: KnownAny;
|
|
35
21
|
query?: KnownAny;
|
|
36
22
|
params?: KnownAny;
|
|
37
|
-
},
|
|
38
|
-
toolCallId: string;
|
|
39
|
-
}) => Promise<any>;
|
|
23
|
+
}, options: KnownAny) => Promise<any>;
|
|
40
24
|
name: string;
|
|
41
25
|
description: string;
|
|
42
26
|
parameters: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLLMFunctions = createLLMFunctions;
|
|
4
|
-
const createLLMFunction = ({ rpcModuleName, handlerName, handler,
|
|
4
|
+
const createLLMFunction = ({ rpcModuleName, handlerName, handler, caller, modules, onSuccess, onError, }) => {
|
|
5
5
|
const { schema } = handler;
|
|
6
|
-
const execute = (input,
|
|
6
|
+
const execute = (input, options) => {
|
|
7
7
|
const { body, query, params } = input;
|
|
8
8
|
const module = modules[rpcModuleName];
|
|
9
9
|
if (!module) {
|
|
@@ -13,32 +13,22 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
13
13
|
if (!handler) {
|
|
14
14
|
throw new Error(`Handler "${handlerName}" not found in module "${rpcModuleName}".`);
|
|
15
15
|
}
|
|
16
|
-
const { schema
|
|
16
|
+
const { schema } = handler;
|
|
17
17
|
if (!schema) {
|
|
18
18
|
throw new Error(`Schema for handler "${handlerName}" in module "${rpcModuleName}" not found.`);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
return callRPCMethod({
|
|
22
|
-
toolCallId,
|
|
23
|
-
schema,
|
|
24
|
-
handler,
|
|
25
|
-
body,
|
|
26
|
-
query,
|
|
27
|
-
params,
|
|
28
|
-
})
|
|
29
|
-
.then((data) => onSuccess(data) ?? data)
|
|
30
|
-
.catch(onError);
|
|
31
|
-
}
|
|
32
|
-
return callControllerMethod({
|
|
33
|
-
toolCallId,
|
|
20
|
+
return caller({
|
|
34
21
|
schema,
|
|
35
22
|
handler,
|
|
36
23
|
body,
|
|
37
24
|
query,
|
|
38
25
|
params,
|
|
39
|
-
})
|
|
26
|
+
}, options)
|
|
40
27
|
.then((data) => onSuccess(data) ?? data)
|
|
41
|
-
.catch(
|
|
28
|
+
.catch((error) => {
|
|
29
|
+
onError?.(error);
|
|
30
|
+
throw error;
|
|
31
|
+
});
|
|
42
32
|
};
|
|
43
33
|
const parametersProperties = {
|
|
44
34
|
...(schema?.validation?.body
|
|
@@ -71,21 +61,26 @@ const createLLMFunction = ({ rpcModuleName, handlerName, handler, callRPCMethod,
|
|
|
71
61
|
: { type: 'object', properties: {}, additionalProperties: false },
|
|
72
62
|
};
|
|
73
63
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
async function defaultCaller({ handler, body, query, params, }, options) {
|
|
65
|
+
((o) => o)(options); // no-op
|
|
66
|
+
if (handler.isRPC) {
|
|
67
|
+
return handler({
|
|
68
|
+
handler,
|
|
69
|
+
body,
|
|
70
|
+
query,
|
|
71
|
+
params,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (handler.func) {
|
|
75
|
+
return handler.func({
|
|
76
|
+
body,
|
|
77
|
+
query,
|
|
78
|
+
params,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Handler is not a valid RPC or controller method');
|
|
82
|
+
}
|
|
83
|
+
function createLLMFunctions({ modules, caller = defaultCaller, onSuccess = (result) => result, onError = () => { }, }) {
|
|
89
84
|
const functions = Object.entries(modules)
|
|
90
85
|
.map(([rpcModuleName, module]) => {
|
|
91
86
|
return Object.entries(module)
|
|
@@ -94,8 +89,7 @@ function createLLMFunctions({ modules, callRPCMethod = defaultCallRPCMethod, cal
|
|
|
94
89
|
rpcModuleName,
|
|
95
90
|
handlerName,
|
|
96
91
|
handler,
|
|
97
|
-
|
|
98
|
-
callControllerMethod,
|
|
92
|
+
caller,
|
|
99
93
|
modules,
|
|
100
94
|
onSuccess,
|
|
101
95
|
onError,
|