SergeyO7 commited on
Commit
30e81de
·
verified ·
1 Parent(s): 587d13c

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +11 -0
agent.py CHANGED
@@ -74,6 +74,12 @@ class ChessboardToFENOnlineTool(Tool):
74
  except Exception as e:
75
  return f"API Call Failed: {str(e)}"
76
 
 
 
 
 
 
 
77
  class VisitWebpageTool(Tool):
78
  name = "visit_webpage"
79
  description = "Visits a webpage at the given url and reads its content as a markdown string. Use this to browse webpages."
@@ -190,6 +196,11 @@ class RetryDuckDuckGoSearchTool(DuckDuckGoSearchTool):
190
  def forward(self, query: str) -> str:
191
  return super().forward(query)
192
 
 
 
 
 
 
193
  class MagAgent:
194
  def __init__(self, rate_limiter: Optional[Limiter] = None):
195
  """Initialize the MagAgent with search tools."""
 
74
  except Exception as e:
75
  return f"API Call Failed: {str(e)}"
76
 
77
+ from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception
78
+ import requests
79
+
80
+ def is_429_error(exception):
81
+ return isinstance(exception, requests.exceptions.HTTPError) and exception.response.status_code == 429
82
+
83
  class VisitWebpageTool(Tool):
84
  name = "visit_webpage"
85
  description = "Visits a webpage at the given url and reads its content as a markdown string. Use this to browse webpages."
 
196
  def forward(self, query: str) -> str:
197
  return super().forward(query)
198
 
199
+
200
+ ##############################
201
+ # MAG Agent
202
+ ##############################
203
+
204
  class MagAgent:
205
  def __init__(self, rate_limiter: Optional[Limiter] = None):
206
  """Initialize the MagAgent with search tools."""