Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,18 +25,13 @@ load_dotenv()
|
|
| 25 |
|
| 26 |
app = Flask(__name__)
|
| 27 |
app.secret_key = os.getenv("SECRET_KEY", "default_secret_key")
|
| 28 |
-
|
| 29 |
-
app.config['
|
| 30 |
-
app.config['MAX_CONTENT_LENGTH'] = 50 * 1024 * 1024 # 50MB limit
|
| 31 |
|
| 32 |
# Faiss Configuration
|
| 33 |
-
FAISS_INDEX_DIR =
|
| 34 |
EMBEDDING_DIM = 768 # all-mpnet-base-v2 embedding dimension
|
| 35 |
|
| 36 |
-
# Ensure writable directories exist when running under gunicorn
|
| 37 |
-
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 38 |
-
os.makedirs(FAISS_INDEX_DIR, exist_ok=True)
|
| 39 |
-
|
| 40 |
# Chunking Configuration
|
| 41 |
CHUNK_SIZE = 1000
|
| 42 |
CHUNK_OVERLAP = 200
|
|
@@ -49,9 +44,7 @@ model = AutoModel.from_pretrained("sentence-transformers/all-mpnet-base-v2")
|
|
| 49 |
# Initialize Mistral client directly (like test.py)
|
| 50 |
from mistralai import Mistral
|
| 51 |
|
| 52 |
-
mistral_api_key =
|
| 53 |
-
if not mistral_api_key:
|
| 54 |
-
raise RuntimeError("MISTRAL_API_KEY not set. Please configure it as an environment variable.")
|
| 55 |
mistral_client = Mistral(api_key=mistral_api_key)
|
| 56 |
|
| 57 |
# API throttling configuration
|
|
@@ -899,5 +892,4 @@ def download_saved_pdf():
|
|
| 899 |
if __name__ == '__main__':
|
| 900 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 901 |
os.makedirs(FAISS_INDEX_DIR, exist_ok=True)
|
| 902 |
-
|
| 903 |
-
app.run(host="0.0.0.0", port=port, debug=True)
|
|
|
|
| 25 |
|
| 26 |
app = Flask(__name__)
|
| 27 |
app.secret_key = os.getenv("SECRET_KEY", "default_secret_key")
|
| 28 |
+
app.config['UPLOAD_FOLDER'] = 'uploads'
|
| 29 |
+
app.config['MAX_CONTENT_LENGTH'] = 10 * 1024 * 1024 # 10MB limit
|
|
|
|
| 30 |
|
| 31 |
# Faiss Configuration
|
| 32 |
+
FAISS_INDEX_DIR = "faiss_indices"
|
| 33 |
EMBEDDING_DIM = 768 # all-mpnet-base-v2 embedding dimension
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Chunking Configuration
|
| 36 |
CHUNK_SIZE = 1000
|
| 37 |
CHUNK_OVERLAP = 200
|
|
|
|
| 44 |
# Initialize Mistral client directly (like test.py)
|
| 45 |
from mistralai import Mistral
|
| 46 |
|
| 47 |
+
mistral_api_key = "8cQw0T1eRC5NY3bKDg6CxNU6465gxoW4"
|
|
|
|
|
|
|
| 48 |
mistral_client = Mistral(api_key=mistral_api_key)
|
| 49 |
|
| 50 |
# API throttling configuration
|
|
|
|
| 892 |
if __name__ == '__main__':
|
| 893 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 894 |
os.makedirs(FAISS_INDEX_DIR, exist_ok=True)
|
| 895 |
+
app.run(debug=True)
|
|
|