ajaykumar0712 commited on
Commit
f5237b3
·
verified ·
1 Parent(s): 92432ee

Applying try except safety block for rate limit error

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +13 -1
src/streamlit_app.py CHANGED
@@ -61,9 +61,21 @@ with left:
61
 
62
  teamA = words[0]
63
  teamB = words[2]
 
 
64
  # with st.spinner("Consulting the AI panel..."):
65
 
66
- agent_outputs = run_agents("match", teamA, teamB)
 
 
 
 
 
 
 
 
 
 
67
  stats_output = agent_outputs["stats"]
68
  strategist_output = agent_outputs["strategist"]
69
  chaos_output = agent_outputs["chaos"]
 
61
 
62
  teamA = words[0]
63
  teamB = words[2]
64
+
65
+ # Create impression of thinking and a spinning icon
66
  # with st.spinner("Consulting the AI panel..."):
67
 
68
+ # Safety net to check rate limit error
69
+
70
+ try:
71
+ agent_outputs = run_agents("match", teamA, teamB)
72
+ except Exception as e:
73
+ if "RateLimit" in str(e):
74
+ st.warning("Rate limit hit. Retrying in 12 seconds...")
75
+ time.sleep(12)
76
+ agent_outputs = run_agents("match", teamA, teamB)
77
+ else:
78
+ raise e
79
  stats_output = agent_outputs["stats"]
80
  strategist_output = agent_outputs["strategist"]
81
  chaos_output = agent_outputs["chaos"]