-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f83d464
commit c5e0579
Showing
9 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from crewai_tools import tool | ||
from exa_py import Exa | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
# Check out our docs for more info! https://docs.exa.ai/ | ||
@tool("Exa search and get contents") | ||
def search_and_contents(question: str) -> str: | ||
""" | ||
Tool using Exa's Python SDK to run semantic search and return result highlights. | ||
Args: | ||
question: The search query or question to find information about | ||
Returns: | ||
Formatted string containing titles, URLs, and highlights from the search results | ||
""" | ||
exa = Exa(api_key=os.getenv('EXA_API_KEY')) | ||
|
||
response = exa.search_and_contents( | ||
question, | ||
type="neural", | ||
use_autoprompt=True, | ||
num_results=3, | ||
highlights=True | ||
) | ||
|
||
parsedResult = ''.join([ | ||
f'<Title id={idx}>{eachResult.title}</Title>' | ||
f'<URL id={idx}>{eachResult.url}</URL>' | ||
f'<Highlight id={idx}>{"".join(eachResult.highlights)}</Highlight>' | ||
for (idx, eachResult) in enumerate(response.results) | ||
]) | ||
|
||
return parsedResult |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "exa", | ||
"package": "poetry add exa_py", | ||
"env": "EXA_API_KEY=...", | ||
"tools": ["search_and_contents"], | ||
"cta": "Get your Exa API key at https://dashboard.exa.ai/api-keys" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters