pentarosarium commited on
Commit
480a85a
·
1 Parent(s): 52498b7

3.70+ fix transl

Browse files
Files changed (1) hide show
  1. app.py +27 -16
app.py CHANGED
@@ -881,7 +881,7 @@ def process_file(uploaded_file, model_choice, translation_method=None):
881
  df = None
882
  processed_rows_df = pd.DataFrame()
883
  last_update_time = time.time()
884
-
885
  try:
886
  # Initialize UI and control systems
887
  ui = ProcessingUI()
@@ -994,33 +994,44 @@ def process_file(uploaded_file, model_choice, translation_method=None):
994
 
995
  # Handle negative sentiment
996
 
 
997
  if sentiment == "Negative":
998
  try:
999
- # Initialize Groq LLM if not already done
1000
- if 'groq_llm' not in locals():
1001
- groq_llm = ensure_groq_llm()
1002
-
 
 
1003
  impact, reasoning = estimate_impact(
1004
- groq_llm if groq_llm is not None else llm,
1005
- translated_text,
1006
- row['Объект']
1007
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
1008
 
1009
  except Exception as e:
1010
  impact = "Неопределенный эффект"
1011
  reasoning = "Error in impact estimation"
1012
  st.warning(f"Impact estimation error: {str(e)}")
1013
 
 
1014
  df.at[idx, 'Impact'] = impact
1015
  df.at[idx, 'Reasoning'] = reasoning
1016
-
1017
- # Show negative alert in real-time
1018
- #ui.show_negative(
1019
- # row['Объект'],
1020
- # row['Заголовок'],
1021
- # reasoning,
1022
- # impact
1023
- #)
1024
 
1025
  processed_rows_df = pd.concat([processed_rows_df, df.iloc[[idx]]], ignore_index=True)
1026
 
 
881
  df = None
882
  processed_rows_df = pd.DataFrame()
883
  last_update_time = time.time()
884
+
885
  try:
886
  # Initialize UI and control systems
887
  ui = ProcessingUI()
 
994
 
995
  # Handle negative sentiment
996
 
997
+ # Handle negative sentiment
998
  if sentiment == "Negative":
999
  try:
1000
+ # Validate translated text
1001
+ if translated_text and len(translated_text.strip()) > 0:
1002
+ # Initialize Groq LLM if not already done
1003
+ if 'groq_llm' not in locals():
1004
+ groq_llm = ensure_groq_llm()
1005
+
1006
  impact, reasoning = estimate_impact(
1007
+ groq_llm if groq_llm is not None else llm,
1008
+ translated_text,
1009
+ row['Объект']
1010
  )
1011
+ else:
1012
+ # Use original text if translation failed
1013
+ original_text = row['Выдержки из текста']
1014
+ if original_text and len(original_text.strip()) > 0:
1015
+ impact, reasoning = estimate_impact(
1016
+ groq_llm if groq_llm is not None else llm,
1017
+ original_text,
1018
+ row['Объект']
1019
+ )
1020
+ else:
1021
+ impact = "Неопределенный эффект"
1022
+ reasoning = "Текст новости отсутствует"
1023
+ st.warning(f"Empty news text for {row['Объект']}")
1024
 
1025
  except Exception as e:
1026
  impact = "Неопределенный эффект"
1027
  reasoning = "Error in impact estimation"
1028
  st.warning(f"Impact estimation error: {str(e)}")
1029
 
1030
+ # Store results
1031
  df.at[idx, 'Impact'] = impact
1032
  df.at[idx, 'Reasoning'] = reasoning
1033
+
1034
+
 
 
 
 
 
 
1035
 
1036
  processed_rows_df = pd.concat([processed_rows_df, df.iloc[[idx]]], ignore_index=True)
1037