File size: 606 Bytes
d9b1770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from crewai_tools import BaseTool

from langchain_community.utilities.wolfram_alpha import WolframAlphaAPIWrapper

wolfram = WolframAlphaAPIWrapper()

class AskWolframAlpha(BaseTool):
    name: str = "AskWolframAlpha"
    description: str = "use WolframAlpha to analyze data"   

    def _run(self, question: str) -> str:
        "Ask Wolfram Alpha to do math, e.g : descriptive statistics {20.9,23.2,26.2,26.4}" 
        wolfram = WolframAlphaAPIWrapper()
        return wolfram.run(question)

# Test
# print(AskWolframAlpha()._run("descriptive statistics {20.9,23.2,26.2,26.4,20.9,23.2,26.2,26.4,20.9}"))