-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: Add Toolset to tooling architecture #9043
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 14043355544Details
💛 - Coveralls |
Perfect, it landed on you @anakin87 🙏 Let's see how we can move forward with the Toolset - as simple as it can get, yet enable dynamic tool discovery |
Sorry for the wait, @vblagoje. |
No problem @anakin87 - as long as we get it into next release - if possible, no rush, let's nail the abstraction correctly. |
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.
I like the idea, but something seems off with the types.
from haystack.tools import Toolset, Tool
from haystack.components.tools import ToolInvoker
def add_numbers(a: int, b: int) -> int:
return a + b
add_tool = Tool(
name="add",
description="Add two numbers",
parameters={
"type": "object",
"properties": {"a": {"type": "integer"}, "b": {"type": "integer"}},
"required": ["a", "b"],
},
function=add_numbers,
)
math_toolset = Toolset([add_tool])
tool_invoker = ToolInvoker(math_toolset)
Running mypy, I get
error: Argument 1 to "ToolInvoker" has incompatible type "Toolset"; expected "list[Tool]" [arg-type]
.
Could you check and iterate on the idea?
Correct @anakin87 somehow it didn't get picked up by mypy when I was running lint/types tests. We have two options:
As everything will still work even if you simply pass toolset instance to ToolInvoker and XYZChatGenerator - I'm kind leaning to approach 1) or 3), wdyt? |
I am not fully understanding options 1 and 2. |
Ah, no problem:
|
Ah, sorry... It was simple. |
@bilgeyucel wdyt, anyone else with a preference feedback? cc @julian-risch @sjrl |
Updated to include list wrapper around all Toolset instances. wdyt @julian-risch |
I like this simple solution, but perhaps we should also think to YAML support... |
Ah good point @anakin87 - so then Union option looks more appropriate? |
@anakin87 Quick heads-up (also shared with @julian-risch): I realized we likely need to change the The current So, we should not always serialize the the Tools in the Not ideal, but seems like the correct path—unless you see a better one. Can you double-check this reasoning and approach against our tooling architecture? |
@vblagoje At this point, it seems that the requirements have evolved and that this simple abstraction may not the best fit. I think we should discuss this further with a clear use-case, more details and possibly a POC. |
Why:
Enhances the tooling infrastructure by introducing a new abstraction, the
Toolset
class, to facilitate the grouping and management of related tool functionalities, supporting dynamic tool loading and registration.What:
Toolset
class to manage collections of tools and enable dynamic loading of tool configurations.__init__.py
to include theToolset
in the exposed API.Toolset
class to ensure its functionality.How can it be used:
The
Toolset
class can be used to group related tools into a cohesive unit, allowing for easier management and potential dynamic loading from external sources:How did you test it:
Tests were written to validate the
Toolset
functionality, including registration of tools, serialization/deserialization, and integration within a pipeline. Specific methods likeToolInvoker
were used to test tool invocation. Tests confirm that tools can be dynamically loaded, executed, and serialized correctly.Notes for the reviewer:
Please pay special attention to the dynamic loading capabilities and serialization logic within the
Toolset
. Ensure there are no name conflicts when registering tools and that the integration tests cover all intended use cases.