wt002 commited on
Commit
eb8a297
·
verified ·
1 Parent(s): 3d002ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -53
app.py CHANGED
@@ -96,59 +96,6 @@ class KeywordsExtractorTool(Tool):
96
  return f"Error during extracting most common words: {e}"
97
 
98
 
99
- @tool
100
- def calculator(inputs: Union[str, dict]):
101
- """
102
- Perform mathematical operations based on the operation provided.
103
- Supports both binary (a, b) operations and list operations.
104
- """
105
-
106
- # If input is a JSON string, parse it
107
- if isinstance(inputs, str):
108
- try:
109
- import json
110
- inputs = json.loads(inputs)
111
- except Exception as e:
112
- return f"Invalid input format: {e}"
113
-
114
- # Handle list-based operations like SUM
115
- if "list" in inputs:
116
- nums = inputs.get("list", [])
117
- op = inputs.get("operation", "").lower()
118
-
119
- if not isinstance(nums, list) or not all(isinstance(n, (int, float)) for n in nums):
120
- return "Invalid list input. Must be a list of numbers."
121
-
122
- if op == "sum":
123
- return sum(nums)
124
- elif op == "multiply":
125
- return reduce(operator.mul, nums, 1)
126
- else:
127
- return f"Unsupported list operation: {op}"
128
-
129
- # Handle basic two-number operations
130
- a = inputs.get("a")
131
- b = inputs.get("b")
132
- operation = inputs.get("operation", "").lower()
133
-
134
- if a is None or b is None or not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
135
- return "Both 'a' and 'b' must be numbers."
136
-
137
- if operation == "add":
138
- return a + b
139
- elif operation == "subtract":
140
- return a - b
141
- elif operation == "multiply":
142
- return a * b
143
- elif operation == "divide":
144
- if b == 0:
145
- return "Error: Division by zero"
146
- return a / b
147
- elif operation == "modulus":
148
- return a % b
149
- else:
150
- return f"Unknown operation: {operation}"
151
-
152
 
153
  @tool
154
  def parse_excel_to_json(task_id: str) -> dict:
 
96
  return f"Error during extracting most common words: {e}"
97
 
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  @tool
101
  def parse_excel_to_json(task_id: str) -> dict: