Spaces:
Sleeping
Sleeping
Commit
·
92cce12
1
Parent(s):
eda701e
Fix upload path to be part of environment vairiable
Browse files- config/__pycache__/config.cpython-312.pyc +0 -0
- config/config.py +3 -0
- src/__pycache__/main.cpython-312.pyc +0 -0
- src/implementations/__pycache__/document_service.cpython-312.pyc +0 -0
- src/implementations/document_service.py +2 -1
- src/main.py +5 -4
- src/utils/__pycache__/database_cleanup.cpython-312.pyc +0 -0
- src/utils/database_cleanup.py +1 -1
- src/vectorstores/__pycache__/optimized_vectorstore.cpython-312.pyc +0 -0
config/__pycache__/config.cpython-312.pyc
CHANGED
|
Binary files a/config/__pycache__/config.cpython-312.pyc and b/config/__pycache__/config.cpython-312.pyc differ
|
|
|
config/config.py
CHANGED
|
@@ -73,6 +73,9 @@ class Settings:
|
|
| 73 |
# Temporary directory for downloaded files
|
| 74 |
TEMP_DOWNLOAD_DIR = os.getenv('TEMP_DOWNLOAD_DIR', './temp_downloads')
|
| 75 |
|
|
|
|
|
|
|
|
|
|
| 76 |
# Application Configuration
|
| 77 |
DEBUG = os.getenv('DEBUG', 'False') == 'True'
|
| 78 |
|
|
|
|
| 73 |
# Temporary directory for downloaded files
|
| 74 |
TEMP_DOWNLOAD_DIR = os.getenv('TEMP_DOWNLOAD_DIR', './temp_downloads')
|
| 75 |
|
| 76 |
+
# Uploads directory for storing uploaded files
|
| 77 |
+
UPLOADS_DIR = os.getenv('UPLOADS_DIR', '/app/uploads')
|
| 78 |
+
|
| 79 |
# Application Configuration
|
| 80 |
DEBUG = os.getenv('DEBUG', 'False') == 'True'
|
| 81 |
|
src/__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/src/__pycache__/main.cpython-312.pyc and b/src/__pycache__/main.cpython-312.pyc differ
|
|
|
src/implementations/__pycache__/document_service.cpython-312.pyc
CHANGED
|
Binary files a/src/implementations/__pycache__/document_service.cpython-312.pyc and b/src/implementations/__pycache__/document_service.cpython-312.pyc differ
|
|
|
src/implementations/document_service.py
CHANGED
|
@@ -12,6 +12,7 @@ from src.utils.document_processor import DocumentProcessor
|
|
| 12 |
from src.models import DocumentResponse, DocumentInfo, BatchUploadResponse
|
| 13 |
from src.utils.logger import logger
|
| 14 |
from src.db.mongodb_store import MongoDBStore
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
class DocumentService:
|
|
@@ -22,7 +23,7 @@ class DocumentService:
|
|
| 22 |
):
|
| 23 |
self.doc_processor = doc_processor
|
| 24 |
self.mongodb = mongodb
|
| 25 |
-
self.permanent_dir = Path(
|
| 26 |
self.permanent_dir.mkdir(exist_ok=True)
|
| 27 |
|
| 28 |
async def check_duplicate_filename(self, filename: str) -> bool:
|
|
|
|
| 12 |
from src.models import DocumentResponse, DocumentInfo, BatchUploadResponse
|
| 13 |
from src.utils.logger import logger
|
| 14 |
from src.db.mongodb_store import MongoDBStore
|
| 15 |
+
from config.config import settings
|
| 16 |
|
| 17 |
|
| 18 |
class DocumentService:
|
|
|
|
| 23 |
):
|
| 24 |
self.doc_processor = doc_processor
|
| 25 |
self.mongodb = mongodb
|
| 26 |
+
self.permanent_dir = Path(settings.UPLOADS_DIR)
|
| 27 |
self.permanent_dir.mkdir(exist_ok=True)
|
| 28 |
|
| 29 |
async def check_duplicate_filename(self, filename: str) -> bool:
|
src/main.py
CHANGED
|
@@ -71,15 +71,16 @@ app.add_middleware(
|
|
| 71 |
# Initialize MongoDB
|
| 72 |
mongodb = MongoDBStore(settings.MONGODB_URI)
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# Initialize core components
|
| 75 |
doc_processor = DocumentProcessor()
|
| 76 |
summarizer = ConversationSummarizer()
|
| 77 |
document_service = DocumentService(doc_processor, mongodb)
|
| 78 |
|
| 79 |
-
# Create uploads directory if it doesn't exist
|
| 80 |
-
UPLOADS_DIR = Path("uploads")
|
| 81 |
-
UPLOADS_DIR.mkdir(exist_ok=True)
|
| 82 |
-
|
| 83 |
# Mount the uploads directory for static file serving
|
| 84 |
app.mount("/docs", StaticFiles(directory=str(UPLOADS_DIR)), name="documents")
|
| 85 |
|
|
|
|
| 71 |
# Initialize MongoDB
|
| 72 |
mongodb = MongoDBStore(settings.MONGODB_URI)
|
| 73 |
|
| 74 |
+
# Create uploads directory if it doesn't exist
|
| 75 |
+
# UPLOADS_DIR = Path("uploads")
|
| 76 |
+
UPLOADS_DIR = Path(settings.UPLOADS_DIR)
|
| 77 |
+
UPLOADS_DIR.mkdir(exist_ok=True)
|
| 78 |
+
|
| 79 |
# Initialize core components
|
| 80 |
doc_processor = DocumentProcessor()
|
| 81 |
summarizer = ConversationSummarizer()
|
| 82 |
document_service = DocumentService(doc_processor, mongodb)
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
# Mount the uploads directory for static file serving
|
| 85 |
app.mount("/docs", StaticFiles(directory=str(UPLOADS_DIR)), name="documents")
|
| 86 |
|
src/utils/__pycache__/database_cleanup.cpython-312.pyc
CHANGED
|
Binary files a/src/utils/__pycache__/database_cleanup.cpython-312.pyc and b/src/utils/__pycache__/database_cleanup.cpython-312.pyc differ
|
|
|
src/utils/database_cleanup.py
CHANGED
|
@@ -119,7 +119,7 @@ async def cleanup_files() -> List[str]:
|
|
| 119 |
|
| 120 |
# Directories to clean
|
| 121 |
directories = {
|
| 122 |
-
'uploads': Path(
|
| 123 |
'temp_downloads': Path(settings.TEMP_DOWNLOAD_DIR),
|
| 124 |
# Additional temp directory used by some components
|
| 125 |
'temp_dir': Path('./temp')
|
|
|
|
| 119 |
|
| 120 |
# Directories to clean
|
| 121 |
directories = {
|
| 122 |
+
'uploads': Path(settings.UPLOADS_DIR),
|
| 123 |
'temp_downloads': Path(settings.TEMP_DOWNLOAD_DIR),
|
| 124 |
# Additional temp directory used by some components
|
| 125 |
'temp_dir': Path('./temp')
|
src/vectorstores/__pycache__/optimized_vectorstore.cpython-312.pyc
CHANGED
|
Binary files a/src/vectorstores/__pycache__/optimized_vectorstore.cpython-312.pyc and b/src/vectorstores/__pycache__/optimized_vectorstore.cpython-312.pyc differ
|
|
|