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:
|
if value is list:
|
||||||
return value
|
return value
|
||||||
return Literal(value)
|
return Literal(value)
|
||||||
|
def get_map_int(d: dict, key):
|
||||||
|
value = d.get(key)
|
||||||
|
return Literal(int(value))
|
||||||
|
|
||||||
@singleton
|
@singleton
|
||||||
class Workflow(Blackbox):
|
class Workflow(Blackbox):
|
||||||
@ -38,6 +41,7 @@ class Workflow(Blackbox):
|
|||||||
@inject
|
@inject
|
||||||
def __init__(self, sum: Sum) -> None:
|
def __init__(self, sum: Sum) -> None:
|
||||||
self.sum_blackbox = sum
|
self.sum_blackbox = sum
|
||||||
|
self.cost = 0
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return self.processing(*args, **kwargs)
|
return self.processing(*args, **kwargs)
|
||||||
@ -48,6 +52,17 @@ class Workflow(Blackbox):
|
|||||||
def sum(self, *args, **kwargs):
|
def sum(self, *args, **kwargs):
|
||||||
return Literal(self.sum_blackbox.processing(*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):
|
async def processing(self, *args, **kwargs):
|
||||||
request: Request = args[0]
|
request: Request = args[0]
|
||||||
json = await request.json()
|
json = await request.json()
|
||||||
@ -79,6 +94,9 @@ class Workflow(Blackbox):
|
|||||||
"sum": self.sum,
|
"sum": self.sum,
|
||||||
"read_binay": read_binay,
|
"read_binay": read_binay,
|
||||||
"jsonfiy": jsonfiy,
|
"jsonfiy": jsonfiy,
|
||||||
|
"get_map_int": get_map_int,
|
||||||
|
"blackbox_example": self.blackbox_example,
|
||||||
|
"get_cost": self.get_cost,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ast = program_parser(t)
|
ast = program_parser(t)
|
||||||
|
|||||||
Reference in New Issue
Block a user