Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/nat/cli/commands/workflow/templates/config.yml.j2
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/nat/cli/commands/workflow/templates/register.py.j2
Original file line number Diff line number Diff line change
@@ -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
26 changes: 22 additions & 4 deletions src/nat/cli/commands/workflow/templates/workflow.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 echoes 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__)