xiaozhou-chat 1.0.7 → 1.1.0
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/lib/chat.js +20 -2
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Spinner, StreamPrinter } from "./ui.js";
|
|
3
3
|
import { sleep } from "./utils.js";
|
|
4
|
+
import { updateConfig } from "./config.js";
|
|
4
5
|
|
|
5
6
|
// 尝试加载 Markdown 渲染库
|
|
6
7
|
let marked;
|
|
@@ -140,8 +141,25 @@ export async function chatStream(context, userInput = null, options = {}) {
|
|
|
140
141
|
spinner.stop();
|
|
141
142
|
|
|
142
143
|
if (shouldRetryWithV1 && res.ok && !res.headers.get("content-type")?.includes("text/html")) {
|
|
143
|
-
console.log(`✅
|
|
144
|
-
|
|
144
|
+
console.log(`✅ 自动修复成功!`);
|
|
145
|
+
|
|
146
|
+
// 自动保存配置
|
|
147
|
+
try {
|
|
148
|
+
const correctBaseUrl = config.baseUrl.endsWith("/")
|
|
149
|
+
? config.baseUrl + "v1"
|
|
150
|
+
: config.baseUrl + "/v1";
|
|
151
|
+
|
|
152
|
+
// 1. 更新内存配置
|
|
153
|
+
config.baseUrl = correctBaseUrl;
|
|
154
|
+
|
|
155
|
+
// 2. 永久保存配置
|
|
156
|
+
updateConfig("baseUrl", correctBaseUrl);
|
|
157
|
+
|
|
158
|
+
console.log(`✅ 已自动将 Base URL 更新为: ${correctBaseUrl}`);
|
|
159
|
+
console.log(` (配置已保存,无需手动修改)`);
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.error("⚠️ 自动保存配置失败:", e.message);
|
|
162
|
+
}
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
if (!res.body) throw new Error("Response body is empty");
|