Skip to content
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

Tool from Component YAML serde POC #164

Closed
wants to merge 2 commits into from

Conversation

anakin87
Copy link
Member

@anakin87 anakin87 commented Jan 8, 2025

Features to implement

  • Enable conversion of components to Tools (essentially implemented by Vladimir in feat: Add Tool.from_component #159)
  • Support the YAML serialization and deserialization for components defined from Tools

Idea

  1. ComponentTool (subclass of Tool)
  • This would have the same features of 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.
  • The component would be created in isolation - outside of a Pipeline.
  1. Introducing a type attribute for Tool
    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

  • No changes to the Pipeline serde logic to accommodate this use case.
  • Avoids adding potentially confusing methods like add_tool to the Pipeline.
  • Minimal divergence from the current implementation.
  • Clearly separates components wrapped as Tools from the Pipeline: they are independent, cannot be connected, etc.

Cons

  • not specific to this idea, but we deserialize and initialize the Tools each time they appear (e.g., duplication between Generator and ToolInvoker). 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/

@anakin87 anakin87 changed the title Tool Component YAML serde POC Tool from Component YAML serde POC Jan 8, 2025
@anakin87
Copy link
Member Author

anakin87 commented Jan 9, 2025

Closing. We're implementing the POC in the linked PRs.

@anakin87 anakin87 closed this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant