@kevisual/ai 0.0.22 → 0.0.23
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,5 +1,6 @@
|
|
|
1
1
|
import * as _kevisual_permission from '@kevisual/permission';
|
|
2
2
|
import { Permission } from '@kevisual/permission';
|
|
3
|
+
import { Result } from '@kevisual/query';
|
|
3
4
|
|
|
4
5
|
type ChatMessage = {
|
|
5
6
|
role?: 'user' | 'assistant' | 'system' | 'tool';
|
|
@@ -467,12 +468,11 @@ declare class Kevisual extends BaseChat {
|
|
|
467
468
|
type CNBOptions = Partial<BaseChatOptions>;
|
|
468
469
|
declare class CNBChat extends BaseChat {
|
|
469
470
|
static BASE_URL: string;
|
|
471
|
+
repo: string;
|
|
470
472
|
constructor(options: CNBOptions & {
|
|
471
473
|
repo: string;
|
|
472
474
|
});
|
|
473
|
-
query(
|
|
474
|
-
repo: string;
|
|
475
|
-
}): void;
|
|
475
|
+
query(params: CNBQueryParam): Promise<Result<QueryRag[]>>;
|
|
476
476
|
}
|
|
477
477
|
type CNBQueryParam = {
|
|
478
478
|
query: string;
|
|
@@ -487,6 +487,18 @@ type CNBQueryParam = {
|
|
|
487
487
|
score_threshold?: number;
|
|
488
488
|
top_k?: number;
|
|
489
489
|
};
|
|
490
|
+
type QueryRag = {
|
|
491
|
+
chunk: string;
|
|
492
|
+
score: number;
|
|
493
|
+
metadata: {
|
|
494
|
+
hash: string;
|
|
495
|
+
name: string;
|
|
496
|
+
path: string;
|
|
497
|
+
position: string;
|
|
498
|
+
type: string;
|
|
499
|
+
url: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
490
502
|
|
|
491
503
|
declare class OllamaProvider extends Ollama {
|
|
492
504
|
}
|
|
@@ -19734,15 +19734,28 @@ class Kevisual extends BaseChat {
|
|
|
19734
19734
|
// src/provider/chat-adapter/cnb.ts
|
|
19735
19735
|
class CNBChat extends BaseChat {
|
|
19736
19736
|
static BASE_URL = "https://api.cnb.cool/{repo}/-/ai";
|
|
19737
|
+
repo;
|
|
19737
19738
|
constructor(options) {
|
|
19738
19739
|
const baseURL = CNBChat.BASE_URL.replace("{repo}", options.repo);
|
|
19739
|
-
super({ ...options, baseURL });
|
|
19740
|
+
super({ model: "hunyuan-a13b", ...options, baseURL });
|
|
19740
19741
|
}
|
|
19741
|
-
query(
|
|
19742
|
-
const
|
|
19743
|
-
this.post(
|
|
19744
|
-
data:
|
|
19742
|
+
async query(params) {
|
|
19743
|
+
const url = this.baseURL.replace("/ai", "/knowledge/base/query");
|
|
19744
|
+
const response = await this.post(url, {
|
|
19745
|
+
data: {
|
|
19746
|
+
score_threshold: 0.62,
|
|
19747
|
+
top_k: 10,
|
|
19748
|
+
...params
|
|
19749
|
+
}
|
|
19745
19750
|
});
|
|
19751
|
+
if (!response.ok) {
|
|
19752
|
+
throw new Error(`query API error: ${response.status} ${response.statusText}`);
|
|
19753
|
+
}
|
|
19754
|
+
const res = await response.json();
|
|
19755
|
+
return {
|
|
19756
|
+
code: 200,
|
|
19757
|
+
data: res || []
|
|
19758
|
+
};
|
|
19746
19759
|
}
|
|
19747
19760
|
}
|
|
19748
19761
|
|
package/dist/ai-provider.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _kevisual_permission from '@kevisual/permission';
|
|
2
2
|
import { Permission } from '@kevisual/permission';
|
|
3
|
+
import { Result } from '@kevisual/query';
|
|
3
4
|
|
|
4
5
|
type ChatMessage = {
|
|
5
6
|
role?: 'user' | 'assistant' | 'system' | 'tool';
|
|
@@ -467,12 +468,11 @@ declare class Kevisual extends BaseChat {
|
|
|
467
468
|
type CNBOptions = Partial<BaseChatOptions>;
|
|
468
469
|
declare class CNBChat extends BaseChat {
|
|
469
470
|
static BASE_URL: string;
|
|
471
|
+
repo: string;
|
|
470
472
|
constructor(options: CNBOptions & {
|
|
471
473
|
repo: string;
|
|
472
474
|
});
|
|
473
|
-
query(
|
|
474
|
-
repo: string;
|
|
475
|
-
}): void;
|
|
475
|
+
query(params: CNBQueryParam): Promise<Result<QueryRag[]>>;
|
|
476
476
|
}
|
|
477
477
|
type CNBQueryParam = {
|
|
478
478
|
query: string;
|
|
@@ -487,6 +487,18 @@ type CNBQueryParam = {
|
|
|
487
487
|
score_threshold?: number;
|
|
488
488
|
top_k?: number;
|
|
489
489
|
};
|
|
490
|
+
type QueryRag = {
|
|
491
|
+
chunk: string;
|
|
492
|
+
score: number;
|
|
493
|
+
metadata: {
|
|
494
|
+
hash: string;
|
|
495
|
+
name: string;
|
|
496
|
+
path: string;
|
|
497
|
+
position: string;
|
|
498
|
+
type: string;
|
|
499
|
+
url: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
490
502
|
|
|
491
503
|
declare class OllamaProvider extends Ollama {
|
|
492
504
|
}
|
package/dist/ai-provider.js
CHANGED
|
@@ -1619,15 +1619,28 @@ class Kevisual extends BaseChat {
|
|
|
1619
1619
|
// src/provider/chat-adapter/cnb.ts
|
|
1620
1620
|
class CNBChat extends BaseChat {
|
|
1621
1621
|
static BASE_URL = "https://api.cnb.cool/{repo}/-/ai";
|
|
1622
|
+
repo;
|
|
1622
1623
|
constructor(options) {
|
|
1623
1624
|
const baseURL = CNBChat.BASE_URL.replace("{repo}", options.repo);
|
|
1624
|
-
super({ ...options, baseURL });
|
|
1625
|
+
super({ model: "hunyuan-a13b", ...options, baseURL });
|
|
1625
1626
|
}
|
|
1626
|
-
query(
|
|
1627
|
-
const
|
|
1628
|
-
this.post(
|
|
1629
|
-
data:
|
|
1627
|
+
async query(params) {
|
|
1628
|
+
const url = this.baseURL.replace("/ai", "/knowledge/base/query");
|
|
1629
|
+
const response = await this.post(url, {
|
|
1630
|
+
data: {
|
|
1631
|
+
score_threshold: 0.62,
|
|
1632
|
+
top_k: 10,
|
|
1633
|
+
...params
|
|
1634
|
+
}
|
|
1630
1635
|
});
|
|
1636
|
+
if (!response.ok) {
|
|
1637
|
+
throw new Error(`query API error: ${response.status} ${response.statusText}`);
|
|
1638
|
+
}
|
|
1639
|
+
const res = await response.json();
|
|
1640
|
+
return {
|
|
1641
|
+
code: 200,
|
|
1642
|
+
data: res || []
|
|
1643
|
+
};
|
|
1631
1644
|
}
|
|
1632
1645
|
}
|
|
1633
1646
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/ai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "AI Center Services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/ai-center-services",
|
|
@@ -27,14 +27,19 @@
|
|
|
27
27
|
],
|
|
28
28
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
29
29
|
"license": "MIT",
|
|
30
|
-
"packageManager": "pnpm@10.28.
|
|
30
|
+
"packageManager": "pnpm@10.28.2",
|
|
31
31
|
"type": "module",
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"registry": "https://registry.npmjs.org/",
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
|
-
".":
|
|
37
|
+
".": {
|
|
38
|
+
"import": "./dist/ai-provider.js",
|
|
39
|
+
"node": "./dist/ai-provider.js",
|
|
40
|
+
"browser": "./dist/ai-provider-browser.js",
|
|
41
|
+
"types": "./dist/ai-provider.d.ts"
|
|
42
|
+
},
|
|
38
43
|
"./ai-provider": {
|
|
39
44
|
"import": "./dist/ai-provider.js",
|
|
40
45
|
"types": "./dist/ai-provider.d.ts"
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
}
|
|
49
54
|
},
|
|
50
55
|
"devDependencies": {
|
|
51
|
-
"@kevisual/router": "0.0.
|
|
56
|
+
"@kevisual/router": "0.0.62",
|
|
52
57
|
"@kevisual/types": "^0.0.12",
|
|
53
58
|
"@kevisual/use-config": "^1.0.28",
|
|
54
59
|
"@types/bun": "^1.3.6",
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import { BaseChat, BaseChatOptions } from '../core/chat.ts';
|
|
2
|
-
|
|
2
|
+
import { Result } from '@kevisual/query'
|
|
3
3
|
export type CNBOptions = Partial<BaseChatOptions>;
|
|
4
4
|
export class CNBChat extends BaseChat {
|
|
5
5
|
static BASE_URL = 'https://api.cnb.cool/{repo}/-/ai';
|
|
6
|
+
repo: string;
|
|
6
7
|
constructor(options: CNBOptions & { repo: string }) {
|
|
7
8
|
const baseURL = CNBChat.BASE_URL.replace('{repo}', options.repo);
|
|
8
|
-
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
|
9
|
+
super({ model: "hunyuan-a13b", ...(options as BaseChatOptions), baseURL: baseURL });
|
|
9
10
|
}
|
|
10
|
-
query(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
async query(params: CNBQueryParam): Promise<Result<QueryRag[]>> {
|
|
12
|
+
const url = this.baseURL.replace('/ai', '/knowledge/base/query');
|
|
13
|
+
const response = await this.post(url, {
|
|
14
|
+
data: {
|
|
15
|
+
score_threshold: 0.62,
|
|
16
|
+
top_k: 10,
|
|
17
|
+
...params
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`query API error: ${response.status} ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
const res = await response.json() as QueryRag[];
|
|
24
|
+
return {
|
|
25
|
+
code: 200,
|
|
26
|
+
data: res || [],
|
|
27
|
+
}
|
|
16
28
|
}
|
|
17
29
|
}
|
|
18
30
|
|
|
@@ -31,4 +43,17 @@ export type CNBQueryParam = {
|
|
|
31
43
|
},
|
|
32
44
|
score_threshold?: number;
|
|
33
45
|
top_k?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type QueryRag = {
|
|
49
|
+
chunk: string;
|
|
50
|
+
score: number;
|
|
51
|
+
metadata: {
|
|
52
|
+
hash: string;
|
|
53
|
+
name: string;
|
|
54
|
+
path: string;
|
|
55
|
+
position: string;
|
|
56
|
+
type: string; // code, text
|
|
57
|
+
url: string;
|
|
58
|
+
}
|
|
34
59
|
}
|