Files

25 lines
672 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.
"""自然语言查询 APIR4/R20)。"""
from __future__ import annotations
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.api.schemas import NLQRequest, NLQResponse
from app.db import get_session
from app.nlq import service as nlq
router = APIRouter(prefix="/nlq", tags=["nlq"])
@router.post("", response_model=NLQResponse)
def ask(req: NLQRequest, session: Session = Depends(get_session)) -> NLQResponse:
ans = nlq.ask(req.question, session=session)
return NLQResponse(
question=ans.question,
answer=ans.answer,
provider=ans.provider,
model=ans.model,
egress=ans.egress,
)