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文档、系统提示词目录
This commit is contained in:
122
test2/server/tests/README_VIKING_TEST.md
Normal file
122
test2/server/tests/README_VIKING_TEST.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Viking 检索性能测试套件
|
||||
|
||||
本测试套件用于测试火山引擎(Viking)知识库的检索性能,包括延迟、缓存效率、并发吞吐量等指标。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
test2/server/tests/
|
||||
├── viking_retrieval_performance.js # 核心性能测试类
|
||||
├── quick_test_viking.js # 快速测试脚本
|
||||
├── test_results/ # 测试结果输出目录
|
||||
└── README_VIKING_TEST.md # 本文档
|
||||
```
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 前置条件
|
||||
|
||||
1. 确保已安装依赖:
|
||||
```bash
|
||||
cd test2/server
|
||||
npm install
|
||||
```
|
||||
|
||||
2. 确保 `.env` 文件配置正确,包含火山引擎相关环境变量:
|
||||
```
|
||||
VOLC_ARK_API_KEY=your_api_key
|
||||
VOLC_ARK_ENDPOINT_ID=your_endpoint_id
|
||||
VOLC_ARK_KNOWLEDGE_BASE_IDS=your_kb_ids
|
||||
VOLC_ARK_KNOWLEDGE_ENDPOINT_ID=your_kb_endpoint_id
|
||||
```
|
||||
|
||||
### 快速测试
|
||||
|
||||
运行完整测试套件:
|
||||
```bash
|
||||
cd test2/server
|
||||
node tests/quick_test_viking.js
|
||||
```
|
||||
|
||||
运行特定类型的测试:
|
||||
|
||||
```bash
|
||||
# 只运行延迟测试
|
||||
node tests/quick_test_viking.js latency
|
||||
|
||||
# 只运行缓存效率测试
|
||||
node tests/quick_test_viking.js cache
|
||||
|
||||
# 只运行并发测试
|
||||
node tests/quick_test_viking.js concurrency
|
||||
```
|
||||
|
||||
### 编程使用
|
||||
|
||||
在你的代码中集成性能测试:
|
||||
|
||||
```javascript
|
||||
const VikingRetrievalPerformanceTester = require('./tests/viking_retrieval_performance');
|
||||
|
||||
const tester = new VikingRetrievalPerformanceTester({
|
||||
outputDir: './my_test_results',
|
||||
verbose: true,
|
||||
warmupRuns: 3
|
||||
});
|
||||
|
||||
// 运行完整测试套件
|
||||
await tester.runFullSuite();
|
||||
|
||||
// 或者单独运行测试
|
||||
const latencyResults = await tester.testLatency([
|
||||
{ name: 'My Query', query: '测试查询' }
|
||||
], 10);
|
||||
|
||||
// 生成并保存报告
|
||||
tester.printSummary();
|
||||
tester.saveReport('my_test.json');
|
||||
```
|
||||
|
||||
## 测试类型
|
||||
|
||||
### 1. 延迟测试 (Latency Test)
|
||||
测试不同查询的响应时间,包括:
|
||||
- 平均延迟
|
||||
- P50/P95/P99 延迟
|
||||
- 最小/最大延迟
|
||||
- 命中率
|
||||
|
||||
### 2. 缓存效率测试 (Cache Efficiency Test)
|
||||
测试缓存命中时的性能提升:
|
||||
- 首次查询延迟
|
||||
- 缓存命中延迟
|
||||
- 加速比(Speedup)
|
||||
|
||||
### 3. 并发测试 (Concurrency Test)
|
||||
测试不同并发级别下的吞吐量:
|
||||
- 吞吐量(requests/second)
|
||||
- 成功率
|
||||
- 总耗时
|
||||
|
||||
### 4. 查询类型测试 (Query Types Test)
|
||||
测试不同类型查询的性能差异。
|
||||
|
||||
## 输出结果
|
||||
|
||||
测试结果将保存为 JSON 文件,包含:
|
||||
- 完整的测试数据
|
||||
- 摘要统计
|
||||
- 时间戳
|
||||
|
||||
控制台会输出格式化的测试摘要。
|
||||
|
||||
## 示例测试查询
|
||||
|
||||
默认测试查询包括:
|
||||
- 产品查询(小红、大白)
|
||||
- 公司信息
|
||||
- NTC 技术
|
||||
- 高频问题
|
||||
- 无结果查询
|
||||
|
||||
你可以根据自己的知识库内容自定义测试查询。
|
||||
Reference in New Issue
Block a user