|
|
@@ -317,10 +317,10 @@ const DEFAULT_SESSION_TITLE = "新会话"
|
|
317
|
317
|
const LLM_SESSION_STORAGE_PREFIX = "ai_consult_llm_session_"
|
|
318
|
318
|
|
|
319
|
319
|
const MODEL_OPTION_DEFS = [
|
|
320
|
|
- { value: "auto", labelKey: "modelAuto", shortKey: "modelAutoShort", descKey: "modelAutoDesc", icon: "el-icon-cpu" },
|
|
321
|
|
- { value: "yak-disease", labelKey: "modelDisease", shortKey: "modelDiseaseShort", descKey: "modelDiseaseDesc", icon: "el-icon-s-flag" },
|
|
|
320
|
+ // { value: "auto", labelKey: "modelAuto", shortKey: "modelAutoShort", descKey: "modelAutoDesc", icon: "el-icon-cpu" },
|
|
322
|
321
|
{ value: "yak-general", labelKey: "modelGeneral", shortKey: "modelGeneralShort", descKey: "modelGeneralDesc", icon: "el-icon-chat-dot-round" },
|
|
323
|
322
|
{ value: "yak-feeding", labelKey: "modelFeeding", shortKey: "modelFeedingShort", descKey: "modelFeedingDesc", icon: "el-icon-s-goods" },
|
|
|
323
|
+ { value: "yak-disease", labelKey: "modelDisease", shortKey: "modelDiseaseShort", descKey: "modelDiseaseDesc", icon: "el-icon-s-flag" },
|
|
324
|
324
|
{ value: "yak-growth", labelKey: "modelGrowth", shortKey: "modelGrowth", descKey: "modelGrowthDesc", icon: "el-icon-s-flag" },
|
|
325
|
325
|
]
|
|
326
|
326
|
|
|
|
@@ -1017,13 +1017,14 @@ export default {
|
|
1017
|
1017
|
}
|
|
1018
|
1018
|
}
|
|
1019
|
1019
|
},
|
|
1020
|
|
- queuePendingPersist(consultSessionId, persistBody, aiReplyContent, llmSessionId, costTime) {
|
|
|
1020
|
+ queuePendingPersist(consultSessionId, persistBody, aiReplyContent, llmSessionId, costTime, aiCategory) {
|
|
1021
|
1021
|
this.pendingPersist = {
|
|
1022
|
1022
|
consultSessionId,
|
|
1023
|
1023
|
persistBody: { ...persistBody },
|
|
1024
|
1024
|
aiReplyContent,
|
|
1025
|
1025
|
llmSessionId: llmSessionId != null ? llmSessionId : null,
|
|
1026
|
|
- costTime: costTime != null ? costTime : null
|
|
|
1026
|
+ costTime: costTime != null ? costTime : null,
|
|
|
1027
|
+ aiCategory: aiCategory != null && aiCategory !== "" ? aiCategory : null
|
|
1027
|
1028
|
}
|
|
1028
|
1029
|
},
|
|
1029
|
1030
|
async flushPendingPersist() {
|
|
|
@@ -1036,14 +1037,15 @@ export default {
|
|
1036
|
1037
|
...pending.persistBody,
|
|
1037
|
1038
|
aiReplyContent: pending.aiReplyContent,
|
|
1038
|
1039
|
realSessionId: pending.llmSessionId != null ? pending.llmSessionId : null,
|
|
1039
|
|
- costTime: pending.costTime != null ? pending.costTime : undefined
|
|
|
1040
|
+ costTime: pending.costTime != null ? pending.costTime : undefined,
|
|
|
1041
|
+ aiCategory: pending.aiCategory != null ? pending.aiCategory : undefined
|
|
1040
|
1042
|
})
|
|
1041
|
1043
|
this.pendingPersist = null
|
|
1042
|
1044
|
} catch (err) {
|
|
1043
|
1045
|
// 离开页面时仍失败则保留队列,下次进入同页可再试(仅内存,刷新会丢)
|
|
1044
|
1046
|
}
|
|
1045
|
1047
|
},
|
|
1046
|
|
- async persistConsultExchange(persistBody, aiReplyContent, costTime) {
|
|
|
1048
|
+ async persistConsultExchange(persistBody, aiReplyContent, costTime, aiCategory) {
|
|
1047
|
1049
|
const reply = (aiReplyContent || "").trim()
|
|
1048
|
1050
|
if (!this.activeSessionId || !persistBody || !reply) {
|
|
1049
|
1051
|
return true
|
|
|
@@ -1054,7 +1056,8 @@ export default {
|
|
1054
|
1056
|
...persistBody,
|
|
1055
|
1057
|
aiReplyContent: reply,
|
|
1056
|
1058
|
realSessionId: llmSessionId || null,
|
|
1057
|
|
- costTime: costTime != null ? costTime : undefined
|
|
|
1059
|
+ costTime: costTime != null ? costTime : undefined,
|
|
|
1060
|
+ aiCategory: aiCategory != null && aiCategory !== "" ? aiCategory : undefined
|
|
1058
|
1061
|
}
|
|
1059
|
1062
|
try {
|
|
1060
|
1063
|
const res = await sendAiConsultMessage(consultSessionId, saveBody)
|
|
|
@@ -1069,7 +1072,7 @@ export default {
|
|
1069
|
1072
|
}
|
|
1070
|
1073
|
return true
|
|
1071
|
1074
|
} catch (err) {
|
|
1072
|
|
- this.queuePendingPersist(consultSessionId, persistBody, reply, llmSessionId, costTime)
|
|
|
1075
|
+ this.queuePendingPersist(consultSessionId, persistBody, reply, llmSessionId, costTime, aiCategory)
|
|
1073
|
1076
|
const msg = (err && err.message) || this.dtT("saveSessionFailed")
|
|
1074
|
1077
|
this.$modal.msgWarning(msg)
|
|
1075
|
1078
|
return false
|
|
|
@@ -1231,6 +1234,7 @@ export default {
|
|
1231
|
1234
|
let aiReplyContent = ""
|
|
1232
|
1235
|
let aiMsg = null
|
|
1233
|
1236
|
let costTime = null
|
|
|
1237
|
+ let aiCategory = null
|
|
1234
|
1238
|
this.abortStreamRequest()
|
|
1235
|
1239
|
const abortController = new AbortController()
|
|
1236
|
1240
|
this.streamAbortController = abortController
|
|
|
@@ -1241,6 +1245,9 @@ export default {
|
|
1241
|
1245
|
onSessionId: (llmSid) => {
|
|
1242
|
1246
|
this.rememberLlmSessionId(session, llmSid)
|
|
1243
|
1247
|
},
|
|
|
1248
|
+ onModel: (model) => {
|
|
|
1249
|
+ aiCategory = model
|
|
|
1250
|
+ },
|
|
1244
|
1251
|
onDelta: (fullText) => {
|
|
1245
|
1252
|
aiReplyContent = fullText
|
|
1246
|
1253
|
if (!aiMsg) {
|
|
|
@@ -1257,6 +1264,9 @@ export default {
|
|
1257
|
1264
|
this.rememberLlmSessionId(session, llmSid)
|
|
1258
|
1265
|
}
|
|
1259
|
1266
|
costTime = streamResult.durationMs != null ? streamResult.durationMs : null
|
|
|
1267
|
+ if (streamResult.model) {
|
|
|
1268
|
+ aiCategory = streamResult.model
|
|
|
1269
|
+ }
|
|
1260
|
1270
|
this.clearStreamRevealTimer()
|
|
1261
|
1271
|
aiReplyContent = (streamResult.content || aiReplyContent || "").trim() || this.dtT("noContent")
|
|
1262
|
1272
|
if (!aiMsg) {
|
|
|
@@ -1287,7 +1297,12 @@ export default {
|
|
1287
|
1297
|
this.sending = false
|
|
1288
|
1298
|
this.$nextTick(() => this.scrollChatBottom())
|
|
1289
|
1299
|
}
|
|
1290
|
|
- await this.persistConsultExchange(persistBody, (aiReplyContent || "").trim(), costTime)
|
|
|
1300
|
+ await this.persistConsultExchange(
|
|
|
1301
|
+ persistBody,
|
|
|
1302
|
+ (aiReplyContent || "").trim(),
|
|
|
1303
|
+ costTime,
|
|
|
1304
|
+ aiCategory
|
|
|
1305
|
+ )
|
|
1291
|
1306
|
},
|
|
1292
|
1307
|
extOf(fileName) {
|
|
1293
|
1308
|
if (!fileName || fileName.lastIndexOf(".") < 0) {
|