Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import os
|
|
7 |
|
8 |
st.set_page_config(page_title="Crypto Analyst", page_icon="π", layout="wide")
|
9 |
|
10 |
-
st.title("β‘
|
11 |
st.markdown("*Powered by Together AI for lightning-fast analysis*")
|
12 |
|
13 |
# Add caching for repeated analyses
|
@@ -22,7 +22,7 @@ with col1:
|
|
22 |
crypto = st.text_input("Enter cryptocurrency name:", placeholder="bitcoin, ethereum, cardano...")
|
23 |
|
24 |
with col2:
|
25 |
-
st.markdown("<br>", unsafe_allow_html=True)
|
26 |
analyze_btn = st.button("π Analyze", type="primary")
|
27 |
|
28 |
if analyze_btn and crypto:
|
@@ -50,7 +50,7 @@ if analyze_btn and crypto:
|
|
50 |
st.subheader("π Sentiment Analysis")
|
51 |
sentiment_data = result["sentiment"]
|
52 |
|
53 |
-
# Create
|
54 |
categories = list(sentiment_data.keys())
|
55 |
values = []
|
56 |
colors = []
|
@@ -85,46 +85,39 @@ if analyze_btn and crypto:
|
|
85 |
|
86 |
st.plotly_chart(fig, use_container_width=True)
|
87 |
|
88 |
-
#
|
89 |
rec_color = {"BUY": "π’", "SELL": "π΄", "HOLD": "π‘"}
|
90 |
st.info(f"{rec_color.get(result.get('recommendation', 'HOLD'), 'π‘')} **Investment Recommendation: {result.get('recommendation', 'HOLD')}**")
|
91 |
|
92 |
except Exception as e:
|
93 |
st.error(f"Analysis failed: {str(e)}")
|
94 |
-
st.info("π‘ **Tips
|
95 |
|
96 |
-
#
|
97 |
with st.sidebar:
|
98 |
-
st.header("βοΈ Setup
|
99 |
-
st.markdown("""
|
100 |
-
**To enable fast analysis:**
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
```
|
107 |
-
3. Install dependencies:
|
108 |
-
```bash
|
109 |
-
pip install together python-dotenv
|
110 |
-
```
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
117 |
""")
|
118 |
|
119 |
-
# Performance tips
|
120 |
st.markdown("---")
|
121 |
-
st.markdown("### π
|
122 |
-
cols = st.columns(
|
123 |
with cols[0]:
|
124 |
-
st.metric("Model Loading", "0s", "
|
125 |
with cols[1]:
|
126 |
-
st.metric("
|
127 |
with cols[2]:
|
128 |
-
st.metric("
|
129 |
-
with cols[3]:
|
130 |
-
st.metric("Total Speedup", "10-50x", "π")
|
|
|
7 |
|
8 |
st.set_page_config(page_title="Crypto Analyst", page_icon="π", layout="wide")
|
9 |
|
10 |
+
st.title("β‘Crypto Analyst")
|
11 |
st.markdown("*Powered by Together AI for lightning-fast analysis*")
|
12 |
|
13 |
# Add caching for repeated analyses
|
|
|
22 |
crypto = st.text_input("Enter cryptocurrency name:", placeholder="bitcoin, ethereum, cardano...")
|
23 |
|
24 |
with col2:
|
25 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
26 |
analyze_btn = st.button("π Analyze", type="primary")
|
27 |
|
28 |
if analyze_btn and crypto:
|
|
|
50 |
st.subheader("π Sentiment Analysis")
|
51 |
sentiment_data = result["sentiment"]
|
52 |
|
53 |
+
# Create sentiment chart
|
54 |
categories = list(sentiment_data.keys())
|
55 |
values = []
|
56 |
colors = []
|
|
|
85 |
|
86 |
st.plotly_chart(fig, use_container_width=True)
|
87 |
|
88 |
+
# Recommendation box
|
89 |
rec_color = {"BUY": "π’", "SELL": "π΄", "HOLD": "π‘"}
|
90 |
st.info(f"{rec_color.get(result.get('recommendation', 'HOLD'), 'π‘')} **Investment Recommendation: {result.get('recommendation', 'HOLD')}**")
|
91 |
|
92 |
except Exception as e:
|
93 |
st.error(f"Analysis failed: {str(e)}")
|
94 |
+
st.info("π‘ **Tips:**\n- Use full cryptocurrency names (e.g., 'bitcoin' not 'btc')\n- Check your API key setup\n- Try again if the first attempt fails")
|
95 |
|
96 |
+
# Sidebar with setup info
|
97 |
with st.sidebar:
|
98 |
+
st.header("βοΈ Setup Status")
|
|
|
|
|
99 |
|
100 |
+
# Check if API key is available
|
101 |
+
import os
|
102 |
+
api_key_status = "β
Connected" if os.getenv("TOGETHER_API_KEY") else "β Missing API Key"
|
103 |
+
st.write(f"Together AI: {api_key_status}")
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
+
if not os.getenv("TOGETHER_API_KEY"):
|
106 |
+
st.error("Add TOGETHER_API_KEY as a secret in HF Spaces settings")
|
107 |
+
|
108 |
+
st.markdown("""
|
109 |
+
**Expected Performance:**
|
110 |
+
- Analysis Time: 10-30s
|
111 |
+
- Memory Usage: ~50MB
|
112 |
+
- No local model loading
|
113 |
""")
|
114 |
|
|
|
115 |
st.markdown("---")
|
116 |
+
st.markdown("### π System Status")
|
117 |
+
cols = st.columns(3)
|
118 |
with cols[0]:
|
119 |
+
st.metric("Model Loading", "0s", "β
Cloud-based")
|
120 |
with cols[1]:
|
121 |
+
st.metric("Memory Usage", "~50MB", "β
Optimized")
|
122 |
with cols[2]:
|
123 |
+
st.metric("API Status", "Ready" if os.getenv("TOGETHER_API_KEY") else "Setup Needed", "π")
|
|
|
|