aboutsummaryrefslogtreecommitdiffstats
path: root/bin/search_wolframalpha
diff options
context:
space:
mode:
authorgilcu3 <828241+gilcu3@users.noreply.github.com>2024-05-16 16:19:30 +0200
committerGitHub <noreply@github.com>2024-05-16 22:19:30 +0800
commit1a24e820dd95e66a990c1bcbb21b045ed5355a9b (patch)
tree5dfffe96fab89c53f34bed0eac97d239cfcc51b9 /bin/search_wolframalpha
parent585a3544fb67f5ff81a4247d11eb0c3285a777f8 (diff)
downloadllm-functions-docker-1a24e820dd95e66a990c1bcbb21b045ed5355a9b.tar.gz
feat: add search_wolframalpha (#1)
* wolframalpha example * remove tungsten dependency * script rename * fix typo
Diffstat (limited to 'bin/search_wolframalpha')
-rwxr-xr-xbin/search_wolframalpha23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/search_wolframalpha b/bin/search_wolframalpha
new file mode 100755
index 0000000..6529ef0
--- /dev/null
+++ b/bin/search_wolframalpha
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+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.
+# @option --query! The query to search for.
+# @env WOLFRAM_API_KEY! The API key used to connect to WolframAlpha
+
+
+main() {
+ local curl_args=(
+ -sSf -G
+ --data-urlencode "output=JSON"
+ --data-urlencode "format=plaintext"
+ --data-urlencode "input=$argc_query"
+ --data-urlencode "appid=$WOLFRAM_API_KEY"
+ "https://api.wolframalpha.com/v2/query"
+ )
+ curl "${curl_args[@]}" | jq -r '.queryresult.pods[] | select(.subpods[0].plaintext != "") | .title, .subpods[0].plaintext'
+}
+
+eval "$(argc --argc-eval "$0" "$@")"