Skip to content

Commit

Permalink
remove tungsten dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
gilcu3 committed May 16, 2024
1 parent 6cd14ca commit 712b116
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bin/wolframalpha
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
set -e

# @describe Get an answer to a question using Wolfram Alpha. Input should the the query in English.
# @meta require-tools tungsten
# 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() {
tungsten 2>/dev/null "$argc_query"
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" "$@")"

0 comments on commit 712b116

Please sign in to comment.