feat: 集成 KieAI 服务,移除 models-integration 子项目
- 添加 Gemini 2.5 Flash 对话接口(流式+非流式) - 添加 NanoBanana 图像生成/编辑接口 - 添加 Sora2 视频生成接口(文生视频、图生视频、去水印) - 移除 models-integration 子项目(功能已迁移至主后端) - 新增测试文档和 Playwright E2E 配置 - 更新前端页面和 API 接口 - 更新后端配置和日志处理
This commit is contained in:
@@ -613,7 +613,7 @@ export default {
|
||||
async sendToAI(content, type) {
|
||||
this.isLoading = true;
|
||||
|
||||
// 纯文字 或 多模态(图+文) 均走 KieAI Gemini,一次请求
|
||||
// 纯文字 / 多模态均走 KieAI Gemini:POST /api/front/kieai/gemini/chat,回复仅来自 data.choices[0].message.content
|
||||
if (type === 'text' || type === 'multimodal') {
|
||||
try {
|
||||
const messages = [{ role: 'user', content: content }];
|
||||
@@ -622,8 +622,11 @@ export default {
|
||||
if (response && response.code === 200 && response.data) {
|
||||
const data = response.data;
|
||||
const choice = data.choices && data.choices[0];
|
||||
const text = choice && choice.message && (choice.message.content || choice.message.text);
|
||||
const reply = (typeof text === 'string' ? text : (text && String(text))) || '未能获取到有效回复。';
|
||||
const msgObj = choice && choice.message;
|
||||
// 仅使用接口返回的 content,禁止固定话术
|
||||
const reply = (msgObj && msgObj.content != null)
|
||||
? (typeof msgObj.content === 'string' ? msgObj.content : String(msgObj.content))
|
||||
: '未能获取到有效回复。';
|
||||
this.messageList.push({ role: 'ai', content: reply });
|
||||
} else {
|
||||
const msg = (response && response.message) || '发起对话失败';
|
||||
@@ -804,25 +807,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
getAIResponse(question) {
|
||||
// 这里可以根据问题返回不同的回复
|
||||
// 实际应该调用AI API
|
||||
const responses = {
|
||||
'香蕉': '香蕉含钾量较高(每100g约330mg),对于需要控制钾摄入的透析患者来说需要谨慎食用。\n\n建议:\n• 如果血钾控制良好,可以少量食用(如半根)\n• 透析后食用更安全\n• 建议咨询您的主治医生确认\n\n您最近的血钾指标如何呢?',
|
||||
'苹果': '苹果是相对安全的水果选择,含钾量中等。建议适量食用,每天1-2个即可。',
|
||||
'蛋白质': '对于肾病患者,蛋白质的摄入需要根据CKD分期和透析情况来调整。建议咨询专业营养师制定个性化方案。'
|
||||
}
|
||||
|
||||
// 简单的关键词匹配
|
||||
for (let key in responses) {
|
||||
if (question.includes(key)) {
|
||||
return responses[key]
|
||||
}
|
||||
}
|
||||
|
||||
// 默认回复
|
||||
return `感谢您的提问。关于"${question}",我建议您:\n\n• 咨询您的主治医生获取专业建议\n• 根据您的CKD分期和透析情况调整饮食\n• 定期监测相关指标\n\n如需更详细的指导,可以联系专业营养师。`
|
||||
},
|
||||
scrollToBottom() {
|
||||
this.$nextTick(() => {
|
||||
// 动态切换 scrollTop 值以触发滚动更新
|
||||
|
||||
Reference in New Issue
Block a user