MrSiebel585 commited on
Commit
0a1f9c3
·
1 Parent(s): 0d36f9e

Add Streamlit multipage app with FastAPI backend

Browse files
Files changed (5) hide show
  1. Dockerfile +9 -6
  2. api_backend.py +8 -0
  3. app.py +25 -9
  4. pages/Omnieye.py +4 -0
  5. pages/Omnilog.py +4 -0
Dockerfile CHANGED
@@ -1,18 +1,21 @@
1
  FROM python:3.11-slim
2
 
3
- # Add user
4
  RUN useradd -m -u 1000 user
5
  USER user
6
  ENV PATH="/home/user/.local/bin:$PATH"
7
 
8
  WORKDIR /app
9
 
10
- # Install dependencies
11
  COPY --chown=user requirements.txt requirements.txt
12
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
- # Copy project
15
  COPY --chown=user . /app
16
 
17
- # Run FastAPI (main entrypoint for the Space)
18
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
+ # Create user
4
  RUN useradd -m -u 1000 user
5
  USER user
6
  ENV PATH="/home/user/.local/bin:$PATH"
7
 
8
  WORKDIR /app
9
 
10
+ # Install deps
11
  COPY --chown=user requirements.txt requirements.txt
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Copy app files
15
  COPY --chown=user . /app
16
 
17
+ # Hugging Face requires port 7860
18
+ EXPOSE 7860
19
+
20
+ # Run Streamlit on port 7860
21
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
api_backend.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.responses import JSONResponse
3
+
4
+ app = FastAPI(title="Omniscient Backend API")
5
+
6
+ @app.get("/health")
7
+ def health():
8
+ return JSONResponse({"ok": True, "message": "Omniscient backend alive"})
app.py CHANGED
@@ -1,12 +1,28 @@
1
- from fastapi import FastAPI
2
- from fastapi.responses import JSONResponse
3
 
4
- app = FastAPI(title="Omniscient Hybrid UI")
5
 
6
- @app.get("/")
7
- def root():
8
- return {"status": "ok", "message": "Omniscient Hybrid Space Running!"}
9
 
10
- @app.get("/health")
11
- def health():
12
- return JSONResponse({"ok": True, "frameworks": ["Streamlit", "Gradio", "Chainlit"]})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
 
2
 
3
+ st.set_page_config(page_title="Omniscient Dashboard", layout="wide")
4
 
5
+ st.title("🤖 Omniscient LLM Dashboard")
6
+ st.write("This Hugging Face Space runs **Streamlit** as the default UI.")
 
7
 
8
+ page = st.sidebar.radio("📑 Pages", ["Chat", "System Health"])
9
+
10
+ if "messages" not in st.session_state:
11
+ st.session_state.messages = []
12
+
13
+ if page == "Chat":
14
+ st.subheader("Chat Interface")
15
+ for m in st.session_state.messages:
16
+ st.chat_message(m["role"]).write(m["content"])
17
+
18
+ if prompt := st.chat_input("Ask me anything..."):
19
+ st.session_state.messages.append({"role": "user", "content": prompt})
20
+ with st.chat_message("assistant"):
21
+ reply = f"Echo: {prompt} (LLM hook goes here)"
22
+ st.write(reply)
23
+ st.session_state.messages.append({"role": "assistant", "content": reply})
24
+
25
+ elif page == "System Health":
26
+ st.subheader("System Health")
27
+ st.metric("Active Sessions", len(st.session_state.get("messages", [])))
28
+ st.success("Backend API is running on /health (FastAPI)")
pages/Omnieye.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("👁️ Omnieye")
4
+ st.write("This is a placeholder for the Omnieye module.")
pages/Omnilog.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("📜 Omnilog")
4
+ st.write("This is a placeholder for the Omnilog module.")