feat(kb): VikingDB纯检索+重排+Redis上下文+全库搜索+别名扩展+KB保护窗口+RAG语气引导
- 新增 kbRetriever.js: VikingDB search_knowledge 纯检索替代 Ark chat/completions, doubao-seed-rerank 重排, RAG payload 语气引导缓解音色差异 - 新增 redisClient.js: Redis 连接管理 + 5轮对话历史 + KB缓存双写 - toolExecutor.js: 产品别名扩展25条, 全库检索topK=25, 检索阈值0.01, 精简 buildDeterministicKnowledgeQuery - nativeVoiceGateway.js: isPureChitchat扩展, KB保护窗口60s, prequery参数调优 - realtimeDialogRouting.js: resolveReply感知KB保护窗口, fast-path适配raw模式 - app.js: 健康检查新增 redis/reranker/kbRetrievalMode - 新增测试: alias A/B测试, KB retriever测试, Redis客户端测试, raw模式集成测试
This commit is contained in:
92
test2/server/tests/_check_logs.cjs
Normal file
92
test2/server/tests/_check_logs.cjs
Normal file
@@ -0,0 +1,92 @@
|
||||
const { Client } = require('ssh2');
|
||||
const SSH_CONFIG = { host: '119.45.10.34', port: 22, username: 'root', password: '#xyzh%CS#2512@28' };
|
||||
|
||||
function sshExec(conn, cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
conn.exec(cmd, (err, s) => {
|
||||
if (err) return reject(err);
|
||||
let o = '';
|
||||
s.on('data', d => o += d);
|
||||
s.stderr.on('data', d => o += d);
|
||||
s.on('close', () => resolve(o));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function sftpUpload(conn, localPath, remotePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
conn.sftp((err, sftp) => {
|
||||
if (err) return reject(err);
|
||||
const rs = fs.createReadStream(localPath);
|
||||
const ws = sftp.createWriteStream(remotePath);
|
||||
ws.on('close', () => resolve());
|
||||
ws.on('error', reject);
|
||||
rs.pipe(ws);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const REMOTE_BASE = '/www/wwwroot/demo.tensorgrove.com.cn/server';
|
||||
const LOCAL_BASE = path.join(__dirname, '..');
|
||||
|
||||
async function main() {
|
||||
const conn = new Client();
|
||||
await new Promise((resolve, reject) => {
|
||||
conn.on('ready', resolve).on('error', reject).connect(SSH_CONFIG);
|
||||
});
|
||||
|
||||
// 1. 上传文件
|
||||
const files = [
|
||||
{ name: 'toolExecutor.js', sub: 'services' },
|
||||
{ name: 'kbRetriever.js', sub: 'services' },
|
||||
];
|
||||
console.log('=== 上传 ===');
|
||||
for (const f of files) {
|
||||
const localFile = path.join(LOCAL_BASE, f.sub, f.name);
|
||||
const remoteFile = `${REMOTE_BASE}/${f.sub}/${f.name}`;
|
||||
await sftpUpload(conn, localFile, remoteFile);
|
||||
console.log(` \u2705 ${f.name}`);
|
||||
const sc = await sshExec(conn, `node -c ${remoteFile} 2>&1`);
|
||||
if (sc.includes('SyntaxError')) { console.log('SYNTAX ERROR!'); conn.end(); process.exit(1); }
|
||||
}
|
||||
|
||||
// 2. 刷 Redis KB 缓存
|
||||
console.log('\n=== 刷 Redis KB 缓存 ===');
|
||||
console.log(await sshExec(conn, `cd ${REMOTE_BASE} && node -e "
|
||||
require('dotenv').config();
|
||||
const Redis = require('ioredis');
|
||||
const r = new Redis(process.env.REDIS_URL || 'redis://127.0.0.1:6379', {
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
db: parseInt(process.env.REDIS_DB) || 0,
|
||||
keyPrefix: process.env.REDIS_KEY_PREFIX || 'bigwo:',
|
||||
lazyConnect: true, maxRetriesPerRequest: 2, connectTimeout: 5000,
|
||||
});
|
||||
r.connect().then(async () => {
|
||||
const keys = await r.keys('kb_cache:*');
|
||||
if (keys.length > 0) { await r.del(...keys); console.log('Deleted ' + keys.length + ' keys'); }
|
||||
else { console.log('No keys'); }
|
||||
r.quit(); process.exit(0);
|
||||
}).catch(e => { console.log('Redis: ' + e.message); process.exit(0); });
|
||||
" 2>&1`));
|
||||
|
||||
// 3. 重启
|
||||
await sshExec(conn, '> /var/log/bigwo/server-error.log && > /var/log/bigwo/server-out.log');
|
||||
await sshExec(conn, 'pm2 stop bigwo-server');
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
await sshExec(conn, `cd ${REMOTE_BASE} && pm2 start bigwo-server --update-env`);
|
||||
console.log('\n=== PM2 重启,等待5s ===');
|
||||
await new Promise(r => setTimeout(r, 5000));
|
||||
console.log(await sshExec(conn, 'pm2 status bigwo-server'));
|
||||
const errLog = await sshExec(conn, 'cat /var/log/bigwo/server-error.log');
|
||||
console.log('=== 错误 ===');
|
||||
console.log(errLog || '(空 ✅)');
|
||||
console.log('\n=== 健康 ===');
|
||||
console.log(await sshExec(conn, 'curl -s --max-time 5 http://localhost:3012/api/health 2>&1'));
|
||||
|
||||
conn.end();
|
||||
}
|
||||
|
||||
main().catch(e => { console.error('FAILED:', e.message); process.exit(1); });
|
||||
Reference in New Issue
Block a user