mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: calculator
This commit is contained in:
@ -6,16 +6,16 @@ from blackbox.blackbox import Blackbox
|
||||
class Calculator(Blackbox):
|
||||
|
||||
"""This class just for example, it show how to implement Blackbox interface."""
|
||||
|
||||
|
||||
def valid(self, data: any) -> bool:
|
||||
return isinstance(data, dict) and "operation" in data and "a" in data and "b" in data
|
||||
return isinstance(data, dict) and "op" in data and "left" in data and "right" in data
|
||||
|
||||
def processing(self, data: dict) -> any:
|
||||
if not self.valid(data):
|
||||
raise ValueError("Invalid data")
|
||||
a = data["a"]
|
||||
b = data["b"]
|
||||
op = data["operation"]
|
||||
a = data["left"]
|
||||
b = data["right"]
|
||||
op = data["op"]
|
||||
if op == "add":
|
||||
return a + b
|
||||
if op == "sub":
|
||||
|
||||
Reference in New Issue
Block a user