Files
rag/core/constants.py
lacerate551 100d1a06eb init: RAG 知识库服务初始提交
- 后端 API(Flask + Gunicorn)
- RAG 引擎(混合检索 + 云端 Reranker + 引用溯源)
- 文档解析(MinerU + 多格式支持)
- Docker 生产部署配置
- 排除前端项目、敏感配置、模型文件
2026-06-04 17:35:27 +08:00

36 lines
814 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
公共常量定义
统一管理 RAG 系统中的常量值,避免重复定义。
"""
from copy import deepcopy
# ==================== 检索结果常量 ====================
# 空检索结果模板(不要直接返回,使用 get_empty_result()
_EMPTY_RESULT_TEMPLATE = {
'ids': [[]],
'documents': [[]],
'metadatas': [[]],
'distances': [[]]
}
# 空检索结果模板(无嵌套列表形式)
_EMPTY_RESULT_FLAT_TEMPLATE = {
'ids': [],
'documents': [],
'metadatas': [],
'distances': []
}
def get_empty_result() -> dict:
"""返回空检索结果的深拷贝,避免副作用"""
return deepcopy(_EMPTY_RESULT_TEMPLATE)
def get_empty_result_flat() -> dict:
"""返回扁平空检索结果的深拷贝"""
return deepcopy(_EMPTY_RESULT_FLAT_TEMPLATE)