Almaatla commited on
Commit
d32c258
1 Parent(s): abb77ac

added a global unhandled error when ask_llm failed

Browse files
Files changed (1) hide show
  1. excel_chat.py +6 -1
excel_chat.py CHANGED
@@ -223,7 +223,12 @@ def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col
223
  for index, row in filtred_df.iterrows():
224
  concatenated_content = "\n\n".join(f"{column_name}: {str(row[column_name])}" for column_name in source_cols)
225
  if not concatenated_content == "\n\n".join(f"{column_name}: nan" for column_name in source_cols):
226
- llm_answer,gloabal_keys = ask_llm(prompt[0], concatenated_content, client, user, gloabal_keys)
 
 
 
 
 
227
  print(f"{cpt}/{len(filtred_df)}\nQUERY:\n{prompt[0]}\nCONTENT:\n{concatenated_content[:200]}...\n\nANSWER:\n{llm_answer}")
228
  df.at[index, dest_col] = llm_answer
229
  cpt += 1
 
223
  for index, row in filtred_df.iterrows():
224
  concatenated_content = "\n\n".join(f"{column_name}: {str(row[column_name])}" for column_name in source_cols)
225
  if not concatenated_content == "\n\n".join(f"{column_name}: nan" for column_name in source_cols):
226
+
227
+ try:
228
+ llm_answer,gloabal_keys = ask_llm(prompt[0], concatenated_content, client, user, gloabal_keys)
229
+ except error:
230
+ llm_answer = "unhandled global error"
231
+
232
  print(f"{cpt}/{len(filtred_df)}\nQUERY:\n{prompt[0]}\nCONTENT:\n{concatenated_content[:200]}...\n\nANSWER:\n{llm_answer}")
233
  df.at[index, dest_col] = llm_answer
234
  cpt += 1