mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
cutting new verison with exa search tool
This commit is contained in:
@@ -5,24 +5,23 @@ from typing import Any
|
|||||||
from .exa_base_tool import EXABaseTool
|
from .exa_base_tool import EXABaseTool
|
||||||
|
|
||||||
class EXASearchTool(EXABaseTool):
|
class EXASearchTool(EXABaseTool):
|
||||||
def _run(
|
def _run(
|
||||||
self,
|
self,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
search_query = kwargs.get('search_query')
|
search_query = kwargs.get('search_query')
|
||||||
if search_query is None:
|
if search_query is None:
|
||||||
search_query = kwargs.get('query')
|
search_query = kwargs.get('query')
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"query": search_query,
|
"query": search_query,
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = self.headers.copy()
|
headers = self.headers.copy()
|
||||||
headers["x-api-key"] = os.environ['EXA_API_KEY']
|
headers["x-api-key"] = os.environ['EXA_API_KEY']
|
||||||
|
|
||||||
response = requests.post(self.search_url, json=payload, headers=headers)
|
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'])
|
||||||
else:
|
return results
|
||||||
return results
|
|
||||||
|
|||||||
Reference in New Issue
Block a user