aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/search_arxiv.sh15
-rwxr-xr-xtools/search_bing.sh20
-rwxr-xr-xtools/search_brave.sh21
-rwxr-xr-xtools/search_duckduckgo.sh5
-rwxr-xr-xtools/search_exa.sh31
-rwxr-xr-xtools/search_searxng.sh20
-rwxr-xr-xtools/search_tavily.sh18
-rwxr-xr-xtools/search_wolframalpha.sh16
8 files changed, 125 insertions, 21 deletions
diff --git a/tools/search_arxiv.sh b/tools/search_arxiv.sh
new file mode 100755
index 0000000..7372c4d
--- /dev/null
+++ b/tools/search_arxiv.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -e
+
+# @describe Search arXiv for a query and return the top papers.
+
+# @env ARXIV_MAX_RESULTS=5 The max results to return.
+# @option --query! The query to search for.
+
+main() {
+ encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
+ url="http://export.arxiv.org/api/query?search_query=all:$encoded_query&max_results=$ARXIV_MAX_RESULTS"
+ curl -fsSL "$url"
+}
+
+eval "$(argc --argc-eval "$0" "$@")"
diff --git a/tools/search_bing.sh b/tools/search_bing.sh
new file mode 100755
index 0000000..28a47dd
--- /dev/null
+++ b/tools/search_bing.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+set -e
+
+# @describe Perform a web search using Bing Web Search API to get up-to-date information or additional context.
+# Use this when you need current information or feel a search could provide a better answer.
+
+# @env BING_API_KEY! The api key
+# @env BING_MAX_RESULTS=5 The max results to return.
+# @option --query! The query to search for.
+
+main() {
+ encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
+ url="https://api.bing.microsoft.com/v7.0/search?q=$encoded_query&mkt=en-us&textdecorations=true&textformat=raw&count=$BING_MAX_RESULTS&offset=0"
+ curl -fsSL "$url" \
+ -H "Ocp-Apim-Subscription-Key: $BING_API_KEY" | \
+ jq '[.webPages.value[] | {name: .name, url: .url, snippet: .snippet}]'
+}
+
+eval "$(argc --argc-eval "$0" "$@")"
+
diff --git a/tools/search_brave.sh b/tools/search_brave.sh
new file mode 100755
index 0000000..553bfc7
--- /dev/null
+++ b/tools/search_brave.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+set -e
+
+# @describe Perform a web search using Brave Search API to get up-to-date information or additional context.
+# Use this when you need current information or feel a search could provide a better answer.
+
+# @env BRAVE_API_KEY! The api key
+# @env BRAVE_MAX_RESULTS=5 The max results to return.
+# @option --query! The query to search for.
+
+main() {
+ encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
+ url="https://api.search.brave.com/res/v1/web/search?q=$encoded_query&count=$BRAVE_MAX_RESULTS"
+ curl -fsSL "$url" \
+ -H "Accept: application/json" \
+ -H "X-Subscription-Token: $BRAVE_API_KEY" | \
+ jq '[.web.results[] | {title: .title, url: .url, description: .description}]'
+}
+
+eval "$(argc --argc-eval "$0" "$@")"
+
diff --git a/tools/search_duckduckgo.sh b/tools/search_duckduckgo.sh
index c5ab565..a04b1b0 100755
--- a/tools/search_duckduckgo.sh
+++ b/tools/search_duckduckgo.sh
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
set -e
-# @describe Takes in a query string and returns search result from DuckDuckGo.
-# Use it to answer user questions that require dates, facts, real-time information, or news.
-# This ensures accurate and up-to-date answers.
+# @describe Perform a web search using DuckDuckGo API to get up-to-date information or additional context.
+# Use this when you need current information or feel a search could provide a better answer.
# @meta require-tools ddgr
# @env DDG_MAX_RESULTS=5 The max results to return.
diff --git a/tools/search_exa.sh b/tools/search_exa.sh
new file mode 100755
index 0000000..33d4564
--- /dev/null
+++ b/tools/search_exa.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+set -e
+
+# @describe Perform a web search using Exa API to get up-to-date information or additional context.
+# Use this when you need current information or feel a search could provide a better answer.
+
+# @env EXA_API_KEY! The api key
+# @env EXA_MAX_RESULTS=5 The max results to return.
+# @option --query! The query to search for.
+
+main() {
+ curl -fsSL -X POST https://api.exa.ai/search \
+ -H "content-type: application/json" \
+ -H "x-api-key: $EXA_API_KEY" \
+ -d '
+{
+ "query": "'"$argc_query"'",
+ "numResults": '"$EXA_MAX_RESULTS"',
+ "type": "keyword",
+ "contents": {
+ "text": {
+ "maxCharacters": 200
+ }
+ }
+}' | \
+ jq '[.results[] | {title: .title, url: .url, text: .text}]'
+}
+
+eval "$(argc --argc-eval "$0" "$@")"
+
+
diff --git a/tools/search_searxng.sh b/tools/search_searxng.sh
new file mode 100755
index 0000000..34345ca
--- /dev/null
+++ b/tools/search_searxng.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+set -e
+
+# @describe Perform a web search using SearXNG API to get up-to-date information or additional context.
+# Use this when you need current information or feel a search could provide a better answer.
+
+# @env SEARXNG_API_BASE! The api url
+# @env SEARXNG_MAX_RESULTS=5 The max results to return.
+# @option --query! The query to search for.
+
+main() {
+ encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
+ url="$SEARXNG_API_BASE/search?q=$encoded_query&categories=general&language=en-US&format=json"
+ curl -fsSL "$url" | \
+ jq '[.results[:'"$SEARXNG_MAX_RESULTS"'] | .[] | {url: .url, title: .title, content: .content}]'
+
+}
+
+eval "$(argc --argc-eval "$0" "$@")"
+
diff --git a/tools/search_tavily.sh b/tools/search_tavily.sh
index 068615d..5e99aba 100755
--- a/tools/search_tavily.sh
+++ b/tools/search_tavily.sh
@@ -1,18 +1,24 @@
#!/usr/bin/env bash
set -e
-# @describe Perform a web search using Tavily API to get up-to-date information or additional context.
+# @describe Perform a web search using EXA API to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
-# @env TAVILY_API_KEY! The max results to return.
+# @env TAVILY_API_KEY! The api key
# @env TAVILY_MAX_RESULTS=5 The max results to return.
# @option --query! The query to search for.
main() {
- curl -fsSL -X POST \
- -H 'content-type: application/json' \
- -d '{"api_key":"'"$TAVILY_API_KEY"'","query":"'"$argc_query"'","search_depth":"advanced","max_results":"'"$TAVILY_MAX_RESULTS"'"}' \
- https://api.tavily.com/search
+ curl -fsSL -X POST https://api.tavily.com/search \
+ -H "content-type: application/json" \
+ -d '
+{
+ "api_key": "'"$TAVILY_API_KEY"'",
+ "query": "'"$argc_query"'",
+ "search_depth": "advanced",
+ "max_results": "'"$TAVILY_MAX_RESULTS"'"
+}' | \
+ jq '[.results[] | {title: .title, url: .url, content: .content}]'
}
eval "$(argc --argc-eval "$0" "$@")"
diff --git a/tools/search_wolframalpha.sh b/tools/search_wolframalpha.sh
index a2dfdc7..20488bf 100755
--- a/tools/search_wolframalpha.sh
+++ b/tools/search_wolframalpha.sh
@@ -3,22 +3,14 @@ set -e
# @describe Get an answer to a question using Wolfram Alpha. Input should the query in English.
# Use it to answer user questions that require computation, detailed facts, data analysis, or complex queries.
-# This ensures accurate and precise answers.
+# @env WOLFRAM_API_ID! The api id
# @option --query! The query to search for.
-# @env WOLFRAM_API_ID!
main() {
- local curl_args=(
- -sSf -G
- --data-urlencode "output=JSON"
- --data-urlencode "format=plaintext"
- --data-urlencode "input=$argc_query"
- --data-urlencode "appid=$WOLFRAM_API_ID"
- "https://api.wolframalpha.com/v2/query"
- )
- curl "${curl_args[@]}" | \
- jq -r '.queryresult.pods[] | select(.subpods[0].plaintext != "")'
+ encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
+ url="https://api.wolframalpha.com/v2/query?appid=$WOLFRAM_API_ID&input=$encoded_query&output=json&format=plaintext"
+ curl -fsSL "$url" | jq '[.queryresult | .pods[] | {title:.title, values:[.subpods[].plaintext | select(. != "")]}]'
}
eval "$(argc --argc-eval "$0" "$@")"