Skip to content

Commit

Permalink
don't charge credits if functions is called from another workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Aug 14, 2024
1 parent c5f464a commit 6caea54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions recipes/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"],
Expand Down

0 comments on commit 6caea54

Please sign in to comment.