feat: refactor component tool description format to prioritize component description (#8327)

* 📝 (component_tool.py): change the order of component description and method in the build_description function to improve readability and consistency

* ♻️ (component_tool.py): refactor build_description function to only return the component description without including the output method

---------

Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-06-16 10:14:41 -03:00 committed by GitHub
commit d1a22b947a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,9 +37,8 @@ def _get_input_type(input_: InputTypes):
return input_.field_type
def build_description(component: Component, output: Output) -> str:
name = component.name or component.__class__.__name__
return f"{name}. {output.method} - {component.description}"
def build_description(component: Component) -> str:
return f"{component.description}"
async def send_message_noop(
@ -231,7 +230,7 @@ class ComponentToolkit:
tools.append(
StructuredTool(
name=formatted_name,
description=build_description(self.component, output),
description=build_description(self.component),
coroutine=_build_output_async_function(self.component, output_method, event_manager),
args_schema=args_schema,
handle_tool_error=True,
@ -239,7 +238,7 @@ class ComponentToolkit:
tags=[formatted_name],
metadata={
"display_name": formatted_name,
"display_description": build_description(self.component, output),
"display_description": build_description(self.component),
},
)
)
@ -247,7 +246,7 @@ class ComponentToolkit:
tools.append(
StructuredTool(
name=formatted_name,
description=build_description(self.component, output),
description=build_description(self.component),
func=_build_output_function(self.component, output_method, event_manager),
args_schema=args_schema,
handle_tool_error=True,
@ -255,7 +254,7 @@ class ComponentToolkit:
tags=[formatted_name],
metadata={
"display_name": formatted_name,
"display_description": build_description(self.component, output),
"display_description": build_description(self.component),
},
)
)