@dj1029/plugin-smart-sl 0.0.22 → 0.0.25
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.js +1 -1
- package/dist/lib/http-client.service.d.ts.map +1 -1
- package/dist/lib/http-client.service.js +4 -0
- package/dist/lib/smart.strategy.js +2 -2
- package/dist/lib/tool.d.ts +1 -1
- package/dist/lib/tool.d.ts.map +1 -1
- package/dist/lib/tool.js +6 -10
- package/dist/lib/toolset.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const plugin = {
|
|
|
20
20
|
},
|
|
21
21
|
displayName: 'SmartBI Plugin',
|
|
22
22
|
description: 'Integrate SmartBI functionality',
|
|
23
|
-
keywords: ['SmartBI', '
|
|
23
|
+
keywords: ['SmartBI', 'document source', 'knowledge', 'integration'],
|
|
24
24
|
author: 'dengjin',
|
|
25
25
|
},
|
|
26
26
|
/** 描述插件的配置Schema */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.service.d.ts","sourceRoot":"","sources":["../../src/lib/http-client.service.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,OAAO,+BAGX,CAAC;
|
|
1
|
+
{"version":3,"file":"http-client.service.d.ts","sourceRoot":"","sources":["../../src/lib/http-client.service.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,OAAO,+BAGX,CAAC;AAkIH,eAAe,OAAO,CAAA;AAGtB,qBACa,iBAAiB;IAC1B,OAAO,CAAC,aAAa,CAAC;;IAqBtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAC,IAAI,CAAC,EAAE,GAAG;IAI1B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAK/B"}
|
|
@@ -15,6 +15,10 @@ const service = axios.create({
|
|
|
15
15
|
service.interceptors.request.use(config => {
|
|
16
16
|
// 是否需要设置 token
|
|
17
17
|
console.log("axios1 ---- config ---- ", config);
|
|
18
|
+
const isToken = config.headers.isToken === false;
|
|
19
|
+
if (!isToken) {
|
|
20
|
+
config.headers['Authorization'] = `Bearer ${config.headers.token}`;
|
|
21
|
+
}
|
|
18
22
|
// get请求映射params参数
|
|
19
23
|
if (config.method === 'get' && config.params) {
|
|
20
24
|
let url = config.url + '?' + tansParams(config.params);
|
|
@@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
|
|
3
3
|
import { ToolsetStrategy } from '@xpert-ai/plugin-sdk';
|
|
4
4
|
import { SmartBIName, iconImage } from './types.js';
|
|
5
5
|
import { SmartToolset } from "./toolset.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getSmartBIAuthToken } from "./tool.js";
|
|
7
7
|
let SmartStrategy = class SmartStrategy {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.meta = {
|
|
@@ -45,7 +45,7 @@ let SmartStrategy = class SmartStrategy {
|
|
|
45
45
|
}
|
|
46
46
|
createTools() {
|
|
47
47
|
return [
|
|
48
|
-
|
|
48
|
+
getSmartBIAuthToken()
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
};
|
package/dist/lib/tool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getSmartBIAuthToken(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
3
3
|
username: z.ZodString;
|
|
4
4
|
password: z.ZodString;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
package/dist/lib/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/lib/tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/lib/tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,wBAAgB,mBAAmB;;;;;;;;;;;;;;;yDA6BlC"}
|
package/dist/lib/tool.js
CHANGED
|
@@ -2,21 +2,17 @@ import { tool } from '@langchain/core/tools';
|
|
|
2
2
|
import { getErrorMessage } from '@xpert-ai/plugin-sdk';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import request from "./http-client.service.js";
|
|
5
|
-
export function
|
|
5
|
+
export function getSmartBIAuthToken() {
|
|
6
6
|
return tool(async (input) => {
|
|
7
7
|
try {
|
|
8
|
-
console.log("input ---------- ", input);
|
|
9
|
-
// const httpClient = new HttpClientService();
|
|
10
|
-
// const res = await httpClient.post('/login', input);
|
|
11
|
-
// console.log("res ---------- ", res.data.token)
|
|
12
|
-
// return res.data.token;
|
|
13
8
|
const req = await request({
|
|
14
9
|
url: '/login',
|
|
15
10
|
method: 'post',
|
|
16
11
|
data: input,
|
|
17
12
|
headers: {
|
|
18
|
-
isToken: false
|
|
19
|
-
|
|
13
|
+
isToken: false,
|
|
14
|
+
token: 'abcdefghijklmnopqrstuvwsyz'
|
|
15
|
+
}
|
|
20
16
|
});
|
|
21
17
|
console.log("req ---------- ", req);
|
|
22
18
|
return req;
|
|
@@ -25,8 +21,8 @@ export function buildSmartTool() {
|
|
|
25
21
|
return "I don't know how to do that because: " + getErrorMessage(error);
|
|
26
22
|
}
|
|
27
23
|
}, {
|
|
28
|
-
name: '
|
|
29
|
-
description:
|
|
24
|
+
name: '获取认证Token',
|
|
25
|
+
description: `获取smartBI系统的认证token`,
|
|
30
26
|
/** 这里决定了 测试的参数 */
|
|
31
27
|
schema: z.object({
|
|
32
28
|
username: z.string().describe('连接用户名'),
|
package/dist/lib/toolset.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BuiltinToolset } from '@xpert-ai/plugin-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { getSmartBIAuthToken } from './tool.js';
|
|
3
3
|
export class SmartToolset extends BuiltinToolset {
|
|
4
4
|
async _validateCredentials(credentials) {
|
|
5
5
|
// No credentials needed for calculator toolset
|
|
6
6
|
}
|
|
7
7
|
async initTools() {
|
|
8
|
-
this.tools = [
|
|
8
|
+
this.tools = [getSmartBIAuthToken()];
|
|
9
9
|
return this.tools;
|
|
10
10
|
}
|
|
11
11
|
}
|