yuangs 1.0.7 → 1.0.9

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.
Files changed (3) hide show
  1. package/cli.js +17 -3
  2. package/index.js +2 -2
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -14,8 +14,9 @@ function printHelp() {
14
14
  console.log(` ${chalk.green('pong')} 打开 Pong 游戏`);
15
15
  console.log(` ${chalk.green('list')} 列出所有应用链接`);
16
16
  console.log(` ${chalk.green('ai')} "<问题>" 向 AI 提问`);
17
+ console.log(` ${chalk.gray('--model <模型名称>')} 指定 AI 模型 (可选)`);
17
18
  console.log(` ${chalk.green('help')} 显示帮助信息\n`);
18
- console.log(chalk.gray('AI 示例: yuangs ai "你好,请问你是谁?"'));
19
+ console.log(chalk.gray('AI 示例: yuangs ai "你好" --model gemini-pro'));
19
20
  console.log(chalk.gray('普通示例: yuangs shici\n'));
20
21
  }
21
22
 
@@ -25,7 +26,20 @@ function printSuccess(app, url) {
25
26
  }
26
27
 
27
28
  async function handleAICommand() {
28
- const question = args.slice(1).join(' ');
29
+ const commandArgs = args.slice(1);
30
+ const modelIndex = commandArgs.indexOf('--model');
31
+
32
+ let model = null; // Default model will be handled in index.js
33
+ let questionParts = commandArgs;
34
+
35
+ if (modelIndex !== -1 && commandArgs.length > modelIndex + 1) {
36
+ model = commandArgs[modelIndex + 1];
37
+ // Filter out --model and its value
38
+ questionParts = commandArgs.filter((_, index) => index !== modelIndex && index !== modelIndex + 1);
39
+ }
40
+
41
+ const question = questionParts.join(' ');
42
+
29
43
  if (!question) {
30
44
  console.log(chalk.red('错误: 请在 ai 命令后输入你的问题。'));
31
45
  printHelp();
@@ -39,7 +53,7 @@ async function handleAICommand() {
39
53
  }, 100);
40
54
 
41
55
  try {
42
- const answer = await yuangs.getAIAnswer(question);
56
+ const answer = await yuangs.getAIAnswer(question, model);
43
57
  clearInterval(interval);
44
58
  process.stdout.clearLine(0);
45
59
  process.stdout.cursorTo(0);
package/index.js CHANGED
@@ -17,7 +17,7 @@ function openUrl(url) {
17
17
  exec(command);
18
18
  }
19
19
 
20
- async function getAIAnswer(question) {
20
+ async function getAIAnswer(question, model) {
21
21
  const url = 'https://aiproxy.want.biz/ai/explain';
22
22
  const prompt = question;
23
23
 
@@ -30,7 +30,7 @@ async function getAIAnswer(question) {
30
30
 
31
31
  const data = {
32
32
  text: prompt,
33
- model: "gemini-flash-lite-latest"
33
+ model: model || "gemini-flash-lite-latest"
34
34
  };
35
35
 
36
36
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuangs",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "苑广山的个人应用集合 CLI(彩色版)",
5
5
  "main": "index.js",
6
6
  "bin": {