File size: 1,568 Bytes
503290b
 
 
 
 
 
 
 
 
 
4bc81ea
 
 
79e56c9
4bc81ea
13758b1
 
4bc81ea
79e56c9
 
4bc81ea
 
 
 
79e56c9
 
 
4bc81ea
 
 
 
 
 
 
 
79e56c9
 
 
 
 
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
45
<!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>
              <a href="https://huggingface.co/spaces/LecJackS/wolfram-alpha-query/blob/main/wolfram-alpha-tool">https://huggingface.co/spaces/LecJackS/wolfram-alpha-query/blob/main/wolfram-alpha-tool</a>

              <h1>Usage instructions:</h1>
              <h3>Save WolframAlpha API key:</h3>
<code>	
CFG_appid = WOLFRAM_API_KEY<br>
  <a href="https://products.wolframalpha.com/simple-api/documentation">https://products.wolframalpha.com/simple-api/documentation</a>
</code>
  
<h3>Test it:</h3>
<code>	
              query = "Integrate [ log(x)^2 + e^(x^2) dx ]"<br>
wolframalpha_tool = WolframAlpha()<br>
print(wolframalpha_tool(query))<br>
</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")<br>
print(res)<br>
<br>
res = agent.run("Integrate log(x)^2 + e^(x^2) dx")<br>
print(res)<br>
</code>  
		</div>
	</body>
</html>