From 7b19d14eef73cf4d1de0d174523ee00678febc18 Mon Sep 17 00:00:00 2001 From: anish-work Date: Wed, 14 Aug 2024 13:40:09 +0530 Subject: [PATCH] don't charge credits if functions is called from another workflow --- recipes/Functions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/Functions.py b/recipes/Functions.py index e376bc061..c0b32b2ba 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): @@ -82,6 +83,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"], allow_add=True)