Saleh commited on
Commit ·
d1f7078
1
Parent(s): 2447eba
Fix Spaces crash: use pysqlite3 for ChromaDB and remove hardcoded port
Browse files- app.py +12 -3
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -33,6 +33,17 @@ from dotenv import load_dotenv
|
|
| 33 |
# Load environment variables
|
| 34 |
load_dotenv()
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# ============================================================
|
| 37 |
# Pipeline Logger — engineering_guardrails.md §5.1
|
| 38 |
# ============================================================
|
|
@@ -1038,10 +1049,8 @@ if __name__ == "__main__":
|
|
| 1038 |
print(" Or export it: export OPENAI_API_KEY=your-key-here")
|
| 1039 |
print()
|
| 1040 |
|
| 1041 |
-
|
| 1042 |
ui.launch(
|
| 1043 |
-
server_name="0.0.0.0",
|
| 1044 |
-
server_port=7860,
|
| 1045 |
theme=gr.themes.Default(primary_hue="blue", secondary_hue="slate"),
|
| 1046 |
css=".main-header {text-align: center; margin-bottom: 2rem;} .upload-area {min-height: 150px;}"
|
| 1047 |
)
|
|
|
|
| 33 |
# Load environment variables
|
| 34 |
load_dotenv()
|
| 35 |
|
| 36 |
+
# ============================================================
|
| 37 |
+
# SQLite Fix for Hugging Face Spaces (ChromaDB requirement)
|
| 38 |
+
# ============================================================
|
| 39 |
+
if sys.platform.startswith("linux"):
|
| 40 |
+
try:
|
| 41 |
+
__import__("pysqlite3")
|
| 42 |
+
sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
|
| 43 |
+
except ImportError:
|
| 44 |
+
pass
|
| 45 |
+
|
| 46 |
+
|
| 47 |
# ============================================================
|
| 48 |
# Pipeline Logger — engineering_guardrails.md §5.1
|
| 49 |
# ============================================================
|
|
|
|
| 1049 |
print(" Or export it: export OPENAI_API_KEY=your-key-here")
|
| 1050 |
print()
|
| 1051 |
|
| 1052 |
+
# Launch with environment variables handling port/host
|
| 1053 |
ui.launch(
|
|
|
|
|
|
|
| 1054 |
theme=gr.themes.Default(primary_hue="blue", secondary_hue="slate"),
|
| 1055 |
css=".main-header {text-align: center; margin-bottom: 2rem;} .upload-area {min-height: 150px;}"
|
| 1056 |
)
|
requirements.txt
CHANGED
|
@@ -6,4 +6,4 @@ pydantic>=2.0.0
|
|
| 6 |
gradio>=5.0.0
|
| 7 |
python-dotenv>=1.0.0
|
| 8 |
requests>=2.31.0
|
| 9 |
-
|
|
|
|
| 6 |
gradio>=5.0.0
|
| 7 |
python-dotenv>=1.0.0
|
| 8 |
requests>=2.31.0
|
| 9 |
+
pysqlite3-binary # Required for CrewAI/ChromaDB on Linux (HF Spaces)
|