多库检索与存储修复: - RRF 融合去重改用 (collection, chunk_id) 复合键,修复同名文件结果被吞 - DocStore 存储路径加 collection 前缀,修复跨库同名切片数据覆盖 - search_multiple 去重改用复合键 - chunk_id 解析改用 rsplit 兼容下划线文件名 上传与版本管理修复: - 同名文件上传改为覆盖模式,自动清理旧切片 - 修复首次上传不创建版本记录 - 修复覆盖上传版本号回退到 v1 - sync ADDED 分支改用动态版本号生成 - _generate_version_id 改为基于全部版本递增 - 废止/恢复操作同步 SQLite 版本记录 - mark_document_as_superseded 改为仅更新 SQLite 删除清理修复: - 删除文档时同步清理 SQLite 版本记录和变更日志 - 删除向量库时同步清理该库所有版本记录 - cleanup 改为清理 SQLite 记录而非 ChromaDB 测试: - test_version_management.py: 27 条版本管理单元测试 - test_edge_cases.py: 28 条边界用例测试 - test_upload_dedup.py: 5 条上传去重测试 - e2e_risk_test.py: 27 条端到端风险测试 文档: - 新增风险边界问题修复注意事项.md(面向后端的对接文档) - 新增向量库边界风险分析.md - 更新多篇现有文档
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
import json
|
|
import re
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
with open(r'C:\Users\qq318\Desktop\rag-agent\test_files\rag_output.txt', 'r', encoding='utf-8') as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line.startswith('data: ') and '"type": "finish"' in line:
|
|
data = json.loads(line[6:])
|
|
citations = data.get('citations', [])
|
|
print(f'Citation count: {len(citations)}')
|
|
for i, c in enumerate(citations):
|
|
coll = c.get('collection', '')
|
|
cid = c.get('chunk_id', '')
|
|
src = c.get('source', '')
|
|
preview = c.get('content', '')[:80]
|
|
print(f' [{i+1}] collection={coll}, chunk_id={cid}, source={src}')
|
|
print(f' content: {preview}...')
|
|
print()
|
|
answer = data.get('answer', '')
|
|
refs = re.findall(r'\[ref:([^\]]+)\]', answer)
|
|
print(f'Ref tags in answer: {refs}')
|
|
print(f'Answer preview: {answer[:200]}...')
|