menikev commited on
Commit
38188b4
·
verified ·
1 Parent(s): 414ed03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -29
app.py CHANGED
@@ -2,38 +2,37 @@ import streamlit as st
2
  import plotly.graph_objs as go
3
  from main import CryptoCrew
4
 
5
- st.title("Crypto Analysis and Coaching")
6
 
7
  crypto = st.text_input("Enter the cryptocurrency you want to analyze:")
8
 
9
  if st.button("Analyze"):
10
  with st.spinner("Analyzing... This may take a few minutes."):
11
  crypto_crew = CryptoCrew(crypto)
12
- result = crypto_crew.run() # This now runs the synchronous wrapper method
13
-
14
- # Display summary
15
- st.subheader("Analysis Summary")
16
- st.write(result["summary"])
17
-
18
- # Visualize sentiment
19
- st.subheader("Sentiment Analysis")
20
- sentiment_data = result.get("sentiment", {})
21
- sentiment_categories = list(sentiment_data.keys())
22
- sentiment_values = [1 if v == "Positive" else (-1 if v == "Negative" else 0) for v in sentiment_data.values()]
23
- colors = ['red' if v < 0 else 'green' if v > 0 else 'gray' for v in sentiment_values]
24
-
25
- if sentiment_categories and sentiment_values:
26
- fig = go.Figure(data=[go.Bar(
27
- x=sentiment_categories,
28
- y=sentiment_values,
29
- marker_color=colors
30
- )])
31
- fig.update_layout(
32
- title="Sentiment Analysis",
33
- xaxis_title="Category",
34
- yaxis_title="Sentiment (Negative to Positive)",
35
- yaxis=dict(tickvals=[-1, 0, 1], ticktext=["Negative", "Neutral", "Positive"])
36
- )
37
- st.plotly_chart(fig)
38
- else:
39
- st.write("No sentiment data available.")
 
2
  import plotly.graph_objs as go
3
  from main import CryptoCrew
4
 
5
+ st.title("Crypto Analyst")
6
 
7
  crypto = st.text_input("Enter the cryptocurrency you want to analyze:")
8
 
9
  if st.button("Analyze"):
10
  with st.spinner("Analyzing... This may take a few minutes."):
11
  crypto_crew = CryptoCrew(crypto)
12
+ result = crypto_crew.run()
13
+
14
+ # Display summary
15
+ st.subheader("Analysis Summary")
16
+ st.write(result["summary"])
17
+
18
+ # Visualize sentiment
19
+ st.subheader("Sentiment Analysis")
20
+ sentiment_data = result["sentiment"]
21
+ sentiment_categories = list(sentiment_data.keys())
22
+ sentiment_values = [1 if v == "Positive" else (-1 if v == "Negative" else 0) for v in sentiment_data.values()]
23
+ colors = ['red' if v < 0 else 'green' if v > 0 else 'gray' for v in sentiment_values]
24
+
25
+ fig = go.Figure(data=[go.Bar(
26
+ x=sentiment_categories,
27
+ y=sentiment_values,
28
+ marker_color=colors
29
+ )])
30
+
31
+ fig.update_layout(
32
+ title="Sentiment Analysis",
33
+ xaxis_title="Category",
34
+ yaxis_title="Sentiment (Negative to Positive)",
35
+ yaxis=dict(tickvals=[-1, 0, 1], ticktext=["Negative", "Neutral", "Positive"])
36
+ )
37
+
38
+ st.plotly_chart(fig)