-
Notifications
You must be signed in to change notification settings - Fork 498
Add example of control flow composition with router agent and sequential executor #1550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add example of control flow composition with router agent and sequential executor #1550
Conversation
…equential executor Signed-off-by: Patrick Chin <8509935+thepatrickchin@users.noreply.github.com>
Signed-off-by: Patrick Chin <8509935+thepatrickchin@users.noreply.github.com>
WalkthroughAdds a new "Mixture of Control Flows" example: documentation, project metadata, a YAML workflow combining router_agent and sequential_executor patterns, mock function registrations, and integration tests exercising several routing and sequential scenarios. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@examples/control_flow/mixture_of_control_flows/configs`:
- Line 1: The file named "configs" in the mixture_of_control_flows example
contains an absolute local path string ("/Users/...") and must be removed or
replaced: either delete this file from the repo, or recreate it as a proper
relative symlink that points to the example's configs directory (e.g., create a
symlink named configs that points to the src/mixture_of_control_flows/configs
directory); ensure no absolute local paths remain in the committed file.
🧹 Nitpick comments (6)
examples/control_flow/mixture_of_control_flows/pyproject.toml (1)
46-47: Add trailing newline at end of file.Per coding guidelines, every file should end with a single newline.
Proposed fix
[project.entry-points.'nat.components'] nat_mixture_of_control_flows = "mixture_of_control_flows.register" +examples/control_flow/mixture_of_control_flows/src/mixture_of_control_flows/register.py (2)
31-57: Consider adding return type hints for async generator functions.For better type safety and documentation, the async generator functions should include return type hints. The
configandbuilderparameters are required by the@register_functiondecorator interface, so the Ruff warnings about unused arguments are false positives in this context.Example type hint addition
+from collections.abc import AsyncGenerator + `@register_function`(config_type=MockInputValidatorFunctionConfig, framework_wrappers=[LLMFrameworkEnum.LANGCHAIN]) -async def mock_input_validator_function(config: MockInputValidatorFunctionConfig, builder: Builder): +async def mock_input_validator_function( + config: MockInputValidatorFunctionConfig, builder: Builder +) -> AsyncGenerator[FunctionInfo, None]:
137-139: Add trailing newline at end of file.Per coding guidelines, every file should end with a single newline.
Proposed fix
yield FunctionInfo.from_fn(format_result, description="Format the final processing result") +examples/control_flow/mixture_of_control_flows/src/mixture_of_control_flows/configs/config.yml (2)
1-1: Copyright year inconsistency.This file uses
2024-2026while other files in this PR use2025-2026. For consistency across the new example, consider updating to2025-2026.Proposed fix
-# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
69-73: Add trailing newline at end of file.Per coding guidelines, every file should end with a single newline.
Proposed fix
branches: [text_analysis_pipeline, text_formatting_pipeline, general_advisor] llm_name: nim_llm detailed_logs: true +examples/control_flow/mixture_of_control_flows/tests/test_mixture_of_control_flows.py (1)
44-45: Add trailing newline at end of file.Per coding guidelines, every file should end with a single newline.
Proposed fix
await run_workflow(config_file=config_file, question=question, expected_answer=expected_answer) +
Signed-off-by: Patrick Chin <pchin@nvidia.com> Signed-off-by: Patrick Chin <8509935+thepatrickchin@users.noreply.github.com>
willkill07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor feedback overall. Please address the symbolic link issue by having it be relative rather than absolute.
| "nat_sequential_executor == {version}", | ||
| "nat_router_agent == {version}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't publish these packages, you can get away with:
| "nat_sequential_executor == {version}", | |
| "nat_router_agent == {version}", | |
| "nat_sequential_executor", | |
| "nat_router_agent", |
|
|
||
| ### Router Agent to Sequential Executor with Router Agent | ||
|
|
||
| Test the text formatting pipeline — these examples demonstrate flows from a sequential executor to a router agent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: for each of these have an output immediately follow run.
| llms: | ||
| nim_llm: | ||
| _type: nim | ||
| model_name: meta/llama-3.1-70b-instruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are trying to reduce our dependence on this model. Have you tried this with nvidia/nemotron-3-nano-30b-a3b?
| llms: | ||
| nim_llm: | ||
| _type: nim | ||
| model_name: meta/llama-3.1-70b-instruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust this line/config if you adjust the file
|
/ok to test 409ee7f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other request... if you update develop, please add nat_mixture_of_control_flows to the examples listing and reference it accordingly (and rerun uv lock in the root directory).
We are trying to do better at tracking examples and their dependencies.
Description
This PR adds an example of composing router agent with sequential executor. It showcases the following control flows:
By Submitting this PR I confirm:
Summary by CodeRabbit
Documentation
Tests