From 6caea54fc73f1729f65acb5d7414c61be6675503 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 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"],