forked from open-webui/open-webui
refac: convert str var to f-string
This commit is contained in:
parent
5b26d2a686
commit
d2c5f3d591
4 changed files with 14 additions and 9 deletions
|
@ -2,5 +2,5 @@ from peewee import *
|
|||
from config import DATA_DIR
|
||||
|
||||
|
||||
DB = SqliteDatabase(str(DATA_DIR / "ollama.db"))
|
||||
DB = SqliteDatabase(f"{DATA_DIR}/ollama.db")
|
||||
DB.connect()
|
||||
|
|
|
@ -96,7 +96,7 @@ async def download(
|
|||
file_name = parse_huggingface_url(url)
|
||||
|
||||
if file_name:
|
||||
file_path = str(UPLOAD_DIR / file_name)
|
||||
file_path = f"{UPLOAD_DIR}/{file_name}"
|
||||
|
||||
return StreamingResponse(
|
||||
download_file_stream(url, file_path, file_name),
|
||||
|
@ -108,7 +108,7 @@ async def download(
|
|||
|
||||
@router.post("/upload")
|
||||
def upload(file: UploadFile = File(...)):
|
||||
file_path = UPLOAD_DIR / file.filename
|
||||
file_path = f"{UPLOAD_DIR}/{file.filename}"
|
||||
|
||||
# Save file in chunks
|
||||
with file_path.open("wb+") as f:
|
||||
|
|
|
@ -15,6 +15,7 @@ from pathlib import Path
|
|||
|
||||
try:
|
||||
from dotenv import load_dotenv, find_dotenv
|
||||
|
||||
load_dotenv(find_dotenv("../.env"))
|
||||
except ImportError:
|
||||
print("dotenv not installed, skipping...")
|
||||
|
@ -24,12 +25,12 @@ except ImportError:
|
|||
# File Upload
|
||||
####################################
|
||||
|
||||
DATA_DIR = Path(os.getenv("DATA_DIR", './data')).resolve()
|
||||
DATA_DIR = Path(os.getenv("DATA_DIR", "./data")).resolve()
|
||||
|
||||
UPLOAD_DIR = DATA_DIR / "uploads"
|
||||
UPLOAD_DIR = f"{DATA_DIR}/uploads"
|
||||
UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
WEB_DIR = Path(os.getenv("WEB_DIR", "../build"))
|
||||
FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", "../build"))
|
||||
|
||||
####################################
|
||||
# ENV (dev,test,prod)
|
||||
|
@ -84,7 +85,7 @@ if WEBUI_AUTH and WEBUI_JWT_SECRET_KEY == "":
|
|||
# RAG
|
||||
####################################
|
||||
|
||||
CHROMA_DATA_PATH = DATA_DIR / "vector_db"
|
||||
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)
|
||||
|
|
|
@ -14,7 +14,7 @@ from apps.openai.main import app as openai_app
|
|||
from apps.web.main import app as webui_app
|
||||
from apps.rag.main import app as rag_app
|
||||
|
||||
from config import ENV, WEB_DIR
|
||||
from config import ENV, FRONTEND_BUILD_DIR
|
||||
|
||||
|
||||
class SPAStaticFiles(StaticFiles):
|
||||
|
@ -58,4 +58,8 @@ app.mount("/openai/api", openai_app)
|
|||
app.mount("/rag/api/v1", rag_app)
|
||||
|
||||
|
||||
app.mount("/", SPAStaticFiles(directory=str(WEB_DIR), html=True), name="spa-static-files")
|
||||
app.mount(
|
||||
"/",
|
||||
SPAStaticFiles(directory=str(FRONTEND_BUILD_DIR), html=True),
|
||||
name="spa-static-files",
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue