Vycka12 commited on
Commit
da3fca1
·
verified ·
1 Parent(s): 03786c1

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -77,11 +77,9 @@ class HumanFriendlyAnalyzer:
77
  time.sleep(300)
78
 
79
  def create_gauge(self):
80
- """Sukuria vizualų 'spidometrą' bendrai nuotaikai."""
81
  total = stats["bullish"] + stats["bearish"] + stats["neutral"]
82
  if total == 0: return go.Figure()
83
 
84
- # Apskaičiuojame poziciją: (pos - neg) / total, sugraduota nuo 0 iki 100
85
  score = ((stats["bullish"] - stats["bearish"]) / (stats["bullish"] + stats["bearish"] + 0.001)) * 50 + 50
86
 
87
  fig = go.Figure(go.Indicator(
@@ -92,9 +90,9 @@ class HumanFriendlyAnalyzer:
92
  'axis': {'range': [0, 100]},
93
  'bar': {'color': "black"},
94
  'steps': [
95
- {'range': [0, 40], 'color': "#ff4b4b"}, # Raudona (Baimė)
96
- {'range': [40, 60], 'color': "#ffffb2"}, # Geltona (Neutralu)
97
- {'range': [60, 100], 'color': "#00cc96"} # Žalia (Gera nuotaika)
98
  ],
99
  }
100
  ))
@@ -103,28 +101,26 @@ class HumanFriendlyAnalyzer:
103
 
104
  analyzer = HumanFriendlyAnalyzer()
105
 
106
- # --- SĄSAJA ---
107
  def update_ui():
108
- return analyzer.create_gauge(), pd.DataFrame(news_buffer), f"✅ Analizė baigta. Rasta: {stats['bullish']} geros, {stats['bearish']} blogos žinios."
 
109
 
110
  if __name__ == "__main__":
111
  threading.Thread(target=analyzer.analyze_all, daemon=True).start()
112
 
113
  with gr.Blocks(title="Sentiment AI - Žmonių kalba", theme=gr.themes.Soft()) as demo:
114
  gr.Markdown("# 🧠 Crypto Sentimentų Vertėjas")
115
- gr.Markdown("Šis AI perskaito visas svarbiausias pasaulio naujienas ir pasako, ar jos geros kainai, ar blogos.")
116
 
117
  with gr.Row():
118
  with gr.Column(scale=1):
119
  gauge_plot = gr.Plot(label="Nuotaikos Matuoklis")
120
  with gr.Column(scale=1):
121
- status_info = gr.Markdown("### 📊 Statistika šiuo metu
122
- Laukiama duomenų...")
123
 
124
  gr.Markdown("### 📰 Ką tik perskaitytos naujienos:")
125
  news_table = gr.Dataframe(interactive=False)
126
 
127
- # Automatinis atnaujinimas
128
  demo.load(update_ui, outputs=[gauge_plot, news_table, status_info])
129
  gr.Timer(10).tick(update_ui, outputs=[gauge_plot, news_table, status_info])
130
 
 
77
  time.sleep(300)
78
 
79
  def create_gauge(self):
 
80
  total = stats["bullish"] + stats["bearish"] + stats["neutral"]
81
  if total == 0: return go.Figure()
82
 
 
83
  score = ((stats["bullish"] - stats["bearish"]) / (stats["bullish"] + stats["bearish"] + 0.001)) * 50 + 50
84
 
85
  fig = go.Figure(go.Indicator(
 
90
  'axis': {'range': [0, 100]},
91
  'bar': {'color': "black"},
92
  'steps': [
93
+ {'range': [0, 40], 'color': "#ff4b4b"},
94
+ {'range': [40, 60], 'color': "#ffffb2"},
95
+ {'range': [60, 100], 'color': "#00cc96"}
96
  ],
97
  }
98
  ))
 
101
 
102
  analyzer = HumanFriendlyAnalyzer()
103
 
 
104
  def update_ui():
105
+ info_text = f"### 📊 Statistika šiuo metu\nAnalizė baigta. Rasta: {stats['bullish']} geros, {stats['bearish']} blogos žinios."
106
+ return analyzer.create_gauge(), pd.DataFrame(news_buffer), info_text
107
 
108
  if __name__ == "__main__":
109
  threading.Thread(target=analyzer.analyze_all, daemon=True).start()
110
 
111
  with gr.Blocks(title="Sentiment AI - Žmonių kalba", theme=gr.themes.Soft()) as demo:
112
  gr.Markdown("# 🧠 Crypto Sentimentų Vertėjas")
113
+ gr.Markdown("Šis AI perskaito visas svarbiausias pasaulio naujienos ir pasako, ar jos geros kainai, ar blogos.")
114
 
115
  with gr.Row():
116
  with gr.Column(scale=1):
117
  gauge_plot = gr.Plot(label="Nuotaikos Matuoklis")
118
  with gr.Column(scale=1):
119
+ status_info = gr.Markdown("### 📊 Statistika šiuo metu\nLaukiama duomenų...")
 
120
 
121
  gr.Markdown("### 📰 Ką tik perskaitytos naujienos:")
122
  news_table = gr.Dataframe(interactive=False)
123
 
 
124
  demo.load(update_ui, outputs=[gauge_plot, news_table, status_info])
125
  gr.Timer(10).tick(update_ui, outputs=[gauge_plot, news_table, status_info])
126