This commit is contained in:
van
2026-04-05 21:37:47 +08:00
parent 2d1f980a47
commit f845044a27

View File

@@ -116,7 +116,7 @@
</span> </span>
<div style="float: right;"> <div style="float: right;">
<el-button type="primary" size="small" icon="el-icon-plus" @click="openLlmDialog(false)">新增配置</el-button> <el-button type="primary" size="small" icon="el-icon-plus" @click="openLlmDialog(false)">新增配置</el-button>
<el-button size="small" icon="el-icon-video-play" @click="openLlmTest(null)">测试当前激活</el-button> <el-button size="small" icon="el-icon-caret-right" @click="openLlmTest(null)">测试当前激活</el-button>
<el-button size="small" icon="el-icon-refresh" @click="loadLlmList">刷新</el-button> <el-button size="small" icon="el-icon-refresh" @click="loadLlmList">刷新</el-button>
</div> </div>
</div> </div>
@@ -611,6 +611,59 @@ export default {
this.$message.error('操作失败:' + (e.message || '未知错误')) this.$message.error('操作失败:' + (e.message || '未知错误'))
} }
} }
},
resetLlmTestDialog() {
this.llmTestRow = null
this.llmTestResult = null
this.llmTestLoading = false
},
openLlmTest(row) {
if (this.llmSummary && this.llmSummary.redisAvailable === false) {
this.$message.warning('Redis 未配置时无法从后台写入多套参数;仍可直接测 Jarvis 默认,请确认 Jarvis 地址正确。')
}
this.llmTestRow = row || null
this.llmTestMessage = '1+1等于几请只回答一个数字或最简结果不要多余解释。'
this.llmTestResult = null
this.llmTestDialogVisible = true
},
async submitLlmTest() {
if (!this.llmTestMessage || !this.llmTestMessage.trim()) {
this.$message.warning('请填写测试问题')
return
}
const payload = { message: this.llmTestMessage.trim() }
if (this.llmTestRow && this.llmTestRow.id) {
payload.profileId = this.llmTestRow.id
}
this.llmTestLoading = true
this.llmTestResult = null
try {
const res = await testLlmProfile(payload)
if (res.code === 200 && res.data) {
this.llmTestResult = {
success: !!res.data.success,
reply: res.data.reply,
error: res.data.error
}
if (this.llmTestResult.success) {
this.$message.success('测试完成')
} else {
this.$message.error(this.llmTestResult.error || '调用失败')
}
} else {
this.$message.error(res.msg || '测试失败')
this.llmTestResult = { success: false, error: res.msg || '未知错误' }
}
} catch (e) {
console.error(e)
this.$message.error('测试失败:' + (e.message || '未知错误'))
this.llmTestResult = { success: false, error: e.message || '未知错误' }
} finally {
this.llmTestLoading = false
}
} }
} }
} }
@@ -702,5 +755,25 @@ export default {
.llm-del-btn { .llm-del-btn {
color: #f56c6c; color: #f56c6c;
} }
.llm-test-hint {
margin: 0 0 12px 0;
font-size: 13px;
color: #606266;
line-height: 1.5;
}
.llm-test-result {
margin-top: 12px;
}
.llm-test-reply {
margin: 8px 0 0 0;
white-space: pre-wrap;
word-break: break-word;
font-family: 'Consolas', 'Monaco', monospace;
font-size: 13px;
line-height: 1.5;
}
</style> </style>