Yermek68 commited on
Commit
fe95bf3
·
verified ·
1 Parent(s): a1a5c33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -8,7 +8,7 @@ import asyncio
8
  import re
9
 
10
  # ======================================================
11
- # 🚀 Eroha Summarizer PRO+++ v2.0 (by Yermek68)
12
  # ======================================================
13
 
14
  # Кэш пайплайнов
@@ -104,7 +104,6 @@ async def summarize_text(text: str):
104
  emo_label = emotions[0]["label"]
105
  emo_score = emotions[0].get("score", 0)
106
 
107
- # Маппинг эмоций
108
  emo_map = {
109
  "joy": "😊 Радость",
110
  "sadness": "😢 Грусть",
@@ -116,16 +115,13 @@ async def summarize_text(text: str):
116
  }
117
  emotion = emo_map.get(emo_label.lower(), "😐 Нейтральное")
118
 
119
- # Определение темы и жанра
120
  topic = detect_topic(text)
121
  genre = detect_genre(text)
122
 
123
- # Цветовое оформление
124
- color = "green" if "Радость" in emotion else "red" if "Гнев" in emotion or "Грусть" in emotion else "orange"
125
 
126
- # Форматированный вывод
127
- output = f"""
128
- # 🧠 <span style='color:#0073e6'>Eroha Summarizer PRO+++ v2.0</span>
129
  _(Автоязык: {'Русский' if lang == 'ru' else 'Английский'})_
130
 
131
  ---
@@ -148,13 +144,13 @@ _(Автоязык: {'Русский' if lang == 'ru' else 'Английский
148
 
149
  *Eroha Intelligence Suite — Multilingual AI summarizer powered by Hugging Face*
150
  """
151
- return output.strip()
152
 
153
  # =====================================================
154
  # 🌐 FastAPI backend
155
  # =====================================================
156
 
157
- app = FastAPI(title="Eroha Summarizer PRO+++ v2.0", version="2.0")
158
  app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
159
 
160
  @app.post("/api/full")
@@ -171,19 +167,27 @@ async def api_lite(data: dict):
171
  return {"tldr": clean_result[:300]}
172
 
173
  # =====================================================
174
- # 🎨 Gradio интерфейс
175
  # =====================================================
176
 
177
  def gradio_summary(text):
178
  return asyncio.run(summarize_text(text))
179
 
180
- iface = gr.Interface(
181
- fn=gradio_summary,
182
- inputs=gr.Textbox(lines=10, label="Введите текст для анализа и суммаризации"),
183
- outputs=gr.Markdown(label="Результат"),
184
- title="Eroha Summarizer PRO+++ v2.0",
185
- description="AI-инструмент нового поколения для анализа, определения языка, темы, эмоций и настроения текста (рус/англ/нем/исп/фр)."
186
- )
 
 
 
 
 
 
 
 
187
 
188
  if __name__ == "__main__":
189
  iface.launch(server_name="0.0.0.0", server_port=7860)
 
8
  import re
9
 
10
  # ======================================================
11
+ # 🚀 Eroha Summarizer PRO++++ v2.1 (by Yermek68)
12
  # ======================================================
13
 
14
  # Кэш пайплайнов
 
104
  emo_label = emotions[0]["label"]
105
  emo_score = emotions[0].get("score", 0)
106
 
 
107
  emo_map = {
108
  "joy": "😊 Радость",
109
  "sadness": "😢 Грусть",
 
115
  }
116
  emotion = emo_map.get(emo_label.lower(), "😐 Нейтральное")
117
 
 
118
  topic = detect_topic(text)
119
  genre = detect_genre(text)
120
 
121
+ color = "green" if "Радость" in emotion else "red" if "Грусть" in emotion or "Гнев" in emotion else "orange"
 
122
 
123
+ formatted_output = f"""
124
+ # 🧠 <span style='color:#0073e6'>Eroha Summarizer PRO++++ v2.1</span>
 
125
  _(Автоязык: {'Русский' if lang == 'ru' else 'Английский'})_
126
 
127
  ---
 
144
 
145
  *Eroha Intelligence Suite — Multilingual AI summarizer powered by Hugging Face*
146
  """
147
+ return formatted_output.strip()
148
 
149
  # =====================================================
150
  # 🌐 FastAPI backend
151
  # =====================================================
152
 
153
+ app = FastAPI(title="Eroha Summarizer PRO++++ v2.1", version="2.1")
154
  app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
155
 
156
  @app.post("/api/full")
 
167
  return {"tldr": clean_result[:300]}
168
 
169
  # =====================================================
170
+ # 🎨 Gradio интерфейс с кнопками
171
  # =====================================================
172
 
173
  def gradio_summary(text):
174
  return asyncio.run(summarize_text(text))
175
 
176
+ with gr.Blocks(title="Eroha Summarizer PRO++++ v2.1") as iface:
177
+ gr.Markdown("## 🧠 Eroha Summarizer PRO++++ v2.1\nAI-инструмент нового поколения для анализа, темы, эмоций и автоопределения языка (рус/англ/нем/исп/фр).")
178
+
179
+ text_input = gr.Textbox(lines=10, label="Введите текст для анализа и суммаризации")
180
+ result_output = gr.Markdown(label="Результат")
181
+
182
+ with gr.Row():
183
+ copy_btn = gr.Button("📋 Копировать")
184
+ download_btn = gr.Button("💾 Скачать результат")
185
+
186
+ text_input.submit(gradio_summary, inputs=text_input, outputs=result_output)
187
+ copy_btn.click(lambda x: x, inputs=result_output, outputs=None)
188
+ download_btn.click(lambda x: gr.File.update(value=x.encode("utf-8"), visible=True), inputs=result_output, outputs=None)
189
+
190
+ gr.Markdown("---\n✨ _Eroha Intelligence Suite © 2025 — by Yermek68_")
191
 
192
  if __name__ == "__main__":
193
  iface.launch(server_name="0.0.0.0", server_port=7860)