Soumik555 commited on
Commit
92b1ad1
·
1 Parent(s): 7a95386

Lets fix this

Browse files
Files changed (1) hide show
  1. controller.py +6 -4
controller.py CHANGED
@@ -213,7 +213,7 @@ def groq_chat(csv_url: str, question: str):
213
 
214
  except Exception as e:
215
  error_message = str(e)
216
- if "429" in error_message:
217
  logger.warning("Rate limit exceeded. Switching to next API key.")
218
  with current_groq_key_lock:
219
  current_groq_key_index += 1
@@ -266,7 +266,8 @@ def langchain_csv_chat(csv_url: str, question: str, chart_required: bool):
266
 
267
  except Exception as e:
268
  error_message = str(e)
269
- if "429" in error_message:
 
270
  with current_langchain_chart_lock:
271
  current_langchain_chart_key_index = (current_langchain_chart_key_index + 1) % len(groq_api_keys)
272
  logger.warning(f"Rate limit exceeded. Switching to next API key: {groq_api_keys[current_langchain_chart_key_index]}")
@@ -404,7 +405,8 @@ def groq_chart(csv_url: str, question: str):
404
 
405
  except Exception as e:
406
  error = str(e)
407
- if "429" in error:
 
408
  with current_groq_chart_lock:
409
  current_groq_chart_key_index = (current_groq_chart_key_index + 1) % len(groq_api_keys)
410
  else:
@@ -747,7 +749,7 @@ def langchain_csv_chart(csv_url: str, question: str, chart_required: bool):
747
 
748
  except Exception as e:
749
  error_message = str(e)
750
- if "429" in error_message:
751
  with current_langchain_chart_lock:
752
  current_langchain_chart_key_index = (current_langchain_chart_key_index + 1) % len(groq_api_keys)
753
  logger.warning(f"Rate limit exceeded. Switching to next API key: {groq_api_keys[current_langchain_chart_key_index]}")
 
213
 
214
  except Exception as e:
215
  error_message = str(e)
216
+ if error_message != "":
217
  logger.warning("Rate limit exceeded. Switching to next API key.")
218
  with current_groq_key_lock:
219
  current_groq_key_index += 1
 
266
 
267
  except Exception as e:
268
  error_message = str(e)
269
+ # if "429" in error_message:
270
+ if error_message != "":
271
  with current_langchain_chart_lock:
272
  current_langchain_chart_key_index = (current_langchain_chart_key_index + 1) % len(groq_api_keys)
273
  logger.warning(f"Rate limit exceeded. Switching to next API key: {groq_api_keys[current_langchain_chart_key_index]}")
 
405
 
406
  except Exception as e:
407
  error = str(e)
408
+ # if "429" in error:
409
+ if error != "":
410
  with current_groq_chart_lock:
411
  current_groq_chart_key_index = (current_groq_chart_key_index + 1) % len(groq_api_keys)
412
  else:
 
749
 
750
  except Exception as e:
751
  error_message = str(e)
752
+ if error_message != "":
753
  with current_langchain_chart_lock:
754
  current_langchain_chart_key_index = (current_langchain_chart_key_index + 1) % len(groq_api_keys)
755
  logger.warning(f"Rate limit exceeded. Switching to next API key: {groq_api_keys[current_langchain_chart_key_index]}")