Sunday, August 18, 2024

Optional inputs to functions for Dynamic AI Agent workflow program is DONE!!!


Today I finally finished the optional input feature on my Dynamic AI Agent workflow program today. Yesterday I fought the program for hours, not able to see the optional values coming into the function.  It was because I had two bugs how I promoted an agent to run as a workflow to be able to run a single agent  with optional inputs when I just ran the agent by itself.  This allows the program to test a single agent.  The agent would work as part of a workflow, but I couldn't run just the agent alone.   Well, there was a disconnect between getting the command line options into the program, and mapping them into the singleton agent workflow. 

First thing this morning I fixed both bugs.  

I had to pass in cli_args to the promote_agent_to_workflow function and add these lines:

for opt_input in agent_config.get('optional_inputs', []):

        if cli_args.get(opt_input) is not None:

            # Add to workflow inputs

            temp_workflow['inputs'].append(opt_input)

            # Add to steps params

            temp_workflow['steps'][0]['params'][opt_input] = f"${opt_input}"

In the config handling I had to move the above function call until after we calculated the command line arguments and also remove entries from the cli_args that didn't actually appear on the command line. 

    cli_args = {k: v for k, v in vars(args).items() if v is not None}

This is the flow of the data through my system, you can see how the command line becomes the cli_args then to the step parameters being passed to the the function, and the output of the function from the input.  You can see how the ENV_ values are replaced by the actual real values from the environmental variables.







No comments:

Post a Comment