Merge pull request #536 from lucasew/backend-data-dir

Unhardcode some stuff, flexibilize dotenv requirement
This commit is contained in:
Timothy Jaeryang Baek 2024-01-25 00:42:12 -08:00 committed by GitHub
commit a243e53bfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 26 deletions

View file

@ -11,7 +11,7 @@ import json
from utils.misc import calculate_sha256
from config import OLLAMA_API_BASE_URL
from config import OLLAMA_API_BASE_URL, DATA_DIR, UPLOAD_DIR
from constants import ERROR_MESSAGES
@ -96,8 +96,7 @@ async def download(
file_name = parse_huggingface_url(url)
if file_name:
os.makedirs("./uploads", exist_ok=True)
file_path = os.path.join("./uploads", f"{file_name}")
file_path = f"{UPLOAD_DIR}/{file_name}"
return StreamingResponse(
download_file_stream(url, file_path, file_name),
@ -109,8 +108,7 @@ async def download(
@router.post("/upload")
def upload(file: UploadFile = File(...)):
os.makedirs("./data/uploads", exist_ok=True)
file_path = os.path.join("./data/uploads", file.filename)
file_path = f"{UPLOAD_DIR}/{file.filename}"
# Save file in chunks
with open(file_path, "wb+") as f: