feature: add command feature column to toolset table and other minor table improvements (#5343)

* refactor: Update toolset configuration display name and description

This commit updates the display name and description of the toolset configuration in the custom component. The display name is changed to "Edit tools" and the description is modified to "Modify tool names and descriptions to help agents understand when to use each tool." This improves the clarity and usability of the toolset configuration.

* refactor: Update table modal header description handling

* refactor: Add EditMode.POPOVER option to table schema

* refactor: Add EditMode.POPOVER option to table schema

* refactor: Add table icon to table schema and components

* add style for not editable cells

* Add "commands" field to tool table schema

* refactor: Add "no_blank" and "valid_csv" field parsers

- Added "no_blank" field parser to remove leading and trailing whitespace from strings and throw an error if the string is blank.
- Added "valid_csv" field parser to replace whitespace with commas in strings.

* refactor: Add commands to tool description in ComponentToolkit

* refactor: Improve parsing of commands in validCommands function

* Update src/frontend/src/utils/stringManipulation.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [autofix.ci] apply automated fixes

* add support for hints on table header

* update descriptions on tool table

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
anovazzi1 2025-01-10 09:15:37 -03:00 • committed by GitHub
commit 18acd304a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 185 additions and 51 deletions

View file

@ -159,6 +159,10 @@ def _format_tool_name(name: str):
return re.sub(r"[^a-zA-Z0-9_-]", "-", name)
def _add_commands_to_tool_description(tool_description: str, commands: str):
return f"very_time you see one of those commands {commands} run the tool. tool description is {tool_description}"
class ComponentToolkit:
def __init__(self, component: Component, metadata: pd.DataFrame | None = None):
self.component = component
@ -276,6 +280,10 @@ class ComponentToolkit:
tool_metadata = metadata_dict[tag]
tool.name = tool_metadata.get("name", tool.name)
tool.description = tool_metadata.get("description", tool.description)
if tool_metadata.get("commands"):
tool.description = _add_commands_to_tool_description(
tool.description, tool_metadata.get("commands")
)
else:
msg = f"Expected a StructuredTool or BaseTool, got {type(tool)}"
raise TypeError(msg)

View file

@ -20,21 +20,31 @@ TOOL_TABLE_SCHEMA = [
"description": "Describe the purpose of the tool.",
"sortable": False,
"filterable": False,
"edit_mode": EditMode.INLINE,
"edit_mode": EditMode.POPOVER,
},
{
"name": "tags",
"display_name": "Tool Identifiers",
"type": "str",
"description": (
"These are the default identifiers for the tools and cannot be changed. "
"Tool Name and Tool Description are the only editable fields."
),
"description": ("The default identifiers for the tools and cannot be changed."),
"disable_edit": True,
"sortable": False,
"filterable": False,
"edit_mode": EditMode.INLINE,
},
{
"name": "commands",
"display_name": "Commands",
"type": "str",
"description": (
"Add commands to the tool. These commands will be used to run the tool. Start all commands with a `/`. "
"You can add multiple commands separated by a comma.\n"
"Example: `/command1`, `/command2`, `/command3`"
),
"sortable": False,
"filterable": False,
"edit_mode": EditMode.INLINE,
},
]
TOOLS_METADATA_INFO = "Use the table to configure the tools."
TOOLS_METADATA_INFO = "Modify tool names and descriptions to help agents understand when to use each tool."

View file

@ -1209,13 +1209,13 @@ class Component(CustomComponent):
return TableInput(
name=TOOLS_METADATA_INPUT_NAME,
info=TOOLS_METADATA_INFO,
display_name="Toolset configuration",
display_name="Edit tools",
real_time_refresh=True,
table_schema=TOOL_TABLE_SCHEMA,
value=tool_data,
table_icon="Hammer",
trigger_icon="Hammer",
trigger_text="Open toolset",
trigger_text="",
table_options=TableOptions(
block_add=True,
block_delete=True,
@ -1225,6 +1225,10 @@ class Component(CustomComponent):
block_hide=True,
block_select=True,
hide_options=True,
field_parsers={"name": FieldParserType.SNAKE_CASE},
field_parsers={
"name": [FieldParserType.SNAKE_CASE, FieldParserType.NO_BLANK],
"commands": FieldParserType.COMMANDS,
},
description=TOOLS_METADATA_INFO,
),
)

View file

@ -186,6 +186,7 @@ class TableMixin(BaseModel):
table_schema: TableSchema | list[Column] | None = None
trigger_text: str = Field(default="Open table")
trigger_icon: str = Field(default="Table")
table_icon: str = Field(default="Table")
table_options: TableOptions | None = None
@field_validator("table_schema")

View file

@ -15,6 +15,7 @@ class FormatterType(str, Enum):
class EditMode(str, Enum):
MODAL = "modal"
POPOVER = "popover"
INLINE = "inline"
@ -83,6 +84,9 @@ class FieldParserType(str, Enum):
KEBAB_CASE = "kebab_case"
LOWERCASE = "lowercase"
UPPERCASE = "uppercase"
NO_BLANK = "no_blank"
VALID_CSV = ("valid_csv",)
COMMANDS = "commands"
class TableOptions(BaseModel):
@ -96,3 +100,4 @@ class TableOptions(BaseModel):
hide_options: bool = Field(default=False)
field_validators: dict[str, list[FieldValidatorType] | FieldValidatorType] | None = Field(default=None)
field_parsers: dict[str, list[FieldParserType] | FieldParserType] | None = Field(default=None)
description: str | None = Field(default=None)