fixes after the refactor

Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
lucasew 2024-01-23 12:59:52 -03:00
parent d2c5f3d591
commit 8da06f5e74
3 changed files with 8 additions and 7 deletions

View file

@ -111,12 +111,12 @@ def upload(file: UploadFile = File(...)):
file_path = f"{UPLOAD_DIR}/{file.filename}"
# Save file in chunks
with file_path.open("wb+") as f:
with open(file_path, "wb+") as f:
for chunk in file.file:
f.write(chunk)
def file_process_stream():
total_size = os.path.getsize(str(file_path))
total_size = os.path.getsize(file_path)
chunk_size = 1024 * 1024
try:
with open(file_path, "rb") as f:

View file

@ -25,12 +25,13 @@ except ImportError:
# File Upload
####################################
DATA_DIR = Path(os.getenv("DATA_DIR", "./data")).resolve()
DATA_DIR = str(Path(os.getenv("DATA_DIR", "./data")).resolve())
UPLOAD_DIR = f"{DATA_DIR}/uploads"
UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", "../build"))
Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True)
FRONTEND_BUILD_DIR = str(Path(os.getenv("FRONTEND_BUILD_DIR", "../build")))
####################################
# ENV (dev,test,prod)
@ -88,7 +89,7 @@ if WEBUI_AUTH and WEBUI_JWT_SECRET_KEY == "":
CHROMA_DATA_PATH = f"{DATA_DIR}/vector_db"
EMBED_MODEL = "all-MiniLM-L6-v2"
CHROMA_CLIENT = chromadb.PersistentClient(
path=str(CHROMA_DATA_PATH), settings=Settings(allow_reset=True)
path=CHROMA_DATA_PATH, settings=Settings(allow_reset=True)
)
CHUNK_SIZE = 1500
CHUNK_OVERLAP = 100

View file

@ -60,6 +60,6 @@ app.mount("/rag/api/v1", rag_app)
app.mount(
"/",
SPAStaticFiles(directory=str(FRONTEND_BUILD_DIR), html=True),
SPAStaticFiles(directory=FRONTEND_BUILD_DIR, html=True),
name="spa-static-files",
)