@llmbridge/plugin-logging 0.0.4 → 0.1.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/dist/index.d.mts +3 -13
- package/dist/index.d.ts +3 -13
- package/dist/index.js +11 -12
- package/dist/index.mjs +11 -12
- package/package.json +7 -5
package/dist/index.d.mts
CHANGED
|
@@ -7,19 +7,9 @@ declare function generateRandomDigits(length: number): string;
|
|
|
7
7
|
declare class LoggingPlugin implements LLMBridge.Plugin<void, string, void, void> {
|
|
8
8
|
private options;
|
|
9
9
|
constructor(options: LoggingPluginOptions);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
beforeExec(params: any): Promise<string>;
|
|
15
|
-
afterExec({ beforeResponse, response }: {
|
|
16
|
-
beforeResponse: string;
|
|
17
|
-
response: any;
|
|
18
|
-
}): Promise<void>;
|
|
19
|
-
beforeToolExec(tool: LLMBridge.Tool, counter: number, input: any, context: LLMBridge.PluginCompletionContext): Promise<void>;
|
|
20
|
-
afterToolExec({ response }: {
|
|
21
|
-
response: any;
|
|
22
|
-
}): Promise<void>;
|
|
10
|
+
wrapRun(next: () => Promise<LLMBridge.Response>, context: LLMBridge.PluginCompletionContext): Promise<LLMBridge.Response>;
|
|
11
|
+
wrapExec(next: (params: any) => Promise<any>, params: any, context: LLMBridge.PluginCompletionContext): Promise<any>;
|
|
12
|
+
wrapToolExec(next: (tool: LLMBridge.Tool, counter: number, input: any) => Promise<any>, tool: LLMBridge.Tool, counter: number, input: any, context: LLMBridge.PluginCompletionContext): Promise<any>;
|
|
23
13
|
createLogFiles(requestId: string, type: 'request' | 'response', data: any): void;
|
|
24
14
|
createTxtFile(filePath: string, data: any): void;
|
|
25
15
|
objectToTxt(obj: any, prefix?: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,19 +7,9 @@ declare function generateRandomDigits(length: number): string;
|
|
|
7
7
|
declare class LoggingPlugin implements LLMBridge.Plugin<void, string, void, void> {
|
|
8
8
|
private options;
|
|
9
9
|
constructor(options: LoggingPluginOptions);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
beforeExec(params: any): Promise<string>;
|
|
15
|
-
afterExec({ beforeResponse, response }: {
|
|
16
|
-
beforeResponse: string;
|
|
17
|
-
response: any;
|
|
18
|
-
}): Promise<void>;
|
|
19
|
-
beforeToolExec(tool: LLMBridge.Tool, counter: number, input: any, context: LLMBridge.PluginCompletionContext): Promise<void>;
|
|
20
|
-
afterToolExec({ response }: {
|
|
21
|
-
response: any;
|
|
22
|
-
}): Promise<void>;
|
|
10
|
+
wrapRun(next: () => Promise<LLMBridge.Response>, context: LLMBridge.PluginCompletionContext): Promise<LLMBridge.Response>;
|
|
11
|
+
wrapExec(next: (params: any) => Promise<any>, params: any, context: LLMBridge.PluginCompletionContext): Promise<any>;
|
|
12
|
+
wrapToolExec(next: (tool: LLMBridge.Tool, counter: number, input: any) => Promise<any>, tool: LLMBridge.Tool, counter: number, input: any, context: LLMBridge.PluginCompletionContext): Promise<any>;
|
|
23
13
|
createLogFiles(requestId: string, type: 'request' | 'response', data: any): void;
|
|
24
14
|
createTxtFile(filePath: string, data: any): void;
|
|
25
15
|
objectToTxt(obj: any, prefix?: string): string;
|
package/dist/index.js
CHANGED
|
@@ -47,26 +47,25 @@ var LoggingPlugin = class {
|
|
|
47
47
|
constructor(options) {
|
|
48
48
|
this.options = options;
|
|
49
49
|
}
|
|
50
|
-
async
|
|
50
|
+
async wrapRun(next, context) {
|
|
51
51
|
console.log("run", context.model);
|
|
52
|
-
|
|
53
|
-
async afterRun({ response }) {
|
|
52
|
+
const response = await next();
|
|
54
53
|
const lastResponsePath = import_path.default.join(this.options.folder, "last_response.json");
|
|
55
54
|
import_fs.default.writeFileSync(lastResponsePath, JSON.stringify(response, null, 2));
|
|
55
|
+
return response;
|
|
56
56
|
}
|
|
57
|
-
async
|
|
57
|
+
async wrapExec(next, params, context) {
|
|
58
58
|
const requestId = generateRandomDigits(4);
|
|
59
59
|
this.createLogFiles(requestId, "request", params);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.createLogFiles(beforeResponse, "response", response);
|
|
60
|
+
const response = await next(params);
|
|
61
|
+
this.createLogFiles(requestId, "response", response);
|
|
62
|
+
return response;
|
|
64
63
|
}
|
|
65
|
-
async
|
|
64
|
+
async wrapToolExec(next, tool, counter, input, context) {
|
|
66
65
|
console.log(`run (${counter + 1}/${context.options.tools?.usesLimit}) tool ${tool.name}`, input);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const result = await next(tool, counter, input);
|
|
67
|
+
console.log(`tool response`, result);
|
|
68
|
+
return result;
|
|
70
69
|
}
|
|
71
70
|
createLogFiles(requestId, type, data) {
|
|
72
71
|
const currentDate = (0, import_moment.default)();
|
package/dist/index.mjs
CHANGED
|
@@ -10,26 +10,25 @@ var LoggingPlugin = class {
|
|
|
10
10
|
constructor(options) {
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
|
-
async
|
|
13
|
+
async wrapRun(next, context) {
|
|
14
14
|
console.log("run", context.model);
|
|
15
|
-
|
|
16
|
-
async afterRun({ response }) {
|
|
15
|
+
const response = await next();
|
|
17
16
|
const lastResponsePath = path.join(this.options.folder, "last_response.json");
|
|
18
17
|
fs.writeFileSync(lastResponsePath, JSON.stringify(response, null, 2));
|
|
18
|
+
return response;
|
|
19
19
|
}
|
|
20
|
-
async
|
|
20
|
+
async wrapExec(next, params, context) {
|
|
21
21
|
const requestId = generateRandomDigits(4);
|
|
22
22
|
this.createLogFiles(requestId, "request", params);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.createLogFiles(beforeResponse, "response", response);
|
|
23
|
+
const response = await next(params);
|
|
24
|
+
this.createLogFiles(requestId, "response", response);
|
|
25
|
+
return response;
|
|
27
26
|
}
|
|
28
|
-
async
|
|
27
|
+
async wrapToolExec(next, tool, counter, input, context) {
|
|
29
28
|
console.log(`run (${counter + 1}/${context.options.tools?.usesLimit}) tool ${tool.name}`, input);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const result = await next(tool, counter, input);
|
|
30
|
+
console.log(`tool response`, result);
|
|
31
|
+
return result;
|
|
33
32
|
}
|
|
34
33
|
createLogFiles(requestId, type, data) {
|
|
35
34
|
const currentDate = moment();
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llmbridge/plugin-logging",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Logging plugin for LLMBridge",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "
|
|
9
|
+
"build": "npm run clean && tsup src/index.ts --format cjs,esm --dts",
|
|
10
10
|
"test": "vitest run",
|
|
11
|
-
"clean": "
|
|
11
|
+
"clean": "rimraf dist",
|
|
12
|
+
"build:publish": "npm run build && npm publish"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"llm",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"moment": "^2.30.1"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
|
-
"@llmbridge/core": ">=0.0
|
|
30
|
+
"@llmbridge/core": ">=0.1.0 <0.2.0",
|
|
30
31
|
"moment": "^2.29.0",
|
|
31
32
|
"typescript": "^5.0.0"
|
|
32
33
|
},
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
"@types/node": "^18.11.9",
|
|
35
36
|
"typescript": "^5.7.3",
|
|
36
37
|
"tsup": "^8.4.0",
|
|
37
|
-
"vitest": "^3.0.7"
|
|
38
|
+
"vitest": "^3.0.7",
|
|
39
|
+
"rimraf": "^5.0.5"
|
|
38
40
|
},
|
|
39
41
|
"author": "",
|
|
40
42
|
"license": "MIT"
|