Tool from Component YAML serde POC #164
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Features to implement
Idea
ComponentTool
(subclass ofTool
)Tool.from_component
.to_dict
method would handle both the serialization of the Tool itself and the underlying component.from_dict
method would recreate the component and the Tool properly.type
attribute forTool
As discussed, the lack of a
type
attribute in Tool is problematic for custom serialization/deserialization, especially when deviating from the basic Tool implementation: in Tool from component, Tool from OpenAPI...To address this, I propose adding a
type
attribute.The implementation is pretty simple and you can see it in action in the example.py file.
Pros
add_tool
to the Pipeline.Cons
Generator
andToolInvoker
). This isn't a significant blocker now but might become problematic if users start converting heavy components into Tools.About verbosity/YAML duplication
As agreed, this has a lower priority, but I found something to explore about YAML anchors and aliases: https://ttl255.com/yaml-anchors-and-aliases-and-how-to-disable-them/