mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
workflow
This commit is contained in:
@ -31,6 +31,9 @@ def get_map_value(d: dict, key):
|
||||
if value is list:
|
||||
return value
|
||||
return Literal(value)
|
||||
def get_map_int(d: dict, key):
|
||||
value = d.get(key)
|
||||
return Literal(int(value))
|
||||
|
||||
@singleton
|
||||
class Workflow(Blackbox):
|
||||
@ -38,6 +41,7 @@ class Workflow(Blackbox):
|
||||
@inject
|
||||
def __init__(self, sum: Sum) -> None:
|
||||
self.sum_blackbox = sum
|
||||
self.cost = 0
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.processing(*args, **kwargs)
|
||||
@ -48,6 +52,17 @@ class Workflow(Blackbox):
|
||||
def sum(self, *args, **kwargs):
|
||||
return Literal(self.sum_blackbox.processing(*args, **kwargs))
|
||||
|
||||
def get_cost(self):
|
||||
return self.cost
|
||||
|
||||
def blackbox_example(self):
|
||||
self.cost_increase(10);
|
||||
return Literal("Blackbox result")
|
||||
|
||||
def cost_increase(self, cost):
|
||||
self.cost+=cost
|
||||
return self.cost
|
||||
|
||||
async def processing(self, *args, **kwargs):
|
||||
request: Request = args[0]
|
||||
json = await request.json()
|
||||
@ -79,6 +94,9 @@ class Workflow(Blackbox):
|
||||
"sum": self.sum,
|
||||
"read_binay": read_binay,
|
||||
"jsonfiy": jsonfiy,
|
||||
"get_map_int": get_map_int,
|
||||
"blackbox_example": self.blackbox_example,
|
||||
"get_cost": self.get_cost,
|
||||
}
|
||||
)
|
||||
ast = program_parser(t)
|
||||
|
||||
Reference in New Issue
Block a user