yuangs 1.3.16 → 1.3.18

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/README.md +13 -2
  2. package/index.js +11 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -29,8 +29,14 @@ yuangs ai "李白是谁?"
29
29
 
30
30
  指定模型:
31
31
 
32
+ 支持使用 `--model` 或 `-m` 指定模型,也支持以下简写:
33
+ - `-p`: `gemini-pro-latest` (Pro 版)
34
+ - `-f`: `gemini-flash-latest` (Flash 版)
35
+ - `-l`: `gemini-flash-lite-latest` (Lite 版)
36
+
32
37
  ```bash
33
- yuangs ai "用 Python 写个 Hello World" --model gemini-pro-latest
38
+ yuangs ai "用 Python 写个 Hello World" -p
39
+ # 等同于 --model gemini-pro-latest
34
40
  ```
35
41
 
36
42
  ### 交互模式(v1.1.x)
@@ -39,9 +45,14 @@ yuangs ai "用 Python 写个 Hello World" --model gemini-pro-latest
39
45
 
40
46
  ```bash
41
47
  yuangs ai
42
- # 进入后直接输入问题,每次回车提问一次,按 Ctrl+C 退出
43
48
  ```
44
49
 
50
+ 在交互模式中,你可以:
51
+ - 直接输入问题进行对话
52
+ - 输入 `/clear` 清空对话历史
53
+ - 输入 `/history` 查看对话历史
54
+ - 输入 `exit`、`quit` 或 `bye` 退出
55
+
45
56
  ## 应用列表
46
57
 
47
58
  以下是 CLI 中可以通过相应命令直接打开的应用程序链接:
package/index.js CHANGED
@@ -44,14 +44,18 @@ async function getAIAnswer(question, model, includeHistory = true) {
44
44
  const url = 'https://aiproxy.want.biz/ai/explain';
45
45
 
46
46
  // Prepare the prompt with conversation history if enabled
47
- let prompt = question;
48
- if (includeHistory && conversationHistory.length > 0) {
49
- // Create a context with the current question added to history
50
- const contextWithHistory = [...conversationHistory, { role: 'user', content: question }];
51
- prompt = contextWithHistory.map(msg => `${msg.role}: ${msg.content}`).join('\n\n');
47
+ let prompt;
48
+ if (includeHistory) {
49
+ prompt = JSON.stringify({
50
+ history: conversationHistory,
51
+ query: question
52
+ }, null, 2);
52
53
  } else {
53
- // If not including history, just use the question directly
54
- prompt = question;
54
+ // If not including history, still use JSON format for consistency but with empty history
55
+ prompt = JSON.stringify({
56
+ history: [],
57
+ query: question
58
+ }, null, 2);
55
59
  }
56
60
 
57
61
  const headers = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuangs",
3
- "version": "1.3.16",
3
+ "version": "1.3.18",
4
4
  "description": "苑广山的个人应用集合 CLI(彩色版)",
5
5
  "main": "index.js",
6
6
  "bin": {