-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wolframalpha example #1
Conversation
Wolfram Alpha already provides API, why do you need a third-party tool? Moreover, this tool has not been updated for a long time and does not have many stars. I haven't used Wolfram Alpha, but I asked it in gpt? Here is the reply: #!/usr/bin/env bash
set -e
# @describe Takes in a query string and returns search results from Wolfram Alpha.
# 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.
main() {
local query="${argc_args[--query]}"
local appid=$(cat ~/.wolfram_appid 2>/dev/null)
if [[ -z "${appid}" ]]; then
echo "Error: Wolfram Alpha App ID not found."
echo "Please create a file named '.wolfram_appid' in your home directory and paste your App ID into it."
exit 1
fi
local url="http://api.wolframalpha.com/v2/query?input=${query// /%20}&appid=${appid}&output=json"
curl -s "${url}" | jq -r '.queryresult.pods[].subpods[].plaintext'
}
eval "$(argc --argc-eval "$0" "$@")" I feel like it can be used with a little modification. @gilcu3 Note: argc have llm-functions/bin/search_duckduckgo Lines 9 to 18 in 7a31090
|
Agree that probably this does not require external tools. The problem is that handling all cases could get much more complicated than what you show, and our script would basically reproduce what |
Just pushed another version with your suggestions. We lost a few features like colorized output, or the possibility of using it without an API key. Feel free to modify further to your liking, I think that will be way more efficient now that we have a base script. |
The function name should always be in the format |
bin/search_wolframalpha
Outdated
#!/usr/bin/env bash | ||
set -e | ||
|
||
# @describe Get an answer to a question using Wolfram Alpha. Input should the the query in English. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input should the the query in English.
Why did you specifically point it out? Is it really only possible to use English?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is the case, WolframAlpha natural language processing features are minimal as far I know.
PS: although the website now lists English, Spanish and Japanese
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best not to limit. Each words occupies tokens.
If users use other languages and feel that the effect is not good, they will not use it, and there is no need to point it out here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those lines there actually make it useful for people using other languages. They are supposed to make the AI translate the query before passing it to WolframAlpha. I think a few words is a good price to pay for better accessibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of this sentence is that search_wolframalpha
only supports English. If you input other languages, it cannot be processed. Bye bye.
This does not tell LLM to translate into English.
Remove this sentence here, add more comments on --query
-- # @option --query! The query to search for.
++ # @option --query! The query to search for. Preferably in English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, I am misunderstanding something then. What exactly is the input on the LLM when using functions? I thought it was the @describe
text, not the @option
text.
PS: I just tested my intuition and it seems to be correct. The LLM (at least the latest gpt-4o) translated a query in hungarian tényező a szám 12141124125125125
into
> call search_wolframalpha --query 'factor the number 12141124125125125' Yes
.
Inputting the hungarian directly to WolframAlpha (website) gives nonsensical results.
Without that sentence therefore the AI may not translate anything and miss results.
PS2: Thinking about it more carefully, maybe the @describe
field is used in 2 contexts, and those two are hard to conflate. It is what the user sees when figuring out what a function does, but it is also what the AI sees when trying to do the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you've tested it, I'll defer to your judgment. Go ahead and fix the grammar, and I'm ready to merge.
-- Input should the the query in English.
++ Input should be the query in English.
Added script to use
wolframalpha
as a function call. It depends on tungsten, which is a simple bash script that can query the engine.By default, I am redirecting err to
/dev/null
astungsten
may output warnings (such as not using API_KEY), but still return the expected response.Tested with:
.role %functions% factor 12442515125122111
PS: as discussed in sigoden/aichat#507 (comment)