Wolfram Alpha Tool for HuggingFace Agents

Not sure how to set this manually (push_to_hub does not seem to work for tool classes) so:

Copy the contents of:

https://huggingface.co/spaces/LecJackS/wolfram-alpha-query/blob/main/wolfram-alpha-tool

Usage:

CFG_appid= # https://products.wolframalpha.com/simple-api/documentation

Test it:

query = "Integrate [ log(x)^2 + e^(x^2) dx ]" wolframalpha_tool = WolframAlpha() print(wolframalpha_tool(query))

Add tool to agent:

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[wolframalpha_tool])

Ask the agent to solve some math:

res = agent.run("Solve the following equation: Area of circle of radius 2") print(res) res = agent.run("Integrate log(x)^2 + e^(x^2) dx") print(res)