Use this file to discover all available pages before exploring further.
You can manually map the inputs and outputs of your nodes using the map_input() and map_output() methods. To do this, call map_input() or map_output() in your node and provide the following values:
map_input() Parameters
Parameter
Type
Required
Description
input_variable
string
Yes
The variable you want to map.
expression
string
Yes
The expression used to map the input.
default_value
string
No
The default value for the mapped input.
map_output() Parameters
Parameter
Type
Required
Description
output_variable
string
Yes
The variable you want to map.
expression
string
Yes
The expression used to map the output.
default_value
string
No
The default value for the mapped output.
The following example shows how to use map_input() and map_output() to map values for a node:
Python
'''Build a simple hello world agentic workflow that will combine the result of two tools.'''from pydantic import BaseModelfrom ibm_watsonx_orchestrate.flow_builder.flows import END, Flow, flow, STARTfrom .get_hello_message import get_hello_messagefrom .combine_names import combine_namesclass Name(BaseModel): """ This class represents a person's name. Attributes: first_name (str): The person's first name. last_name (str): The person's last name. """ first_name: str last_name: strclass Message(BaseModel): msg: str@flow( name = "hello_message_flow", input_schema=Name, output_schema=Message )def build_hello_message_flow_datamap(aflow: Flow = None) -> Flow: """ Creates a agentic workflow with two tools: get_hello_message and combine_names. Args: flow (Flow, optional): The agentic workflow to be built. Defaults to None. Returns: Flow: The created agentic workflow. """ combine_names_node = aflow.tool(combine_names) combine_names_node.map_input(input_variable="first_name", expression="flow.input.first_name") combine_names_node.map_input(input_variable="last_name", expression="flow.input.last_name", default_value="default_last_name") get_hello_message_node = aflow.tool(get_hello_message, output_schema=Message) aflow.edge(START, combine_names_node).edge(combine_names_node, get_hello_message_node).edge(get_hello_message_node, END) aflow.map_output(output_variable="msg", expression="flow.get_hello_message_node.msg") return aflow