Spaces:
Sleeping
Sleeping
Commit
·
31e7b1f
1
Parent(s):
7b3ce5a
v.1.35
Browse files
app.py
CHANGED
@@ -645,7 +645,7 @@ def create_interface():
|
|
645 |
control = ProcessControl()
|
646 |
|
647 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
648 |
-
gr.Markdown("# AI-анализ мониторинга новостей v.1.
|
649 |
|
650 |
with gr.Row():
|
651 |
file_input = gr.File(
|
@@ -708,7 +708,7 @@ def create_interface():
|
|
708 |
def analyze(file_bytes):
|
709 |
if file_bytes is None:
|
710 |
gr.Warning("Пожалуйста, загрузите файл")
|
711 |
-
return None, None, None, False, None, "Ожидание файла...", ""
|
712 |
|
713 |
try:
|
714 |
# Reset stop flag
|
@@ -737,14 +737,13 @@ def create_interface():
|
|
737 |
result_df = pd.DataFrame(processed_rows)
|
738 |
output_bytes_io = create_output_file(result_df, file_obj)
|
739 |
if output_bytes_io:
|
740 |
-
output_bytes = output_bytes_io.getvalue() # Convert BytesIO to bytes
|
741 |
fig_sentiment, fig_events = create_visualizations(result_df)
|
742 |
return (
|
743 |
result_df,
|
744 |
fig_sentiment,
|
745 |
fig_events,
|
746 |
True,
|
747 |
-
|
748 |
f"Обработка остановлена. Обработано {len(processed_rows)}/{total} строк",
|
749 |
dedup_message
|
750 |
)
|
@@ -785,14 +784,13 @@ def create_interface():
|
|
785 |
result_df = pd.DataFrame(processed_rows)
|
786 |
output_bytes_io = create_output_file(result_df, file_obj)
|
787 |
if output_bytes_io:
|
788 |
-
output_bytes = output_bytes_io.getvalue() # Convert BytesIO to bytes
|
789 |
fig_sentiment, fig_events = create_visualizations(result_df)
|
790 |
yield (
|
791 |
result_df,
|
792 |
fig_sentiment,
|
793 |
fig_events,
|
794 |
True,
|
795 |
-
|
796 |
f"Обработано {len(processed_rows)}/{total} строк",
|
797 |
dedup_message
|
798 |
)
|
@@ -806,25 +804,24 @@ def create_interface():
|
|
806 |
final_df = pd.DataFrame(processed_rows)
|
807 |
output_bytes_io = create_output_file(final_df, file_obj)
|
808 |
if output_bytes_io:
|
809 |
-
output_bytes = output_bytes_io.getvalue() # Convert BytesIO to bytes
|
810 |
fig_sentiment, fig_events = create_visualizations(final_df)
|
811 |
return (
|
812 |
final_df,
|
813 |
fig_sentiment,
|
814 |
fig_events,
|
815 |
True,
|
816 |
-
|
817 |
"Обработка завершена!",
|
818 |
dedup_message
|
819 |
)
|
820 |
else:
|
821 |
-
return None, None, None, False, None, "Нет обработанных данных", ""
|
822 |
|
823 |
except Exception as e:
|
824 |
error_msg = f"Ошибка анализа: {str(e)}"
|
825 |
logger.error(error_msg)
|
826 |
gr.Error(error_msg)
|
827 |
-
return None, None, None, False, None, error_msg, ""
|
828 |
finally:
|
829 |
if detector:
|
830 |
detector.cleanup()
|
|
|
645 |
control = ProcessControl()
|
646 |
|
647 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
648 |
+
gr.Markdown("# AI-анализ мониторинга новостей v.1.35")
|
649 |
|
650 |
with gr.Row():
|
651 |
file_input = gr.File(
|
|
|
708 |
def analyze(file_bytes):
|
709 |
if file_bytes is None:
|
710 |
gr.Warning("Пожалуйста, загрузите файл")
|
711 |
+
return None, None, None, False, (None, None), "Ожидание файла...", ""
|
712 |
|
713 |
try:
|
714 |
# Reset stop flag
|
|
|
737 |
result_df = pd.DataFrame(processed_rows)
|
738 |
output_bytes_io = create_output_file(result_df, file_obj)
|
739 |
if output_bytes_io:
|
|
|
740 |
fig_sentiment, fig_events = create_visualizations(result_df)
|
741 |
return (
|
742 |
result_df,
|
743 |
fig_sentiment,
|
744 |
fig_events,
|
745 |
True,
|
746 |
+
("partial_results.xlsx", output_bytes_io.getvalue()), # Return tuple of (name, bytes)
|
747 |
f"Обработка остановлена. Обработано {len(processed_rows)}/{total} строк",
|
748 |
dedup_message
|
749 |
)
|
|
|
784 |
result_df = pd.DataFrame(processed_rows)
|
785 |
output_bytes_io = create_output_file(result_df, file_obj)
|
786 |
if output_bytes_io:
|
|
|
787 |
fig_sentiment, fig_events = create_visualizations(result_df)
|
788 |
yield (
|
789 |
result_df,
|
790 |
fig_sentiment,
|
791 |
fig_events,
|
792 |
True,
|
793 |
+
(f"results_{len(processed_rows)}_rows.xlsx", output_bytes_io.getvalue()), # Return tuple of (name, bytes)
|
794 |
f"Обработано {len(processed_rows)}/{total} строк",
|
795 |
dedup_message
|
796 |
)
|
|
|
804 |
final_df = pd.DataFrame(processed_rows)
|
805 |
output_bytes_io = create_output_file(final_df, file_obj)
|
806 |
if output_bytes_io:
|
|
|
807 |
fig_sentiment, fig_events = create_visualizations(final_df)
|
808 |
return (
|
809 |
final_df,
|
810 |
fig_sentiment,
|
811 |
fig_events,
|
812 |
True,
|
813 |
+
("результаты_анализа.xlsx", output_bytes_io.getvalue()), # Return tuple of (name, bytes)
|
814 |
"Обработка завершена!",
|
815 |
dedup_message
|
816 |
)
|
817 |
else:
|
818 |
+
return None, None, None, False, (None, None), "Нет обработанных данных", ""
|
819 |
|
820 |
except Exception as e:
|
821 |
error_msg = f"Ошибка анализа: {str(e)}"
|
822 |
logger.error(error_msg)
|
823 |
gr.Error(error_msg)
|
824 |
+
return None, None, None, False, (None, None), error_msg, ""
|
825 |
finally:
|
826 |
if detector:
|
827 |
detector.cleanup()
|