mominah commited on
Commit
c27f8a5
·
verified ·
1 Parent(s): 392c4bc

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -8
main.py CHANGED
@@ -8,7 +8,8 @@ from datetime import datetime
8
 
9
  from fastapi import FastAPI, File, UploadFile, HTTPException, Query, Depends
10
  from fastapi.responses import FileResponse, StreamingResponse
11
- from fastapi.staticfiles import StaticFiles # <-- Imported for serving static files
 
12
 
13
  from llm_initialization import get_llm
14
  from embedding import get_embeddings
@@ -31,12 +32,8 @@ MONGO_CLUSTER_URL = os.getenv("CONNECTION_STRING")
31
 
32
  app = FastAPI(title="VectorStore & Document Management API")
33
 
34
- # ----- New: Setup avatars static file serving using absolute path -----
35
- AVATAR_DIR = os.path.join(os.getcwd(), "avatars")
36
- if not os.path.exists(AVATAR_DIR):
37
- os.makedirs(AVATAR_DIR)
38
- app.mount("/avatars", StaticFiles(directory=AVATAR_DIR), name="avatars")
39
- # --------------------------------------------------------------------------
40
 
41
  # Import auth router and dependencies
42
  from auth import router as auth_router, get_current_user, users_collection
@@ -190,7 +187,7 @@ def chat(
190
  # ----------------------- Remaining Endpoints -----------------------
191
  @app.post("/add_document")
192
  async def add_document(
193
- file: Optional[UploadFile] = File(None), # Changed type to UploadFile
194
  wiki_query: Optional[str] = Query(None),
195
  wiki_url: Optional[str] = Query(None)
196
  ):
 
8
 
9
  from fastapi import FastAPI, File, UploadFile, HTTPException, Query, Depends
10
  from fastapi.responses import FileResponse, StreamingResponse
11
+ # Removed static files mounting for avatars as avatars are now served via GridFS in auth
12
+ #from fastapi.staticfiles import StaticFiles
13
 
14
  from llm_initialization import get_llm
15
  from embedding import get_embeddings
 
32
 
33
  app = FastAPI(title="VectorStore & Document Management API")
34
 
35
+ # Note: Since user avatars are now stored in MongoDB via GridFS and served via /auth/avatar,
36
+ # we no longer mount a local avatars directory.
 
 
 
 
37
 
38
  # Import auth router and dependencies
39
  from auth import router as auth_router, get_current_user, users_collection
 
187
  # ----------------------- Remaining Endpoints -----------------------
188
  @app.post("/add_document")
189
  async def add_document(
190
+ file: Optional[UploadFile] = File(None), # File parameter now is an UploadFile
191
  wiki_query: Optional[str] = Query(None),
192
  wiki_url: Optional[str] = Query(None)
193
  ):