Files
bigwo/test2/server/routes/assistantProfile.js
User 9567eb7358 feat(server): KB prompt优化、字幕修复、S2S重连、助手配置API
- assistantProfileConfig: KB answer prompt改为分层策略(严格产品信息+灵活常识补充)
- nativeVoiceGateway: S2S upstream自动重连(最多50次)、event 351字幕debounce(800ms取最长文本)
- toolExecutor: 确定性query改写增强、KB查询传递session上下文
- contextKeywordTracker: 支持KB话题记忆优先enrichment
- contentSafeGuard: 新增品牌安全内容过滤服务
- assistantProfileService: 新增助手配置CRUD服务
- routes/assistantProfile: 新增助手配置API路由
- knowledgeKeywords: 扩展KB关键词词典
- fastAsrCorrector: ASR纠错规则更新
- tests/: KB prompt测试、保护窗口测试、Viking性能测试
- docs/: 助手配置API文档、系统提示词目录
2026-03-24 17:19:36 +08:00

66 lines
1.8 KiB
JavaScript

const express = require('express');
const router = express.Router();
const { getAssistantProfile, clearAssistantProfileCache } = require('../services/assistantProfileService');
router.get('/', async (req, res) => {
try {
const userId = String(req.query.userId || '').trim() || null;
const forceRefresh = String(req.query.forceRefresh || '').trim() === 'true';
const result = await getAssistantProfile({ userId, forceRefresh });
res.json({
code: 0,
message: 'success',
success: true,
data: {
userId,
profile: result.profile,
source: result.source,
cached: result.cached,
fetchedAt: result.fetchedAt,
configured: result.configured,
error: result.error,
},
});
} catch (error) {
console.error('[AssistantProfile] query failed:', error.message);
res.status(500).json({
code: 500,
message: error.message,
success: false,
error: error.message,
});
}
});
router.post('/refresh', async (req, res) => {
try {
const userId = String(req.body?.userId || '').trim() || null;
clearAssistantProfileCache(userId);
const result = await getAssistantProfile({ userId, forceRefresh: true });
res.json({
code: 0,
message: 'success',
success: true,
data: {
userId,
profile: result.profile,
source: result.source,
cached: result.cached,
fetchedAt: result.fetchedAt,
configured: result.configured,
error: result.error,
},
});
} catch (error) {
console.error('[AssistantProfile] refresh failed:', error.message);
res.status(500).json({
code: 500,
message: error.message,
success: false,
error: error.message,
});
}
});
module.exports = router;