Spaces:
Runtime error
Runtime error
Update pages/Example.py
Browse files- pages/Example.py +25 -2
pages/Example.py
CHANGED
|
@@ -1,4 +1,27 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
st.title("🧪 Example Page")
|
| 4 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from utils.backend import run_llm
|
| 3 |
|
| 4 |
+
st.title("🧪 Example Page with Chatbot")
|
| 5 |
+
st.write("This is a demo page showing how any `/pages/*.py` file becomes a sidebar entry.")
|
| 6 |
+
|
| 7 |
+
# Initialize session state
|
| 8 |
+
if "example_chat" not in st.session_state:
|
| 9 |
+
st.session_state.example_chat = []
|
| 10 |
+
|
| 11 |
+
# Display chat history
|
| 12 |
+
for msg in st.session_state.example_chat:
|
| 13 |
+
with st.chat_message(msg["role"]):
|
| 14 |
+
st.markdown(msg["content"])
|
| 15 |
+
|
| 16 |
+
# Chat input
|
| 17 |
+
if prompt := st.chat_input("Say something to the Example Chatbot..."):
|
| 18 |
+
# Add user message
|
| 19 |
+
st.session_state.example_chat.append({"role": "user", "content": prompt})
|
| 20 |
+
with st.chat_message("user"):
|
| 21 |
+
st.markdown(prompt)
|
| 22 |
+
|
| 23 |
+
# Generate AI response
|
| 24 |
+
with st.chat_message("assistant"):
|
| 25 |
+
ai_reply = run_llm(prompt)
|
| 26 |
+
st.markdown(ai_reply)
|
| 27 |
+
st.session_state.example_chat.append({"role": "assistant", "content": ai_reply})
|