From be6614104a33728c3f383b98d1a2ab470f845b0a Mon Sep 17 00:00:00 2001 From: Will Killian Date: Thu, 2 Oct 2025 13:22:21 -0400 Subject: [PATCH 1/3] chore: additional template cleanup Signed-off-by: Will Killian --- .../commands/workflow/templates/config.yml.j2 | 13 ---------- .../workflow/templates/workflow.py.j2 | 26 ++++++++++++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/nat/cli/commands/workflow/templates/config.yml.j2 b/src/nat/cli/commands/workflow/templates/config.yml.j2 index 918e53077..1cd2dcf90 100644 --- a/src/nat/cli/commands/workflow/templates/config.yml.j2 +++ b/src/nat/cli/commands/workflow/templates/config.yml.j2 @@ -1,15 +1,3 @@ -general: - logging: - console: - _type: console - level: WARN - - front_end: - _type: fastapi - - front_end: - _type: console - functions: current_datetime: _type: current_datetime @@ -27,4 +15,3 @@ workflow: _type: react_agent llm_name: nim_llm tool_names: [current_datetime, {{python_safe_workflow_name}}] - parse_agent_response_max_retries: 3 diff --git a/src/nat/cli/commands/workflow/templates/workflow.py.j2 b/src/nat/cli/commands/workflow/templates/workflow.py.j2 index 9f07e049d..bf854d483 100644 --- a/src/nat/cli/commands/workflow/templates/workflow.py.j2 +++ b/src/nat/cli/commands/workflow/templates/workflow.py.j2 @@ -20,13 +20,31 @@ class {{ workflow_class_name }}(FunctionBaseConfig, name="{{ workflow_name }}"): @register_function(config_type={{ workflow_class_name }}, framework_wrappers=[LLMFrameworkEnum.LANGCHAIN]) async def {{ python_safe_workflow_name }}_function(config: {{ workflow_class_name }}, builder: Builder): + """ + Registers a function (addressable via `{{ workflow_name }}` in the configuration). + This registration ensures a static mapping of the function type, `{{ workflow_name }}`, to the `{{ workflow_class_name }}` configuration object. + + Args: + config ({{ workflow_class_name }}): The configuration for the function. + builder (Builder): The builder object. + + Returns: + FunctionInfo: The function info object for the function. + """ + # Define the function that will be registered. async def _echo(text: str) -> str: """ - This is the part where all the logic for the function goes. + Takes a text input and echos back with a pre-defined prefix. + + Args: + text (str): The text to echo back. + + Returns: + str: The text with the prefix. """ return f"{config.prefix} {text}" - # This is the part where the function is registered. The description parameter is used to describe the function. - yield FunctionInfo.from_fn( - _echo, description="This is a function that takes an input and echos back with a pre-defined prefix.") + # The callable is wrapped in a FunctionInfo object. + # The description parameter is used to describe the function. + yield FunctionInfo.from_fn(_echo, description=_echo.__doc__) From 9db25456d822d193257408615ff4b82bb1f4f141 Mon Sep 17 00:00:00 2001 From: Will Killian Date: Thu, 2 Oct 2025 13:57:58 -0400 Subject: [PATCH 2/3] bug: fix error with missing _function suffix Signed-off-by: Will Killian --- src/nat/cli/commands/workflow/templates/register.py.j2 | 2 +- src/nat/cli/commands/workflow/templates/workflow.py.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nat/cli/commands/workflow/templates/register.py.j2 b/src/nat/cli/commands/workflow/templates/register.py.j2 index d5085beef..5d44d0acf 100644 --- a/src/nat/cli/commands/workflow/templates/register.py.j2 +++ b/src/nat/cli/commands/workflow/templates/register.py.j2 @@ -1,4 +1,4 @@ # flake8: noqa # Import the generated workflow function to trigger registration -from {{package_name}} import {{ python_safe_workflow_name }} +from {{package_name}} import {{ python_safe_workflow_name }}_function diff --git a/src/nat/cli/commands/workflow/templates/workflow.py.j2 b/src/nat/cli/commands/workflow/templates/workflow.py.j2 index bf854d483..1d781432f 100644 --- a/src/nat/cli/commands/workflow/templates/workflow.py.j2 +++ b/src/nat/cli/commands/workflow/templates/workflow.py.j2 @@ -35,7 +35,7 @@ async def {{ python_safe_workflow_name }}_function(config: {{ workflow_class_nam # Define the function that will be registered. async def _echo(text: str) -> str: """ - Takes a text input and echos back with a pre-defined prefix. + Takes a text input and echoes back with a pre-defined prefix. Args: text (str): The text to echo back. From 657ea5054382667f979830c511963ee948751c60 Mon Sep 17 00:00:00 2001 From: Will Killian Date: Thu, 2 Oct 2025 14:22:57 -0400 Subject: [PATCH 3/3] fix: relative import Signed-off-by: Will Killian --- src/nat/cli/commands/workflow/templates/register.py.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nat/cli/commands/workflow/templates/register.py.j2 b/src/nat/cli/commands/workflow/templates/register.py.j2 index 5d44d0acf..8e18f0465 100644 --- a/src/nat/cli/commands/workflow/templates/register.py.j2 +++ b/src/nat/cli/commands/workflow/templates/register.py.j2 @@ -1,4 +1,4 @@ # flake8: noqa # Import the generated workflow function to trigger registration -from {{package_name}} import {{ python_safe_workflow_name }}_function +from .{{package_name}} import {{ python_safe_workflow_name }}_function