feat: add prefilled_params support for function node#165
feat: add prefilled_params support for function node#165vishnurk6247 merged 5 commits intodevelopfrom
Conversation
WalkthroughThis PR standardizes the name Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as Agent / Arium
participant Builder as AriumBuilder / AgentBuilder
participant FunctionNode
participant Function as user_function()
rect rgb(245,250,245)
Note over Builder,FunctionNode: YAML/builder extracts `prefilled_params` and constructs node/tool
end
Caller->>Builder: add_function_node(name, function, prefilled_params)
Builder->>FunctionNode: new FunctionNode(..., prefilled_params)
Caller->>FunctionNode: invoke(runtime_inputs, **call_kwargs)
Note right of FunctionNode: merge runtime inputs with prefilled_params before call
FunctionNode->>Function: call(**runtime_inputs, **prefilled_params, **call_kwargs)
Function-->>FunctionNode: result
FunctionNode-->>Caller: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
flo_ai/flo_ai/arium/nodes.py (1)
198-201: Critical: NameError due to undefined variable reference.Line 198 references
resultbefore it's defined, which will cause aNameErrorwhen the function is not a coroutine function. The check at line 191 returns early at line 196, so if we reach line 198,resulthasn't been defined yet.The intended logic appears to be checking if a regular function returns a coroutine, but this check should occur after calling the function (after lines 204-206).
Apply this diff to fix the logic:
if asyncio.iscoroutinefunction(self.function): logger.info(f"Executing FunctionNode '{self.name}' as a coroutine function") result = await self.function( inputs=inputs, variables=variables, **self.prefilled_params, **kwargs ) return UserMessage(content=result) - if asyncio.iscoroutine(result): - logger.info(f"Executing FunctionNode '{self.name}' as a coroutine") - content = await result - return UserMessage(content=content) - logger.info(f"Executing FunctionNode '{self.name}' as a regular function") result = self.function( inputs=inputs, variables=variables, **self.prefilled_params, **kwargs ) + + if asyncio.iscoroutine(result): + logger.info(f"Executing FunctionNode '{self.name}' as a coroutine") + content = await result + return UserMessage(content=content) + return UserMessage(content=result)
🧹 Nitpick comments (1)
flo_ai/flo_ai/tool/partial_tool.py (1)
71-80: Consider renaming methods for consistency.The methods
add_pre_filled_paramandremove_pre_filled_paramstill use the oldpre_fillednaming convention, while the rest of the API has been updated toprefilled_params. For consistency, consider renaming these toadd_prefilled_paramandremove_prefilled_paramto align with the updated naming scheme.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
TOOLS.md(15 hunks)flo_ai/examples/partial_tool_example.py(4 hunks)flo_ai/examples/tools_quickstart.py(3 hunks)flo_ai/examples/yaml_tool_config_example.py(5 hunks)flo_ai/flo_ai/__init__.py(2 hunks)flo_ai/flo_ai/arium/__init__.py(2 hunks)flo_ai/flo_ai/arium/builder.py(3 hunks)flo_ai/flo_ai/arium/nodes.py(3 hunks)flo_ai/flo_ai/builder/agent_builder.py(6 hunks)flo_ai/flo_ai/tool/partial_tool.py(5 hunks)flo_ai/flo_ai/tool/tool_config.py(4 hunks)flo_ai/pyproject.toml(1 hunks)flo_ai/tests/unit-tests/test_agent_builder_tools.py(3 hunks)flo_ai/tests/unit-tests/test_arium_builder.py(1 hunks)flo_ai/tests/unit-tests/test_arium_yaml.py(1 hunks)flo_ai/tests/unit-tests/test_partial_tool.py(8 hunks)flo_ai/tests/unit-tests/test_tool_config.py(4 hunks)flo_ai/tests/unit-tests/test_yaml_tool_config.py(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
flo_ai/examples/tools_quickstart.py (1)
flo_ai/flo_ai/tool/partial_tool.py (2)
get_prefilled_params(67-69)remove_pre_filled_param(76-80)
flo_ai/tests/unit-tests/test_partial_tool.py (1)
flo_ai/flo_ai/tool/partial_tool.py (3)
get_prefilled_params(67-69)add_pre_filled_param(71-74)remove_pre_filled_param(76-80)
flo_ai/flo_ai/arium/__init__.py (1)
flo_ai/flo_ai/arium/memory.py (3)
MessageMemory(134-154)BaseMemory(107-131)MessageMemoryItem(22-35)
flo_ai/tests/unit-tests/test_arium_builder.py (2)
flo_ai/flo_ai/arium/builder.py (2)
AriumBuilder(16-970)add_function_node(62-65)flo_ai/flo_ai/arium/nodes.py (1)
FunctionNode(160-207)
flo_ai/flo_ai/__init__.py (2)
flo_ai/flo_ai/arium/memory.py (1)
MessageMemoryItem(22-35)flo_ai/flo_ai/arium/builder.py (1)
create_arium(974-976)
flo_ai/examples/partial_tool_example.py (1)
flo_ai/flo_ai/tool/partial_tool.py (2)
get_prefilled_params(67-69)remove_pre_filled_param(76-80)
flo_ai/flo_ai/builder/agent_builder.py (1)
flo_ai/flo_ai/tool/tool_config.py (2)
ToolConfig(5-56)create_tool_config(59-70)
🔇 Additional comments (24)
flo_ai/pyproject.toml (1)
3-3: Verify the release candidate version number.The version bumps from
1.0.8-rc3to1.1.0-rc2, which means the RC number decreased. Typically, release candidate numbers increment sequentially (rc1 → rc2 → rc3). Confirm whether1.1.0-rc2is correct or if it should be1.1.0-rc1(first RC of the new minor version) or a higher number if prior RCs exist.flo_ai/tests/unit-tests/test_agent_builder_tools.py (1)
50-50: LGTM!Test updates correctly reflect the API rename from
pre_filled_paramstoprefilled_params.Also applies to: 65-68, 84-84, 89-89
flo_ai/flo_ai/arium/__init__.py (1)
4-4: LGTM!Adding
MessageMemoryItemto the public API expands the API surface appropriately without breaking existing functionality.Also applies to: 23-23
flo_ai/flo_ai/__init__.py (1)
45-45: LGTM!Exposing
MessageMemoryItemat the top-level package API is appropriate. The repositioning ofcreate_ariumin the import block is a minor organizational change with no functional impact.Also applies to: 47-47, 103-103
flo_ai/tests/unit-tests/test_tool_config.py (1)
33-33: LGTM!Test updates correctly reflect the API rename from
pre_filled_paramstoprefilled_paramsinToolConfig.Also applies to: 39-39, 58-58, 89-89, 122-125
flo_ai/tests/unit-tests/test_yaml_tool_config.py (1)
80-82: LGTM!YAML configuration key correctly updated from
pre_filled_paramstoprefilled_params, and tests verify the parsing logic handles the new key name.Also applies to: 120-122, 173-174, 266-266
flo_ai/tests/unit-tests/test_arium_yaml.py (1)
210-275: LGTM!The new test method comprehensively validates that
prefilled_paramsare correctly parsed from YAML configuration and properly stored inFunctionNodeinstances. The test covers multiple data types (strings and integers) and verifies the complete flow from YAML parsing to node construction.flo_ai/tests/unit-tests/test_arium_builder.py (1)
74-99: LGTM! Well-structured test for prefilled_params functionality.The test properly validates that:
- FunctionNode accepts prefilled_params
- The node is correctly added to the builder
- Parameter values are preserved and accessible
flo_ai/examples/tools_quickstart.py (2)
128-131: LGTM! Accessor method usage is correct.The code properly uses
get_prefilled_params()to display pre-filled parameters that are hidden from the AI.
160-171: LGTM! YAML configuration properly uses prefilled_params.The YAML examples correctly demonstrate the renamed
prefilled_paramskey for tool configuration.flo_ai/examples/yaml_tool_config_example.py (1)
118-138: LGTM! Consistent usage of renamed prefilled_params.All YAML configurations and ToolConfig usage properly reference the renamed
prefilled_paramsparameter and attribute.Also applies to: 160-175, 201-212, 241-252
flo_ai/examples/partial_tool_example.py (1)
122-131: LGTM! Examples properly demonstrate the renamed API.All references to
prefilled_paramsandget_prefilled_params()are consistent with the updated API.Also applies to: 175-179, 194-194
flo_ai/flo_ai/arium/nodes.py (2)
167-179: LGTM! FunctionNode correctly accepts and stores prefilled_params.The constructor properly accepts
prefilled_paramsas an optional parameter and stores it with a sensible default of an empty dict.
193-195: LGTM! Prefilled params correctly merged with runtime kwargs.The function calls properly spread
**self.prefilled_paramsbefore**kwargs, ensuring that runtime parameters can override prefilled values as expected.Also applies to: 204-206
flo_ai/tests/unit-tests/test_partial_tool.py (1)
40-50: LGTM! Tests properly updated for renamed API.All test cases correctly use:
prefilled_paramsparameter in PartialTool constructorget_prefilled_params()accessor method- Proper validation of prefilled parameter behavior
Also applies to: 72-78, 109-119, 144-157, 172-189, 217-220, 237-245, 281-293
flo_ai/flo_ai/arium/builder.py (1)
534-552: LGTM! YAML parsing correctly wires prefilled_params to FunctionNode.The builder properly:
- Extracts
prefilled_paramsfrom YAML configuration (line 534)- Extracts optional
descriptionandinput_filterfields (lines 535-536)- Passes all parameters to FunctionNode constructor (lines 546-552)
flo_ai/flo_ai/builder/agent_builder.py (2)
54-111: LGTM! AgentBuilder API correctly updated for prefilled_params.The changes properly:
- Update documentation to reference
prefilled_params(lines 64, 74-75, 80-81, 119)- Extract and pass
prefilled_paramsin tool processing (lines 96, 102)- Update
add_toolmethod signature to accept**prefilled_params(line 113)- Consistently use the renamed parameter throughout
Also applies to: 113-133
302-323: LGTM! YAML tool processing correctly uses prefilled_params.The YAML parsing logic properly extracts
prefilled_paramsfrom tool configurations and passes them to ToolConfig, maintaining consistency with the renamed API.TOOLS.md (3)
136-411: LGTM! Documentation updated consistently.The documentation has been systematically updated to reflect the parameter rename from
pre_filled_paramstoprefilled_paramsacross all examples (dictionary format, ToolConfig usage, YAML configurations). The changes are comprehensive and maintain consistency throughout.
460-496: LGTM! API reference updated correctly.The API reference section has been properly updated with the new
prefilled_paramsparameter naming for ToolConfig, PartialTool constructors, and the AgentBuilder.add_tool method.
578-578: LGTM! Debug tip updated correctly.The debug tip has been updated to use the new
get_prefilled_params()method name.flo_ai/flo_ai/tool/tool_config.py (3)
12-31: LGTM! Constructor updated consistently.The
__init__method has been properly updated with the newprefilled_paramsparameter name, including the parameter signature, docstring, and internal attribute assignment. The changes maintain backward compatibility in functionality while updating the API surface.
33-56: LGTM! Methods updated consistently.The
is_partial()andto_tool()methods have been correctly updated to referenceself.prefilled_params, and the PartialTool instantiation uses the new parameter name. The logic remains functionally equivalent.
59-70: LGTM! Helper function updated correctly.The
create_tool_config()function has been properly updated with the newprefilled_paramsparameter name in the signature, docstring, and return statement. The changes are consistent and maintain the function's behavior.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
flo_ai/flo_ai/arium/nodes.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
flo_ai/flo_ai/arium/nodes.py (1)
flo_ai/flo_ai/models/chat_message.py (1)
UserMessage(65-70)
🔇 Additional comments (3)
flo_ai/flo_ai/arium/nodes.py (3)
172-173: LGTM!The parameter signature is correct, with appropriate type annotation and default value.
178-178: LGTM!Proper handling of the None default by converting it to an empty dictionary.
193-195: LGTM!The parameter spreading order is correct:
prefilled_paramsare spread first, followed bykwargs, allowing runtime parameters to override prefilled ones as expected.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
flo_ai/flo_ai/arium/nodes.py (2)
167-179: prefilled_params wiring and defaulting look good; consider copying for isolationUsing
prefilled_params or {}is correct and makes the**self.prefilled_paramsexpansions safe even whenNoneis passed. To avoid surprising mutations from outside code holding the original dict, you might optionally copy here:- self.prefilled_params = prefilled_params or {} + self.prefilled_params = dict(prefilled_params) if prefilled_params else {}
191-201: prefilled_params now consistently applied in both async and sync paths; consider guarding reserved keysPassing
**self.prefilled_params, **kwargsinto both the coroutine and regular function paths cleanly fixes the earlier inconsistency and lets runtime kwargs override prefilled ones, which is a good default.One small edge case: if
prefilled_paramsever includesinputsorvariables, the call could raise a confusing "multiple values for keyword argument" error. You may want to either document that these keys are reserved, or add a lightweight check/validation when constructingFunctionNode(or when loading from config) to prevent such overlaps.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
flo_ai/flo_ai/arium/nodes.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
flo_ai/flo_ai/arium/nodes.py (1)
flo_ai/flo_ai/models/chat_message.py (1)
UserMessage(65-70)
Summary by CodeRabbit
New Features
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.