feat:增加训练场和错题集接口
This commit is contained in:
40
main.py
40
main.py
@@ -8,8 +8,10 @@ from starlette.responses import StreamingResponse
|
||||
from database import get_db
|
||||
from schemas.agent import QueryRequest
|
||||
from schemas.library import LibraryFileRequest, LibraryFileResponse
|
||||
from schemas.mistake import MistakeResponse
|
||||
from schemas.practice import PracticeQuestionResponse, PracticeCheckResult, PracticeRecordResponse
|
||||
from service import library_service, practice_service, mistake_service
|
||||
from service.agent_service import query_agent
|
||||
from service.library_service import add_file, get_file, list_files, edit_file
|
||||
from storage import upload_rustfs
|
||||
from ocr import ocr_from_url
|
||||
|
||||
@@ -39,20 +41,40 @@ def generate(query: QueryRequest):
|
||||
|
||||
|
||||
@app.get("/library/files", response_model=List[LibraryFileResponse])
|
||||
async def list_library_file(db: AsyncSession = Depends(get_db)):
|
||||
return await list_files(db)
|
||||
async def list_files(db: AsyncSession = Depends(get_db)):
|
||||
return await library_service.list_files(db)
|
||||
|
||||
|
||||
@app.get("/library/files/{id}", response_model=LibraryFileResponse)
|
||||
async def get_library_file(id: int, db: AsyncSession = Depends(get_db)):
|
||||
return await get_file(db, id)
|
||||
async def get_file(id: int, db: AsyncSession = Depends(get_db)):
|
||||
return await library_service.get_file(db, id)
|
||||
|
||||
|
||||
@app.post("/library/files", response_model=bool)
|
||||
async def add_library_file(data: LibraryFileRequest, db: AsyncSession = Depends(get_db)):
|
||||
return await add_file(db, data)
|
||||
async def add_file(data: LibraryFileRequest, db: AsyncSession = Depends(get_db)):
|
||||
return await library_service.add_file(db, data)
|
||||
|
||||
|
||||
@app.put("/library/files/{id}", response_model=bool)
|
||||
async def edit_library_file(id: int, data: LibraryFileRequest, db: AsyncSession = Depends(get_db)):
|
||||
return await edit_file(db, id, data)
|
||||
async def edit_file(id: int, data: LibraryFileRequest, db: AsyncSession = Depends(get_db)):
|
||||
return await library_service.edit_file(db, id, data)
|
||||
|
||||
|
||||
@app.get("/practice/files/{id}", response_model=List[PracticeQuestionResponse])
|
||||
async def get_question(id: int, db: AsyncSession = Depends(get_db)):
|
||||
return await practice_service.get_question(db, id)
|
||||
|
||||
|
||||
@app.get("/practice/record/{id}", response_model=List[PracticeRecordResponse])
|
||||
async def get_record(id: int, db: AsyncSession = Depends(get_db)):
|
||||
return await practice_service.get_record(db, id)
|
||||
|
||||
|
||||
@app.post("/practice/check/{id}", response_model=List[PracticeCheckResult])
|
||||
async def check_practice(id: int, data: List[PracticeQuestionResponse], db: AsyncSession = Depends(get_db)):
|
||||
return await practice_service.check_practice(db, id, data)
|
||||
|
||||
|
||||
@app.get("/mistake", response_model=List[MistakeResponse])
|
||||
async def list_mistakes(db: AsyncSession = Depends(get_db)):
|
||||
return await mistake_service.list_mistakes(db)
|
||||
|
||||
Reference in New Issue
Block a user