fastAPI 심화
- Chart.js - pdf, csv 파일 업로드 후 데이터 정제하여 llm으로 처리 후 결과 도출 - sqlite로 데이터 저장 - ORM - SQLAlchemy
This commit is contained in:
@@ -1,25 +1,33 @@
|
||||
from fastapi import APIRouter, Request, UploadFile
|
||||
from backend.services.llm_service import question_and_answer
|
||||
from backend.schemas.basic_schema import QuestionRequest
|
||||
from backend.services.rag_service import upload_document
|
||||
from backend.services.rag_service import upload_document, rag_chat, rag_chat_stream
|
||||
from fastapi.responses import StreamingResponse
|
||||
router = APIRouter(prefix="/api")
|
||||
|
||||
# http://127.0.0.1:8000/api/question
|
||||
@router.post("/question")
|
||||
async def question(req:QuestionRequest):
|
||||
async def question(req: QuestionRequest):
|
||||
answer = question_and_answer(req.question)
|
||||
|
||||
return {"message" : answer}
|
||||
|
||||
# http://127.0.0.1:8000/api/rag/upload
|
||||
@router.post("/rag/upload")
|
||||
async def fileUpload(file:UploadFile):
|
||||
async def file_Upload(file: UploadFile):
|
||||
# 서비스 호출
|
||||
return upload_document(file)
|
||||
|
||||
|
||||
# http://127.0.0.1:8000/api/rag/question
|
||||
|
||||
@router.post("/rag/question")
|
||||
async def question():
|
||||
pass
|
||||
async def question(req: QuestionRequest):
|
||||
answer = rag_chat(req.question)
|
||||
|
||||
return {"message" : answer}
|
||||
|
||||
@router.post("/rag/question/stream")
|
||||
async def question_stream(req: QuestionRequest):
|
||||
answer = rag_chat_stream(req.question)
|
||||
|
||||
return StreamingResponse(rag_chat_stream(req.question), media_type="text/plain")
|
||||
Reference in New Issue
Block a user