File size: 1,283 Bytes
503290b
 
 
 
 
 
 
 
 
 
4bc81ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503290b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width" />
		<title>My static Space</title>
		<link rel="stylesheet" href="style.css" />
	</head>
	<body>
		<div class="card">
			<h1>Wolfram Alpha Tool for HuggingFace Agents</h1>
            <p>Not sure how to set this manually (push_to_hub does not seem to work for tool classes) so:</p>
            <p> Copy the contents of:<p>
			https://huggingface.co/spaces/LecJackS/wolfram-alpha-query/blob/main/wolfram-alpha-tool

              <h1>Usage:</h1>
<code>	
CFG_appid=<WOLFRAM API KEY>
# https://products.wolframalpha.com/simple-api/documentation
</code>
  
<h3>Test it:</h3>
<code>	
              query = "Integrate [ log(x)^2 + e^(x^2) dx ]"
wolframalpha_tool = WolframAlpha()
print(wolframalpha_tool(query))
</code>
              
<h3>Add tool to agent:</h3>
              <code>	
agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[wolframalpha_tool])
              </code>
<h3>Ask the agent to solve some math:</h3>
<code>	
              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)
</code>  
		</div>
	</body>
</html>