mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-08-27 03:29:36 +00:00
Added api for document listing
This commit is contained in:
parent
c8b39c898c
commit
c45f5b993d
@ -15,7 +15,7 @@ from private_gpt.server.ingest.ingest_router import common_ingest_logic, IngestR
|
||||
from private_gpt.constants import OCR_UPLOAD
|
||||
|
||||
|
||||
pdf_router = APIRouter(prefix="/pdf", tags=["ocr"])
|
||||
pdf_router = APIRouter(prefix="/v1", tags=["ocr"])
|
||||
|
||||
|
||||
@pdf_router.post("/pdf_ocr")
|
||||
|
@ -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…
Reference in New Issue
Block a user