Skip to content

Commit

Permalink
Add Exa tool to agentstack.
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethtrykin committed Nov 9, 2024
1 parent f83d464 commit c5e0579
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added agentstack/.DS_Store
Binary file not shown.
Binary file added agentstack/templates/.DS_Store
Binary file not shown.
Binary file added agentstack/templates/crewai/.DS_Store
Binary file not shown.
Binary file added agentstack/templates/crewai/tools/.DS_Store
Binary file not shown.
35 changes: 35 additions & 0 deletions agentstack/templates/crewai/tools/exa_tool.py
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 added agentstack/tools/.DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions agentstack/tools/exa.json
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"
}
9 changes: 9 additions & 0 deletions agentstack/tools/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"name": "firecrawl",
"url": "https://www.firecrawl.dev/"
}],
"sandboxing": [
{
"name":"e2b",
"url": "https://e2b.dev/"
}],
"storage": [{
"name": "mem0",
"url": "https://github.com/mem0ai/mem0"
Expand Down Expand Up @@ -38,5 +43,9 @@
"vision": [{
"name": "vision",
"url": "AgentStack core tool"
}],
"web-retrieval": [{
"name": "exa",
"url": "https://exa.ai"
}]
}

0 comments on commit c5e0579

Please sign in to comment.