moving EXA env dependency to tool execution

This commit is contained in:
João Moura
2024-05-02 04:12:45 -03:00
parent cf6231384c
commit 59d9d9eb1f
2 changed files with 5 additions and 2 deletions

View File

@@ -16,7 +16,6 @@ class EXABaseTool(BaseTool):
headers: dict = { headers: dict = {
"accept": "application/json", "accept": "application/json",
"content-type": "application/json", "content-type": "application/json",
"x-api-key": os.environ['EXA_API_KEY'],
} }
def _parse_results(self, results): def _parse_results(self, results):

View File

@@ -1,3 +1,4 @@
import os
import requests import requests
from typing import Any from typing import Any
@@ -16,7 +17,10 @@ class EXASearchTool(EXABaseTool):
"query": search_query, "query": search_query,
} }
response = requests.post(self.search_url, json=payload, headers=self.headers) headers = self.headers.copy()
headers["x-api-key"] = os.environ['EXA_API_KEY']
response = requests.post(self.search_url, json=payload, headers=headers)
results = response.json() results = response.json()
if 'results' in results: if 'results' in results:
results = super()._parse_results(results['results']) results = super()._parse_results(results['results'])