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:
parent
20f3a32ccc
commit
d1a22b947a
1 changed files with 6 additions and 7 deletions
|
|
@ -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),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue