Wolfram Alpha Tool for HuggingFace Agents
Demo Colab Notebook:
https://colab.research.google.com/drive/1wRv65uzfHO3WUJCo1tcRZgadq4XQ-o--
Usage instructions:
Create and save WolframAlpha APP_ID as an environment variable:
os.environ["WOLFRAM_APP_ID"] = "YOUR_WOLFRAM_APP_ID"
# Get it from: https://products.wolframalpha.com/simple-api/documentation
from transformers import load_tool
wolframalpha_tool = load_tool('LecJackS/wolfram-alpha-query')
Test it:
query = "Integrate [ log(x)^2 + e^(x^2) dx ]"
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)