Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,40 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
|
|
|
|
|
|
3 |
from agents.voice_agent import speech_to_text, text_to_speech
|
4 |
|
5 |
-
st.
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
else:
|
12 |
-
if st.button("Get
|
13 |
query = "What's our risk exposure in Asia tech stocks today?"
|
14 |
|
15 |
if query:
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from agents.api_agent import get_asia_tech_risk
|
3 |
+
from agents.scraping_agent import get_earnings_news
|
4 |
+
from agents.analysis_agent import get_aum_change, earnings_summary
|
5 |
+
from agents.language_agent import generate_brief
|
6 |
from agents.voice_agent import speech_to_text, text_to_speech
|
7 |
|
8 |
+
st.set_page_config(page_title="🧠 Finance Assistant", layout="centered")
|
9 |
+
st.title("🧠 Morning Market Brief - Voice Assistant")
|
10 |
|
11 |
+
st.markdown("Ask: _What's our risk exposure in Asia tech stocks today?_")
|
12 |
+
|
13 |
+
input_mode = st.radio("Choose input mode", ["🎤 Voice", "⌨️ Button"])
|
14 |
+
|
15 |
+
query = ""
|
16 |
+
if input_mode == "🎤 Voice":
|
17 |
+
if st.button("Record Voice"):
|
18 |
+
query = speech_to_text()
|
19 |
+
st.write("You said:", query)
|
20 |
else:
|
21 |
+
if st.button("Get Market Brief"):
|
22 |
query = "What's our risk exposure in Asia tech stocks today?"
|
23 |
|
24 |
if query:
|
25 |
+
# Get agent responses
|
26 |
+
stocks = get_asia_tech_risk(['TSM', 'SSNLF'])
|
27 |
+
news = get_earnings_news()
|
28 |
+
earnings = earnings_summary(stocks)
|
29 |
+
aum_change = get_aum_change(22, 18)
|
30 |
+
narrative = generate_brief(query)
|
31 |
+
|
32 |
+
final_brief = (
|
33 |
+
f"Today, your Asia tech allocation is 22% of AUM, up from 18% yesterday.\n\n"
|
34 |
+
f"Earnings Summary: {earnings}.\n\n"
|
35 |
+
f"Top Headlines:\n" + "\n".join([f"- {h}" for h in news]) + "\n\n"
|
36 |
+
f"{narrative}"
|
37 |
+
)
|
38 |
+
|
39 |
+
st.success(final_brief)
|
40 |
+
text_to_speech(final_brief)
|