shiroai 2.0.4 → 2.0.6
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/cli.js +40 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -17,7 +17,18 @@ const c = {
|
|
|
17
17
|
|
|
18
18
|
// ===== CONFIG =====
|
|
19
19
|
const API_URL = 'https://inference.do-ai.run/v1/chat/completions';
|
|
20
|
-
const
|
|
20
|
+
const MODELS = [
|
|
21
|
+
'openai-gpt-oss-120b',
|
|
22
|
+
'anthropic-claude-3.5-sonnet',
|
|
23
|
+
'anthropic-claude-sonnet-4',
|
|
24
|
+
'meta-llama-3.1-405b-instruct',
|
|
25
|
+
'deepseek-r1',
|
|
26
|
+
'deepseek-v3',
|
|
27
|
+
'qwen-2.5-72b-instruct',
|
|
28
|
+
'llama-3.3-70b-instruct',
|
|
29
|
+
'deepseek-r1-distill-llama-70b',
|
|
30
|
+
'mistral-small-3.2-24b-instruct',
|
|
31
|
+
];
|
|
21
32
|
const CWD = process.cwd();
|
|
22
33
|
const CONFIG_DIR = path.join(os.homedir(), '.shiroai');
|
|
23
34
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
@@ -32,6 +43,7 @@ const AGENTS_DIR = path.join(CONFIG_DIR, 'agents');
|
|
|
32
43
|
function loadConfig() { try { return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); } catch { return {}; } }
|
|
33
44
|
function saveConfig(cfg) { fs.writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2)); }
|
|
34
45
|
let config = loadConfig();
|
|
46
|
+
let MODEL = config.model || 'openai-gpt-oss-120b';
|
|
35
47
|
|
|
36
48
|
// ===== CLI ARGS =====
|
|
37
49
|
const args = process.argv.slice(2);
|
|
@@ -262,9 +274,14 @@ initMessages();
|
|
|
262
274
|
// ===== STREAMING API =====
|
|
263
275
|
function streamChat(msgs, tools) {
|
|
264
276
|
return new Promise((resolve, reject) => {
|
|
277
|
+
// DO inference doesn't allow system messages - convert to user context
|
|
278
|
+
const filteredMsgs = msgs.map(m => {
|
|
279
|
+
if (m.role === 'system') return { role: 'user', content: `[CONTEXT]\n${m.content}` };
|
|
280
|
+
return m;
|
|
281
|
+
});
|
|
265
282
|
const payload = {
|
|
266
283
|
model: MODEL,
|
|
267
|
-
messages:
|
|
284
|
+
messages: filteredMsgs,
|
|
268
285
|
stream: true,
|
|
269
286
|
max_tokens: 8192
|
|
270
287
|
};
|
|
@@ -486,6 +503,10 @@ function header() {
|
|
|
486
503
|
function showHelp() {
|
|
487
504
|
console.log(`${c.bold}Commands:${c.r}`);
|
|
488
505
|
console.log(` ${c.cyan}/help${c.r} Show this help`);
|
|
506
|
+
console.log(` ${c.cyan}/model${c.r} Show current model`);
|
|
507
|
+
console.log(` ${c.cyan}/model list${c.r} List available models`);
|
|
508
|
+
console.log(` ${c.cyan}/model <name>${c.r} Switch model`);
|
|
509
|
+
console.log(` ${c.cyan}/auto${c.r} Use default model`);
|
|
489
510
|
console.log(` ${c.cyan}/context${c.r} Show context info`);
|
|
490
511
|
console.log(` ${c.cyan}/context add <f>${c.r} Add file to context`);
|
|
491
512
|
console.log(` ${c.cyan}/chat save <name>${c.r} Save session`);
|
|
@@ -549,6 +570,23 @@ function prompt() {
|
|
|
549
570
|
return prompt();
|
|
550
571
|
}
|
|
551
572
|
|
|
573
|
+
// Model commands
|
|
574
|
+
if (input === '/model') { console.log(`${c.dim}Current model: ${c.cyan}${MODEL}${c.r}`); return prompt(); }
|
|
575
|
+
if (input === '/model list') {
|
|
576
|
+
console.log(`${c.bold}Available models:${c.r}`);
|
|
577
|
+
MODELS.forEach((m, i) => console.log(` ${m === MODEL ? c.green + '● ' : ' '}${c.cyan}${m}${c.r}`));
|
|
578
|
+
console.log(`\n${c.dim} Use: /model <name>${c.r}`);
|
|
579
|
+
return prompt();
|
|
580
|
+
}
|
|
581
|
+
if (input === '/auto') { MODEL = 'openai-gpt-oss-120b'; config.model = MODEL; saveConfig(config); console.log(`${c.green}✓ Model: ${MODEL} (auto)${c.r}`); return prompt(); }
|
|
582
|
+
if (input.startsWith('/model ')) {
|
|
583
|
+
const name = input.slice(7).trim();
|
|
584
|
+
const match = MODELS.find(m => m.includes(name));
|
|
585
|
+
if (match) { MODEL = match; config.model = MODEL; saveConfig(config); console.log(`${c.green}✓ Model switched: ${MODEL}${c.r}`); }
|
|
586
|
+
else { console.log(`${c.red}Model not found. Use /model list${c.r}`); }
|
|
587
|
+
return prompt();
|
|
588
|
+
}
|
|
589
|
+
|
|
552
590
|
// Regular chat with tool use
|
|
553
591
|
await chat(input);
|
|
554
592
|
prompt();
|