dahutapea commited on
Commit
4eda25e
·
1 Parent(s): b534bcc

Add starter-question buttons to UI; add live demo link to README

Browse files
Files changed (2) hide show
  1. README.md +1 -2
  2. app.py +20 -1
README.md CHANGED
@@ -20,8 +20,7 @@ citations** — instead of making things up.
20
 
21
  > Portfolio project · Retrieval-Augmented Generation over financial documents.
22
 
23
- <!-- After deploying, add your live link here:
24
- **🔗 Live demo:** https://huggingface.co/spaces/<your-username>/finchat -->
25
 
26
  ---
27
 
 
20
 
21
  > Portfolio project · Retrieval-Augmented Generation over financial documents.
22
 
23
+ **🔗 Live demo:** <https://huggingface.co/spaces/dahutapea/Finchat>
 
24
 
25
  ---
26
 
app.py CHANGED
@@ -32,6 +32,14 @@ with st.sidebar:
32
  st.markdown(f"- **{ticker}** — {name}")
33
  st.caption("Source: SEC 10-K filings, 2017–2020.")
34
 
 
 
 
 
 
 
 
 
35
  # --- chat history -----------------------------------------------------------
36
  if "messages" not in st.session_state:
37
  st.session_state.messages = []
@@ -40,8 +48,19 @@ for msg in st.session_state.messages:
40
  with st.chat_message(msg["role"]):
41
  st.markdown(msg["content"])
42
 
 
 
 
 
 
 
 
 
 
43
  # --- new question -----------------------------------------------------------
44
- if prompt := st.chat_input("e.g. What were AMD's main risk factors?"):
 
 
45
  st.session_state.messages.append({"role": "user", "content": prompt})
46
  with st.chat_message("user"):
47
  st.markdown(prompt)
 
32
  st.markdown(f"- **{ticker}** — {name}")
33
  st.caption("Source: SEC 10-K filings, 2017–2020.")
34
 
35
+ # --- starter questions (clickable examples) ---------------------------------
36
+ STARTER_QUESTIONS = [
37
+ "What are AMD's main business risks?",
38
+ "What are Abbott's business segments?",
39
+ "What is Air Products' primary business?",
40
+ "What does Matson's logistics business do?",
41
+ ]
42
+
43
  # --- chat history -----------------------------------------------------------
44
  if "messages" not in st.session_state:
45
  st.session_state.messages = []
 
48
  with st.chat_message(msg["role"]):
49
  st.markdown(msg["content"])
50
 
51
+ # Clickable examples, shown only until the first question is asked.
52
+ if not st.session_state.messages and "pending" not in st.session_state:
53
+ st.markdown("**Try one of these to get started:**")
54
+ cols = st.columns(2)
55
+ for i, example in enumerate(STARTER_QUESTIONS):
56
+ if cols[i % 2].button(example, use_container_width=True):
57
+ st.session_state.pending = example
58
+ st.rerun()
59
+
60
  # --- new question -----------------------------------------------------------
61
+ # A question can arrive from the chat box or from a starter button.
62
+ prompt = st.chat_input("e.g. What were AMD's main risk factors?") or st.session_state.pop("pending", None)
63
+ if prompt:
64
  st.session_state.messages.append({"role": "user", "content": prompt})
65
  with st.chat_message("user"):
66
  st.markdown(prompt)