Run query through WolframAlpha and parse result.
(self, query: str)
| 94 | super().__init__() |
| 95 | |
| 96 | def run(self, query: str) -> str: |
| 97 | """Run query through WolframAlpha and parse result.""" |
| 98 | res = self.wolfram_client.query(query) |
| 99 | |
| 100 | try: |
| 101 | answer = next(res.results).text |
| 102 | except StopIteration: |
| 103 | return "Wolfram Alpha wasn't able to answer it" |
| 104 | |
| 105 | if answer is None or answer == "": |
| 106 | return "No good Wolfram Alpha Result was found" |
| 107 | else: |
| 108 | return f"Answer: {answer}" |
| 109 | |
| 110 | |
| 111 | class WolframAlphaWorker(Node): |