We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5ee7de commit 4c6c5f0Copy full SHA for 4c6c5f0
langchain/utilities/wolfram_alpha.py
@@ -52,8 +52,15 @@ def validate_environment(cls, values: Dict) -> Dict:
52
def run(self, query: str) -> str:
53
"""Run query through WolframAlpha and parse result."""
54
res = self.wolfram_client.query(query)
55
- # Includes only text from the response
56
- answer = next(res.results).text
+
+ try:
57
+ assumption = next(res.pods).text
58
+ answer = next(res.results).text
59
+ except StopIteration:
60
+ return "Wolfram Alpha wasn't able to answer it"
61
62
if answer is None or answer == "":
63
+ # We don't want to return the assumption alone if answer is empty
64
return "No good Wolfram Alpha Result was found"
- return answer
65
+ else:
66
+ return f"Assumption: {assumption} \nAnswer: {answer}"
0 commit comments