File size: 1,531 Bytes
503290b
 
 
 
 
 
 
 
 
 
d026e26
f4fedaa
 
 
6d7aff4
973787d
4bc81ea
f4fedaa
 
 
a47fb02
4bc81ea
6d7aff4
973787d
4bc81ea
f4fedaa
79e56c9
4bc81ea
6d7aff4
973787d
f4fedaa
a47fb02
f4fedaa
6d7aff4
973787d
4bc81ea
f4fedaa
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
46
<!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">
			<h3>Wolfram Alpha Tool for HuggingFace Agents</h3>
            <h2>Demo Colab Notebook:</h2>
          
          <a href="https://colab.research.google.com/drive/1wRv65uzfHO3WUJCo1tcRZgadq4XQ-o--">https://colab.research.google.com/drive/1wRv65uzfHO3WUJCo1tcRZgadq4XQ-o--</a><br>
              <h3>Usage instructions:</h3>
              <h1>Create and save WolframAlpha APP_ID as an environment variable:</h1>
<code>	
os.environ["WOLFRAM_APP_ID"] = "YOUR_WOLFRAM_APP_ID"<br>
# Get it from: <a href="https://products.wolframalpha.com/simple-api/documentation">https://products.wolframalpha.com/simple-api/documentation</a><br>
from transformers import load_tool<br>
wolframalpha_tool = load_tool('LecJackS/wolfram-alpha-query')<br>
</code>
<br>
<h1>Test it:</h1>
<code>	
query = "Integrate [ log(x)^2 + e^(x^2) dx ]"<br>
print(wolframalpha_tool(query))<br>
</code>
<br>
<h1>Add tool to agent:</h1>
<code>	
agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[wolframalpha_tool])<br>
</code>
<br>
<h1>Ask the agent to solve some math:</h1>
<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>