Skip to content

Commit

Permalink
avoid showing recipe fields as variables
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jan 10, 2025
1 parent 283a61e commit 45a4140
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,9 @@ def render_variables(self):
if not self.functions_in_settings:
functions_input(self.request.user)
variables_input(
template_keys=self.template_keys, allow_add=is_functions_enabled()
template_keys=self.template_keys,
allow_add=is_functions_enabled(),
exclude=self.fields_to_save(),
)

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion daras_ai_v2/variables_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def variables_input(
description: str = "Variables let you pass custom parameters to your workflow. Access a variable in your instruction prompt with <a href='https://jinja.palletsprojects.com/en/3.1.x/templates/' target='_blank'>Jinja</a>, e.g. `{{ my_variable }}`\n ",
key: str = "variables",
allow_add: bool = False,
exclude: typing.Iterable[str] = (),
):
from recipes.BulkRunner import list_view_editor

Expand All @@ -45,7 +46,7 @@ def variables_input(
var_names = (
(template_var_names | set(variables.keys()))
- set(context_globals().keys()) # dont show global context variables
- set(gui.session_state.keys()) # dont show other session state variables
- set(exclude) # used for hiding request/response fields
)
pressed_add = False
if var_names or allow_add:
Expand Down
1 change: 1 addition & 0 deletions recipes/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def render_variables(self):
allow_add=True,
description="Pass custom parameters to your function and access the parent workflow data. "
"Variables will be passed down as the first argument to your anonymous JS function.",
exclude=self.fields_to_save(),
)

options = set(gui.session_state.get("secrets") or [])
Expand Down

0 comments on commit 45a4140

Please sign in to comment.