viho 0.0.9 → 0.1.1
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/bin/viho-ask.js +3 -8
- package/bin/viho-chat.js +3 -10
- package/bin/viho-expert.js +78 -0
- package/bin/viho.js +1 -0
- package/package.json +3 -2
- package/src/experts/antd.md +23127 -0
- package/src/experts/daisyui.md +2228 -0
- package/src/experts/experts.js +10 -0
- package/src/llm.js +25 -2
- package/src/util.js +24 -0
package/bin/viho-ask.js
CHANGED
|
@@ -6,8 +6,7 @@ const LLM = require('qiao-llm');
|
|
|
6
6
|
|
|
7
7
|
// util
|
|
8
8
|
const { ask } = require('../src/llm.js');
|
|
9
|
-
const {
|
|
10
|
-
const { getDB, printLogo } = require('../src/util.js');
|
|
9
|
+
const { getDB, preLLMAsk } = require('../src/util.js');
|
|
11
10
|
const db = getDB();
|
|
12
11
|
|
|
13
12
|
// cmd
|
|
@@ -15,9 +14,8 @@ cli.cmd
|
|
|
15
14
|
.command('ask [modelName]')
|
|
16
15
|
.description('Ask a question to an AI model')
|
|
17
16
|
.action(async (modelName) => {
|
|
18
|
-
//
|
|
19
|
-
const model = await
|
|
20
|
-
if (!model) return;
|
|
17
|
+
// pre ask
|
|
18
|
+
const model = await preLLMAsk('ask', db, modelName);
|
|
21
19
|
|
|
22
20
|
// llm
|
|
23
21
|
const llm = LLM({
|
|
@@ -25,9 +23,6 @@ cli.cmd
|
|
|
25
23
|
baseURL: model.baseURL,
|
|
26
24
|
});
|
|
27
25
|
|
|
28
|
-
// logo
|
|
29
|
-
printLogo();
|
|
30
|
-
|
|
31
26
|
// ask
|
|
32
27
|
await ask(llm, model);
|
|
33
28
|
});
|
package/bin/viho-chat.js
CHANGED
|
@@ -6,8 +6,7 @@ const LLM = require('qiao-llm');
|
|
|
6
6
|
|
|
7
7
|
// util
|
|
8
8
|
const { ask } = require('../src/llm.js');
|
|
9
|
-
const {
|
|
10
|
-
const { getDB, printLogo } = require('../src/util.js');
|
|
9
|
+
const { getDB, preLLMAsk } = require('../src/util.js');
|
|
11
10
|
const db = getDB();
|
|
12
11
|
|
|
13
12
|
// cmd
|
|
@@ -15,9 +14,8 @@ cli.cmd
|
|
|
15
14
|
.command('chat [modelName]')
|
|
16
15
|
.description('Start a continuous chat session with an AI model')
|
|
17
16
|
.action(async (modelName) => {
|
|
18
|
-
//
|
|
19
|
-
const model = await
|
|
20
|
-
if (!model) return;
|
|
17
|
+
// pre ask
|
|
18
|
+
const model = await preLLMAsk('chat', db, modelName);
|
|
21
19
|
|
|
22
20
|
// init
|
|
23
21
|
const llm = LLM({
|
|
@@ -25,11 +23,6 @@ cli.cmd
|
|
|
25
23
|
baseURL: model.baseURL,
|
|
26
24
|
});
|
|
27
25
|
|
|
28
|
-
// logo
|
|
29
|
-
printLogo();
|
|
30
|
-
console.log(cli.colors.cyan(`Welcome to viho chat! Using model: ${model.modelName}`));
|
|
31
|
-
console.log(cli.colors.gray('Press Ctrl+C to exit\n'));
|
|
32
|
-
|
|
33
26
|
// chat
|
|
34
27
|
let keepChatting = true;
|
|
35
28
|
while (keepChatting) {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// qiao
|
|
2
|
+
const cli = require('qiao-cli');
|
|
3
|
+
|
|
4
|
+
// llm
|
|
5
|
+
const LLM = require('qiao-llm');
|
|
6
|
+
|
|
7
|
+
// util
|
|
8
|
+
const { expertAsk } = require('../src/llm.js');
|
|
9
|
+
const { experts } = require('../src/experts/experts.js');
|
|
10
|
+
const { getDB, printLogo, preLLMAsk } = require('../src/util.js');
|
|
11
|
+
const db = getDB();
|
|
12
|
+
|
|
13
|
+
// actions
|
|
14
|
+
const actions = ['list', ...experts.map((e) => e.name)];
|
|
15
|
+
|
|
16
|
+
// model
|
|
17
|
+
cli.cmd
|
|
18
|
+
.command('expert <action>')
|
|
19
|
+
.description('Manage expert resources (list, daisyui, ...)')
|
|
20
|
+
.action((action) => {
|
|
21
|
+
if (!actions.includes(action)) {
|
|
22
|
+
console.log(cli.colors.red(`Invalid action. Use: ${actions.join(', ')}`));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// actions
|
|
27
|
+
if (action === 'list') {
|
|
28
|
+
expertList();
|
|
29
|
+
} else {
|
|
30
|
+
// all other actions are expert names
|
|
31
|
+
expertAskByName(action);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* expertList
|
|
37
|
+
*/
|
|
38
|
+
async function expertList() {
|
|
39
|
+
// logo
|
|
40
|
+
printLogo();
|
|
41
|
+
|
|
42
|
+
console.log(cli.colors.cyan('Available experts:'));
|
|
43
|
+
console.log();
|
|
44
|
+
|
|
45
|
+
if (!experts || experts.length === 0) {
|
|
46
|
+
console.log(cli.colors.gray('No experts available.'));
|
|
47
|
+
console.log();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
experts.forEach((expert) => {
|
|
52
|
+
console.log(cli.colors.white(` • ${expert.name}`));
|
|
53
|
+
console.log(cli.colors.gray(` URL: ${expert.url}`));
|
|
54
|
+
console.log();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* expertAskByName
|
|
60
|
+
* @param {*} expertName
|
|
61
|
+
*/
|
|
62
|
+
async function expertAskByName(expertName) {
|
|
63
|
+
// pre ask
|
|
64
|
+
const model = await preLLMAsk(`expert (${expertName})`, db);
|
|
65
|
+
if (!model) return;
|
|
66
|
+
|
|
67
|
+
// init
|
|
68
|
+
const llm = LLM({
|
|
69
|
+
apiKey: model.apiKey,
|
|
70
|
+
baseURL: model.baseURL,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// chat
|
|
74
|
+
let keepChatting = true;
|
|
75
|
+
while (keepChatting) {
|
|
76
|
+
await expertAsk(llm, model, expertName);
|
|
77
|
+
}
|
|
78
|
+
}
|
package/bin/viho.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viho",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A lightweight CLI tool for managing and interacting with AI models",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"qiao-cli": "^5.0.0",
|
|
43
43
|
"qiao-config": "^5.0.1",
|
|
44
|
+
"qiao-file": "^5.0.1",
|
|
44
45
|
"qiao-llm": "^0.2.5"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "30ba092c8b2ab0e52894506eb93fdd77a26e4e36"
|
|
47
48
|
}
|