Skip to content

Commit 18915ba

Browse files
committed
add web_search_exa.sh
1 parent 703cedb commit 18915ba

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tools/web_search_exa.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# @describe Perform a web search using Exa API to get up-to-date information or additional context.
5+
# Use this when you need current information or feel a search could provide a better answer.
6+
# Construct the query out of keywords, not human sentences, sorted by relevance - just like a good Google query.
7+
# This returns text, then URL. Print that URL so that it's transparent where you got the info from.
8+
9+
# @option --query! The query to search for.
10+
11+
# @env EXA_API_KEY! The api key
12+
# @env LLM_OUTPUT=/dev/stdout The output path The output path
13+
14+
main() {
15+
curl -X POST 'https://api.exa.ai/search' \
16+
-H "x-api-key: $EXA_API_KEY" \
17+
-H 'Content-Type: application/json' \
18+
-d '{
19+
"query": "'"$argc_query"'",
20+
"text": true,
21+
"type": "keyword",
22+
"numResults": 1
23+
}' | \
24+
jq -r '.results[0] | (.text, .url)' >> "$LLM_OUTPUT"
25+
}
26+
27+
eval "$(argc --argc-eval "$0" "$@")"

0 commit comments

Comments
 (0)