mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 20:12:55 +01:00
Added api for document listing
This commit is contained in:
parent
c8b39c898c
commit
c45f5b993d
2 changed files with 29 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
from typing import Literal, Optional, List
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, UploadFile, File, status, Security, Body
|
||||
|
|
@ -275,3 +275,30 @@ async def common_ingest_logic(
|
|||
status_code=500,
|
||||
detail="Internal Server Error: Unable to ingest file.",
|
||||
)
|
||||
|
||||
from private_gpt.users.schemas import Document
|
||||
|
||||
@ingest_router.get("/ingest/list_files", response_model=List[schemas.Document], tags=["Ingestion"])
|
||||
def list_files(
|
||||
request: Request,
|
||||
db: Session = Depends(deps.get_db),
|
||||
skip: int = 0,
|
||||
limit: int = 100,
|
||||
current_user: models.User = Security(
|
||||
deps.get_current_user,
|
||||
scopes=[Role.ADMIN["name"], Role.SUPER_ADMIN["name"]],
|
||||
|
||||
)
|
||||
):
|
||||
try:
|
||||
docs = crud.documents.get_multi(db, skip=skip, limit=limit)
|
||||
return docs
|
||||
except Exception as e:
|
||||
logger.error(f"There was an error uploading the file(s): {str(e)}")
|
||||
print("ERROR: ", e)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Internal Server Error: Unable to ingest file.",
|
||||
)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue