zypchn commited on
Commit
5703cae
·
verified ·
1 Parent(s): a240073

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
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})