menikev commited on
Commit
6f35e0f
Β·
verified Β·
1 Parent(s): 8fecd6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -31
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("⚑ Fast Crypto Analyst")
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) # Add spacing
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 more detailed sentiment chart
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
- # Add 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 for faster analysis:**\n- Use full cryptocurrency names (e.g., 'bitcoin' not 'btc')\n- Ensure stable internet connection\n- Try again if the first attempt fails")
95
 
96
- # Setup instructions in sidebar
97
  with st.sidebar:
98
- st.header("βš™οΈ Setup Instructions")
99
- st.markdown("""
100
- **To enable fast analysis:**
101
 
102
- 1. Get Together AI API key from [together.ai](https://together.ai)
103
- 2. Create `.env` file:
104
- ```
105
- TOGETHER_API_KEY=your_key_here
106
- ```
107
- 3. Install dependencies:
108
- ```bash
109
- pip install together python-dotenv
110
- ```
111
 
112
- **Performance Improvements:**
113
- - ⚑ 10-50x faster inference
114
- - 🎯 Reduced token usage
115
- - πŸ“± Better mobile experience
116
- - πŸ’Ύ Smart caching
 
 
 
117
  """)
118
 
119
- # Performance tips
120
  st.markdown("---")
121
- st.markdown("### πŸš€ Performance Optimizations Applied")
122
- cols = st.columns(4)
123
  with cols[0]:
124
- st.metric("Model Loading", "0s", "↓ 30-60s saved")
125
  with cols[1]:
126
- st.metric("Inference Speed", "~2s", "↓ 10-20s saved")
127
  with cols[2]:
128
- st.metric("Memory Usage", "~50MB", "↓ 2-4GB saved")
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", "πŸ”„")