默认为流式输出

This commit is contained in:
zhonghua.li
2026-04-04 09:43:01 +08:00
parent 99a71cdc69
commit 99c087e8f4
3 changed files with 8 additions and 7 deletions

View File

@@ -237,7 +237,7 @@ export default {
safeBottom: systemInfo.safeAreaInsets.bottom || 0, safeBottom: systemInfo.safeAreaInsets.bottom || 0,
message: '', message: '',
sending: false, sending: false,
useStreamOutput: false, useStreamOutput: true,
chatMessages: [], chatMessages: [],
sessionParentId: '', sessionParentId: '',
streamRequestTask: null, streamRequestTask: null,
@@ -663,7 +663,8 @@ export default {
}, },
sendByNormal(payload) { sendByNormal(payload) {
const url = getApiUrl('/api/aiQaItem/askAI'); const url = getApiUrl('/api/aiQaItem/askAI');
post(url, payload) // 非流式回答耗时更长,放宽超时避免频繁超时失败
post(url, payload, { timeout: 120000 })
.then((res) => { .then((res) => {
uni.hideLoading(); uni.hideLoading();
const body = res && res.data ? res.data : null; const body = res && res.data ? res.data : null;

File diff suppressed because one or more lines are too long

View File

@@ -468,7 +468,7 @@ const _sfc_main = {
}, },
sendByNormal(payload) { sendByNormal(payload) {
const url = common_config.getApiUrl("/api/aiQaItem/askAI"); const url = common_config.getApiUrl("/api/aiQaItem/askAI");
common_request.post(url, payload).then((res) => { common_request.post(url, payload, { timeout: 12e4 }).then((res) => {
common_vendor.index.hideLoading(); common_vendor.index.hideLoading();
const body = res && res.data ? res.data : null; const body = res && res.data ? res.data : null;
const success = body && body.success === true; const success = body && body.success === true;
@@ -486,7 +486,7 @@ const _sfc_main = {
this.chatMessages.push({ role: "ai", text: this.normalizeText(rawAnswer) }); this.chatMessages.push({ role: "ai", text: this.normalizeText(rawAnswer) });
}).catch((err) => { }).catch((err) => {
common_vendor.index.hideLoading(); common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:696", "[general_qa] askAI error:", err); common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:697", "[general_qa] askAI error:", err);
this.chatMessages.push({ role: "ai", text: (err == null ? void 0 : err.errMsg) || "调用失败,请重试" }); this.chatMessages.push({ role: "ai", text: (err == null ? void 0 : err.errMsg) || "调用失败,请重试" });
}).finally(() => { }).finally(() => {
this.sending = false; this.sending = false;
@@ -514,7 +514,7 @@ const _sfc_main = {
} }
}, },
fail: (err) => { fail: (err) => {
common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:793", "[general_qa] askAIStream error:", err); common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:794", "[general_qa] askAIStream error:", err);
const idx = this.streamAiMsgIndex; const idx = this.streamAiMsgIndex;
if (idx >= 0 && this.chatMessages[idx]) { if (idx >= 0 && this.chatMessages[idx]) {
const raw = String(this.chatMessages[idx].text || "").trim(); const raw = String(this.chatMessages[idx].text || "").trim();
@@ -547,7 +547,7 @@ const _sfc_main = {
this.streamBuffer += chunk; this.streamBuffer += chunk;
this.flushStreamBuffer(false); this.flushStreamBuffer(false);
} catch (e) { } catch (e) {
common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:834", "[general_qa] stream chunk parse error:", e); common_vendor.index.__f__("error", "at pages-subpackage/ai_qa/general_qa/general_qa.vue:835", "[general_qa] stream chunk parse error:", e);
} }
}); });
} else { } else {