Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +55 -38
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,57 @@
|
|
| 1 |
-
import altair as alt
|
| 2 |
-
import numpy as np
|
| 3 |
-
import pandas as pd
|
| 4 |
import streamlit as st
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
"
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
# --- 1. Page Configuration ---
|
| 4 |
+
st.set_page_config(page_title="cAsh Robo-Advisor", page_icon="🤖")
|
| 5 |
+
|
| 6 |
+
# --- 2. Styling & Header ---
|
| 7 |
+
st.title("🤖 cAsh Robo-Advisor")
|
| 8 |
+
st.markdown("""
|
| 9 |
+
**Your AI Quantitative Analyst for Pokemon Cards.**
|
| 10 |
+
|
| 11 |
+
Ask about:
|
| 12 |
+
* **Arbitrage:** "What are the best grading opportunities?"
|
| 13 |
+
* **Risk:** "Is Charizard VMAX a safe investment?"
|
| 14 |
+
* **Trends:** "What is crashing right now?"
|
| 15 |
+
* **Sets:** "How is Evolving Skies performing?"
|
| 16 |
+
""")
|
| 17 |
+
|
| 18 |
+
# --- 3. Initialize Chat History ---
|
| 19 |
+
# Streamlit reruns the whole script on every interaction,
|
| 20 |
+
# so we store messages in 'session_state'.
|
| 21 |
+
if "messages" not in st.session_state:
|
| 22 |
+
st.session_state.messages = []
|
| 23 |
+
|
| 24 |
+
# --- 4. Display Chat History ---
|
| 25 |
+
for message in st.session_state.messages:
|
| 26 |
+
with st.chat_message(message["role"]):
|
| 27 |
+
st.markdown(message["content"])
|
| 28 |
+
|
| 29 |
+
# --- 5. Sidebar Examples (Equivalent to Gradio Examples) ---
|
| 30 |
+
st.sidebar.header("Example Queries")
|
| 31 |
+
examples = [
|
| 32 |
+
"What are the top 3 grading opportunities right now?",
|
| 33 |
+
"Is investing in Charizard VMAX risky?",
|
| 34 |
+
"What cards are trending down?",
|
| 35 |
+
"Show me profitable cards by Tomokazu Komiya."
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
for ex in examples:
|
| 39 |
+
if st.sidebar.button(ex):
|
| 40 |
+
# This allows the sidebar buttons to act as user inputs
|
| 41 |
+
st.session_state.messages.append({"role": "user", "content": ex})
|
| 42 |
+
# Note: You'd call your 'ask_advisor' logic here for the example buttons
|
| 43 |
+
|
| 44 |
+
# --- 6. Chat Input Logic ---
|
| 45 |
+
if prompt := st.chat_input("Ask your Pokemon Quants advisor..."):
|
| 46 |
+
# Display user message
|
| 47 |
+
with st.chat_message("user"):
|
| 48 |
+
st.markdown(prompt)
|
| 49 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 50 |
+
|
| 51 |
+
# Generate Response (Replace 'ask_advisor' with your actual function)
|
| 52 |
+
with st.chat_message("assistant"):
|
| 53 |
+
# response = ask_advisor(prompt, st.session_state.messages)
|
| 54 |
+
response = f"Analysis for: '{prompt}'. (Connect your ask_advisor function here)"
|
| 55 |
+
st.markdown(response)
|
| 56 |
+
|
| 57 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|