feat: api tool config section + agent refactor for more llm fields

This commit is contained in:
Siddhant Rai
2025-02-03 06:07:10 +05:30
parent 9319ec5bb2
commit a5b2eb3a28
13 changed files with 1048 additions and 250 deletions

View File

@@ -15,11 +15,16 @@ class APITool(Tool):
self.url = config.get("url", "")
self.method = config.get("method", "GET")
self.headers = config.get("headers", {"Content-Type": "application/json"})
self.query_params = config.get("query_params", {})
def execute_action(self, action_name, **kwargs):
return self._make_api_call(self.url, self.method, self.headers, kwargs)
return self._make_api_call(
self.url, self.method, self.headers, self.query_params, kwargs
)
def _make_api_call(self, url, method, headers, body):
def _make_api_call(self, url, method, headers, query_params, body):
if query_params:
url = f"{url}?{requests.compat.urlencode(query_params)}"
if isinstance(body, dict):
body = json.dumps(body)
try: