diff --git a/recipes/Functions.py b/recipes/Functions.py index 179c13d95..4c30d5213 100644 --- a/recipes/Functions.py +++ b/recipes/Functions.py @@ -10,6 +10,7 @@ from daras_ai_v2.exceptions import raise_for_status from daras_ai_v2.field_render import field_title_desc from daras_ai_v2.prompt_vars import variables_input +from functions.models import CalledFunction class ConsoleLogs(BaseModel): @@ -83,6 +84,14 @@ def render_form_v2(self): height=300, ) + def get_price_roundoff(self, state: dict) -> float: + try: + # called from another workflow don't charge any credits + CalledFunction.objects.get(function_run=self.get_current_sr()) + return 0 + except CalledFunction.DoesNotExist: + return self.price + def render_variables(self): variables_input( template_keys=["code"],