79 lines
2.6 KiB
Python
Executable File
79 lines
2.6 KiB
Python
Executable File
"""
|
|
API路由 - 纯净版RAG系统
|
|
保留RAG核心接口,为bbav20311接入预留接口
|
|
"""
|
|
|
|
from fastapi import APIRouter, UploadFile, File, HTTPException
|
|
from pathlib import Path
|
|
import os
|
|
|
|
from api.rag_routes import router as rag_router
|
|
from api.case_routes import router as case_router
|
|
|
|
router = APIRouter()
|
|
|
|
# ============================================
|
|
# RAG核心接口(已实现)
|
|
# ============================================
|
|
|
|
# RAG对话接口
|
|
router.include_router(rag_router, prefix="/rag", tags=["RAG"])
|
|
|
|
# 真实复现案例问答接口(确定性QA,不调用LLM)
|
|
router.include_router(case_router, prefix="/case", tags=["Case QA"])
|
|
|
|
# ============================================
|
|
# 预留接口(为bbav20311接入准备)
|
|
# ============================================
|
|
|
|
# 文件上传接口(预留)
|
|
@router.post("/upload")
|
|
async def upload_file(file: UploadFile = File(...)):
|
|
"""文件上传接口 - 预留"""
|
|
raise HTTPException(status_code=501, detail="待bbav20311接入后实现")
|
|
|
|
# 批量上传接口(预留)
|
|
@router.post("/upload/batch")
|
|
async def upload_batch(files: list[UploadFile] = File(...)):
|
|
"""批量上传接口 - 预留"""
|
|
raise HTTPException(status_code=501, detail="待bbav20311接入后实现")
|
|
|
|
# 工作空间接口(预留)
|
|
@router.get("/workspace/{job_id}/files")
|
|
async def get_workspace_files(job_id: str):
|
|
"""工作空间文件接口 - 预留"""
|
|
raise HTTPException(status_code=501, detail="待bbav20311接入后实现")
|
|
|
|
# 基因家族分析接口(预留)
|
|
@router.post("/analysis/gene-family")
|
|
async def analyze_gene_family(job_id: str, species: str, gene_family: str):
|
|
"""基因家族分析接口 - 预留"""
|
|
raise HTTPException(status_code=501, detail="待bbav20311接入后实现")
|
|
|
|
# 工具执行接口(预留)
|
|
@router.post("/tools/{tool_id}/execute")
|
|
async def execute_tool(tool_id: str, params: dict):
|
|
"""工具执行接口 - 预留"""
|
|
raise HTTPException(status_code=501, detail="待bbav20311接入后实现")
|
|
|
|
# ============================================
|
|
# 状态查询接口
|
|
# ============================================
|
|
|
|
@router.get("/status")
|
|
async def get_status():
|
|
"""获取RAG系统状态"""
|
|
try:
|
|
from src.rag.retriever import retriever
|
|
indexed_count = retriever.count_chunks() if retriever else 0
|
|
except Exception as e:
|
|
# 如果retriever未初始化,使用RAG路由的状态
|
|
indexed_count = 0
|
|
|
|
return {
|
|
"status": "ready",
|
|
"indexed_documents": indexed_count,
|
|
"rag_enabled": True,
|
|
"analysis_enabled": False, # 待接入bbav20311后开启
|
|
}
|