Scott Cogan commited on
Commit ·
3427e8c
1
Parent(s): b82a7ed
debug
Browse files
app.py
CHANGED
|
@@ -194,7 +194,7 @@ class BasicAgent:
|
|
| 194 |
- Never make up information - if you can't find it, say so''')
|
| 195 |
|
| 196 |
# Create the graph
|
| 197 |
-
self.workflow = StateGraph(AgentState)
|
| 198 |
|
| 199 |
# Add nodes
|
| 200 |
self.workflow.add_node("agent", self.call_model)
|
|
@@ -246,11 +246,16 @@ class BasicAgent:
|
|
| 246 |
if "429" in error_str:
|
| 247 |
if "GenerateRequestsPerDayPerProjectPerModel-FreeTier" in error_str:
|
| 248 |
logger.warning("Daily quota limit reached, providing fallback response")
|
| 249 |
-
# For daily quota limits, provide a fallback response
|
| 250 |
-
return {
|
|
|
|
|
|
|
|
|
|
| 251 |
else:
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
| 254 |
raise # Re-raise to trigger retry
|
| 255 |
else:
|
| 256 |
raise
|
|
|
|
| 194 |
- Never make up information - if you can't find it, say so''')
|
| 195 |
|
| 196 |
# Create the graph
|
| 197 |
+
self.workflow = StateGraph(AgentState, config={"recursion_limit": 50})
|
| 198 |
|
| 199 |
# Add nodes
|
| 200 |
self.workflow.add_node("agent", self.call_model)
|
|
|
|
| 246 |
if "429" in error_str:
|
| 247 |
if "GenerateRequestsPerDayPerProjectPerModel-FreeTier" in error_str:
|
| 248 |
logger.warning("Daily quota limit reached, providing fallback response")
|
| 249 |
+
# For daily quota limits, provide a fallback response and end the conversation
|
| 250 |
+
return {
|
| 251 |
+
"messages": [AIMessage(content="I've reached my daily limit for processing requests. Please try again tomorrow or contact support for assistance.")],
|
| 252 |
+
"next": END
|
| 253 |
+
}
|
| 254 |
else:
|
| 255 |
+
# For other rate limits, wait and retry
|
| 256 |
+
wait_time = 60
|
| 257 |
+
logger.warning(f"Rate limit hit, waiting {wait_time} seconds before retry...")
|
| 258 |
+
time.sleep(wait_time)
|
| 259 |
raise # Re-raise to trigger retry
|
| 260 |
else:
|
| 261 |
raise
|