viho 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -1,14 +1,21 @@
1
- # viho
1
+ <p align="center">
2
+ <img src="./logo.png" alt="viho logo" width="200"/>
3
+ </p>
2
4
 
3
- A lightweight CLI tool for managing and chatting with AI models.
5
+ <h1 align="center">viho</h1>
4
6
 
5
- [![npm version](https://img.shields.io/npm/v/viho.svg)](https://www.npmjs.com/package/viho)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ <p align="center">A lightweight CLI tool for managing and interacting with AI models.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/viho"><img src="https://img.shields.io/npm/v/viho.svg" alt="npm version"></a>
11
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
12
+ </p>
7
13
 
8
14
  ## Features
9
15
 
10
16
  - Multiple AI model management
11
- - Interactive chat with streaming responses
17
+ - Interactive Q&A with streaming responses
18
+ - Continuous chat sessions for multi-turn conversations
12
19
  - Support for thinking mode (enabled/disabled/auto)
13
20
  - Configurable API endpoints (OpenAI, Anthropic, custom providers)
14
21
  - Default model configuration
@@ -41,10 +48,10 @@ viho model add
41
48
  viho model default
42
49
  ```
43
50
 
44
- 3. Start chatting:
51
+ 3. Start asking questions:
45
52
 
46
53
  ```bash
47
- viho chat
54
+ viho ask
48
55
  ```
49
56
 
50
57
  ## Commands
@@ -91,31 +98,56 @@ Set a default model for chat sessions:
91
98
  viho model default
92
99
  ```
93
100
 
94
- ### Chat
101
+ ### Ask
95
102
 
96
- #### `viho chat [modelName]`
103
+ #### `viho ask [modelName]`
97
104
 
98
- Start an interactive chat session with an AI model.
105
+ Ask a question to an AI model.
99
106
 
100
107
  If no model name is provided, uses the default model:
101
108
 
102
109
  ```bash
103
- viho chat
110
+ viho ask
104
111
  ```
105
112
 
106
113
  Or specify a model explicitly:
107
114
 
108
115
  ```bash
109
- viho chat mymodel
116
+ viho ask mymodel
110
117
  ```
111
118
 
112
- The chat interface includes:
119
+ The interface includes:
113
120
 
114
121
  - Editor-based question input
115
122
  - Streaming responses
116
123
  - Visual thinking process (when enabled)
117
124
  - Colored output for better readability
118
125
 
126
+ ### Chat
127
+
128
+ #### `viho chat [modelName]`
129
+
130
+ Start a continuous chat session with an AI model for multi-turn conversations.
131
+
132
+ If no model name is provided, uses the default model:
133
+
134
+ ```bash
135
+ viho chat
136
+ ```
137
+
138
+ Or specify a model explicitly:
139
+
140
+ ```bash
141
+ viho chat mymodel
142
+ ```
143
+
144
+ The chat session runs in a loop, allowing you to ask multiple questions continuously without restarting the command. Each question uses the same model configuration but starts a fresh conversation context.
145
+
146
+ **Note:** The main difference between `viho ask` and `viho chat`:
147
+
148
+ - `viho ask` - Single question, exits after receiving the answer
149
+ - `viho chat` - Continuous loop, keeps asking for new questions until manually stopped (Ctrl+C)
150
+
119
151
  ## Configuration
120
152
 
121
153
  Configuration is stored in `~/viho.json`. You can manage all settings through the CLI commands.
@@ -176,8 +208,8 @@ viho model add
176
208
  # Set it as default
177
209
  viho model default
178
210
 
179
- # Start chatting
180
- viho chat
211
+ # Start asking questions
212
+ viho ask
181
213
  ```
182
214
 
183
215
  ## Dependencies
package/bin/util.js CHANGED
@@ -4,6 +4,9 @@ const os = require('os');
4
4
  // path
5
5
  const path = require('path');
6
6
 
7
+ // qiao
8
+ const cli = require('qiao-cli');
9
+
7
10
  // db
8
11
  const DB = require('qiao-config');
9
12
 
@@ -15,3 +18,86 @@ exports.getDB = () => {
15
18
  const dbPath = path.resolve(os.homedir(), './viho.json');
16
19
  return DB(dbPath);
17
20
  };
21
+
22
+ /**
23
+ * printLogo
24
+ */
25
+ exports.printLogo = () => {
26
+ console.log(
27
+ cli.colors.green(`
28
+ ██╗ ██╗██╗██╗ ██╗ ██████╗
29
+ ██║ ██║██║██║ ██║██╔═══██╗
30
+ ██║ ██║██║███████║██║ ██║
31
+ ╚██╗ ██╔╝██║██╔══██║██║ ██║
32
+ ╚████╔╝ ██║██║ ██║╚██████╔╝
33
+ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
34
+ `),
35
+ );
36
+ };
37
+
38
+ /**
39
+ * ask
40
+ * @param {*} llm
41
+ * @param {*} model
42
+ */
43
+ exports.ask = async (llm, model) => {
44
+ // ask
45
+ const questions = [
46
+ {
47
+ type: 'editor',
48
+ name: 'content',
49
+ message: 'Your question:',
50
+ },
51
+ ];
52
+ const answers = await cli.ask(questions);
53
+
54
+ // answers
55
+ console.log();
56
+ console.log(cli.colors.gray('Question:'));
57
+ console.log(cli.colors.gray(answers.content));
58
+ console.log();
59
+
60
+ // chat
61
+ const chatOptions = {
62
+ model: model.modelID,
63
+ messages: [
64
+ { role: 'system', content: 'You are a helpful AI assistant' },
65
+ { role: 'user', content: answers.content },
66
+ ],
67
+ thinking: {
68
+ type: model.modelThinking,
69
+ },
70
+ };
71
+
72
+ // callback options
73
+ const callbackOptions = {
74
+ firstThinkingCallback: () => {
75
+ console.log();
76
+ console.log(cli.colors.gray('[Thinking...]'));
77
+ console.log();
78
+ },
79
+ thinkingCallback: (msg) => {
80
+ process.stdout.write(cli.colors.gray(msg));
81
+ },
82
+ firstContentCallback: () => {
83
+ console.log();
84
+ console.log(cli.colors.cyan('[Response]'));
85
+ console.log();
86
+ },
87
+ contentCallback: (msg) => {
88
+ process.stdout.write(msg);
89
+ },
90
+ endCallback: () => {
91
+ console.log();
92
+ console.log();
93
+ },
94
+ errorCallback: (error) => {
95
+ console.log();
96
+ console.log(cli.colors.red('Error:'));
97
+ console.log(error);
98
+ },
99
+ };
100
+
101
+ // go
102
+ await llm.chatWithStreaming(chatOptions, callbackOptions);
103
+ };
@@ -0,0 +1,43 @@
1
+ // qiao
2
+ const cli = require('qiao-cli');
3
+
4
+ // llm
5
+ const LLM = require('qiao-llm');
6
+
7
+ // util
8
+ const { getDB, ask, printLogo } = require('./util.js');
9
+ const db = getDB();
10
+
11
+ // cmd
12
+ cli.cmd
13
+ .command('ask [modelName]')
14
+ .description('Ask a question to an AI model')
15
+ .action(async (modelName) => {
16
+ if (!modelName) {
17
+ const defaultModel = await db.config('default');
18
+ if (!defaultModel) {
19
+ console.log(cli.colors.red('No default model set. Use: viho model default'));
20
+ return;
21
+ }
22
+
23
+ modelName = defaultModel;
24
+ }
25
+
26
+ // check
27
+ const model = await db.config(modelName);
28
+ if (!model) {
29
+ console.log(cli.colors.red(`Model not found: ${modelName}`));
30
+ return;
31
+ }
32
+
33
+ // init
34
+ const llm = LLM({
35
+ apiKey: model.apiKey,
36
+ baseURL: model.baseURL,
37
+ });
38
+
39
+ // logo
40
+ printLogo();
41
+
42
+ await ask(llm, model);
43
+ });
package/bin/viho-chat.js CHANGED
@@ -4,14 +4,14 @@ const cli = require('qiao-cli');
4
4
  // llm
5
5
  const LLM = require('qiao-llm');
6
6
 
7
- // db
8
- const { getDB } = require('./util.js');
7
+ // util
8
+ const { getDB, ask, printLogo } = require('./util.js');
9
9
  const db = getDB();
10
10
 
11
11
  // cmd
12
12
  cli.cmd
13
13
  .command('chat [modelName]')
14
- .description('Chat with an AI model')
14
+ .description('Start a continuous chat session with an AI model')
15
15
  .action(async (modelName) => {
16
16
  if (!modelName) {
17
17
  const defaultModel = await db.config('default');
@@ -36,62 +36,14 @@ cli.cmd
36
36
  baseURL: model.baseURL,
37
37
  });
38
38
 
39
- // ask
40
- const questions = [
41
- {
42
- type: 'editor',
43
- name: 'content',
44
- message: 'Your question:',
45
- },
46
- ];
47
- const answers = await cli.ask(questions);
48
-
49
- // answers
50
- console.log();
51
- console.log(cli.colors.gray('Question:'));
52
- console.log(cli.colors.gray(answers.content));
53
- console.log();
39
+ // logo
40
+ printLogo();
41
+ console.log(cli.colors.cyan(`Welcome to viho chat! Using model: ${modelName}`));
42
+ console.log(cli.colors.gray('Press Ctrl+C to exit\n'));
54
43
 
55
44
  // chat
56
- const chatOptions = {
57
- model: model.modelID,
58
- messages: [
59
- { role: 'system', content: 'You are a helpful AI assistant' },
60
- { role: 'user', content: answers.content },
61
- ],
62
- thinking: {
63
- type: model.modelThinking,
64
- },
65
- };
66
-
67
- // callback options
68
- const callbackOptions = {
69
- firstThinkingCallback: () => {
70
- console.log();
71
- console.log(cli.colors.gray('[Thinking...]'));
72
- console.log();
73
- },
74
- thinkingCallback: (msg) => {
75
- process.stdout.write(cli.colors.gray(msg));
76
- },
77
- firstContentCallback: () => {
78
- console.log();
79
- console.log(cli.colors.cyan('[Response]'));
80
- console.log();
81
- },
82
- contentCallback: (msg) => {
83
- process.stdout.write(msg);
84
- },
85
- endCallback: () => {
86
- console.log();
87
- },
88
- errorCallback: (error) => {
89
- console.log();
90
- console.log(cli.colors.red('Error:'));
91
- console.log(error);
92
- },
93
- };
94
-
95
- // go
96
- await llm.chatWithStreaming(chatOptions, callbackOptions);
45
+ let keepChatting = true;
46
+ while (keepChatting) {
47
+ await ask(llm, model);
48
+ }
97
49
  });
package/bin/viho-model.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // qiao
2
2
  const cli = require('qiao-cli');
3
3
 
4
- // db
5
- const { getDB } = require('./util.js');
4
+ // util
5
+ const { getDB, printLogo } = require('./util.js');
6
6
  const db = getDB();
7
7
 
8
8
  // actions
@@ -91,6 +91,9 @@ async function modelAdd() {
91
91
  */
92
92
  async function modelList() {
93
93
  try {
94
+ // logo
95
+ printLogo();
96
+
94
97
  // list
95
98
  const all = await db.all();
96
99
  console.log(cli.colors.cyan('Configured models:'));
package/bin/viho.js CHANGED
@@ -5,6 +5,7 @@ const cli = require('qiao-cli');
5
5
 
6
6
  // cmds
7
7
  require('./viho-model.js');
8
+ require('./viho-ask.js');
8
9
  require('./viho-chat.js');
9
10
  require('./viho-version.js');
10
11
 
package/logo.png ADDED
Binary file
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "viho",
3
- "version": "0.0.4",
4
- "description": "A lightweight CLI tool for managing and chatting with AI models",
3
+ "version": "0.0.5",
4
+ "description": "A lightweight CLI tool for managing and interacting with AI models",
5
5
  "keywords": [
6
6
  "ai",
7
7
  "llm",
8
+ "qa",
9
+ "ask",
8
10
  "chat",
9
11
  "cli",
10
12
  "chatgpt",
@@ -30,7 +32,8 @@
30
32
  "files": [
31
33
  "bin",
32
34
  "LICENSE",
33
- "README.md"
35
+ "README.md",
36
+ "logo.png"
34
37
  ],
35
38
  "engines": {
36
39
  "node": ">=18.0.0"
@@ -40,5 +43,5 @@
40
43
  "qiao-config": "^5.0.1",
41
44
  "qiao-llm": "^0.2.5"
42
45
  },
43
- "gitHead": "08434f296e9d87e8ae6dcb2720989edbc414841e"
46
+ "gitHead": "4536783e6823add1a9556e0fb2f569e8d1f5bac0"
44
47
  }