feat: 凭证生成、成本分析、AI问答、前端页面、集成测试与E2E测试
- 后端: 凭证生成引擎、金蝶导出器、凭证模板服务 - 后端: 成本分析服务、AI问答服务 - 后端: 科目映射CRUD API、分析API、QA API - 后端: 集成测试(认证/任务/凭证) 49个测试全部通过 - 前端: 凭证管理、成本分析、导出中心、知识库、系统设置页面 - 前端: AuthGuard认证守卫、Dashboard AI聊天功能 - 前端: Playwright E2E测试 16 passed, 1 skipped - 基础设施: Docker Compose、Nginx反向代理、.env.example - 文档: 用户手册、管理员手册、发布检查清单
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
问答 API
|
||||
|
||||
提供预置问题列表和问题回答接口
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Body
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.tenant import get_current_company_id
|
||||
from app.services.ai.qa_service import QAService
|
||||
|
||||
router = APIRouter(prefix="/api/qa", tags=["问答"])
|
||||
|
||||
|
||||
class QuestionRequest(BaseModel):
|
||||
"""问题请求"""
|
||||
task_id: int
|
||||
question: str
|
||||
context: str = ""
|
||||
|
||||
|
||||
class QuestionResponse(BaseModel):
|
||||
"""问题响应"""
|
||||
answer: str
|
||||
data_points: List[str] = []
|
||||
|
||||
|
||||
class SuggestedQuestionsResponse(BaseModel):
|
||||
"""建议问题响应"""
|
||||
questions: List[str]
|
||||
|
||||
|
||||
@router.get("/suggested-questions", response_model=SuggestedQuestionsResponse)
|
||||
async def get_suggested_questions(
|
||||
task_id: int,
|
||||
context: str = "",
|
||||
db: AsyncSession = Depends(get_db),
|
||||
company_id: int = Depends(get_current_company_id),
|
||||
) -> SuggestedQuestionsResponse:
|
||||
"""
|
||||
获取预置问题列表
|
||||
|
||||
根据任务状态返回合适的预置问题
|
||||
"""
|
||||
service = QAService(db)
|
||||
questions = await service.get_suggested_questions(task_id, context)
|
||||
return SuggestedQuestionsResponse(questions=questions)
|
||||
|
||||
|
||||
@router.post("/ask", response_model=QuestionResponse)
|
||||
async def ask_question(
|
||||
request: QuestionRequest,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
company_id: int = Depends(get_current_company_id),
|
||||
) -> QuestionResponse:
|
||||
"""
|
||||
回答用户问题
|
||||
|
||||
基于真实数据回答预置问题
|
||||
"""
|
||||
service = QAService(db)
|
||||
answer = await service.answer_preset_question(request.task_id, request.question)
|
||||
return QuestionResponse(answer=answer, data_points=[])
|
||||
Reference in New Issue
Block a user