Spaces:
Running
Running
Anirudh Esthuri
commited on
Commit
Β·
1dbbeef
1
Parent(s):
a56dead
Fix: Add error handling for missing files and use PORT env var correctly
Browse files- Dockerfile +2 -1
- app.py +9 -3
Dockerfile
CHANGED
|
@@ -47,4 +47,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
| 47 |
CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
|
| 48 |
|
| 49 |
# Run Streamlit app using PORT env var from Hugging Face Spaces
|
| 50 |
-
|
|
|
|
|
|
| 47 |
CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
|
| 48 |
|
| 49 |
# Run Streamlit app using PORT env var from Hugging Face Spaces
|
| 50 |
+
# HuggingFace sets $PORT, don't override it.
|
| 51 |
+
CMD ["bash", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=$PORT --server.headless=true"]
|
app.py
CHANGED
|
@@ -41,15 +41,21 @@ def rewrite_message(
|
|
| 41 |
# Page setup & CSS
|
| 42 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
# Sidebar
|
| 50 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 51 |
with st.sidebar:
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
st.markdown("#### Choose Model")
|
| 55 |
|
|
|
|
| 41 |
# Page setup & CSS
|
| 42 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
|
| 44 |
+
try:
|
| 45 |
+
with open("./styles.css") as f:
|
| 46 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
| 47 |
+
except FileNotFoundError:
|
| 48 |
+
st.markdown("<style></style>", unsafe_allow_html=True)
|
| 49 |
|
| 50 |
|
| 51 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
# Sidebar
|
| 53 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 54 |
with st.sidebar:
|
| 55 |
+
try:
|
| 56 |
+
st.image("./assets/memmachine_logo.png", use_container_width=True)
|
| 57 |
+
except FileNotFoundError:
|
| 58 |
+
st.markdown("### MemMachine")
|
| 59 |
|
| 60 |
st.markdown("#### Choose Model")
|
| 61 |
|