mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-15 14:08:00 +00:00
Add items and title to ToolParameter/ToolParamDefinition
This commit is contained in:
parent
0b08d64ddb
commit
dbaf38acc5
5 changed files with 18 additions and 0 deletions
|
@ -26,6 +26,8 @@ class ToolParameter(BaseModel):
|
|||
:param parameter_type: Type of the parameter (e.g., string, integer)
|
||||
:param description: Human-readable description of what the parameter does
|
||||
:param required: Whether this parameter is required for tool invocation
|
||||
:param items: Type of the elements when parameter_type is array
|
||||
:param title: (Optional) Title of the parameter
|
||||
:param default: (Optional) Default value for the parameter if not provided
|
||||
"""
|
||||
|
||||
|
@ -33,6 +35,8 @@ class ToolParameter(BaseModel):
|
|||
parameter_type: str
|
||||
description: str
|
||||
required: bool = Field(default=True)
|
||||
items: dict | None = None
|
||||
title: str | None = None
|
||||
default: Any | None = None
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ class ToolParamDefinition(BaseModel):
|
|||
param_type: str
|
||||
description: str | None = None
|
||||
required: bool | None = True
|
||||
items: Any | None = None
|
||||
title: str | None = None
|
||||
default: Any | None = None
|
||||
|
||||
|
||||
|
|
|
@ -797,6 +797,8 @@ class ChatAgent(ShieldRunnerMixin):
|
|||
param_type=param.parameter_type,
|
||||
description=param.description,
|
||||
required=param.required,
|
||||
items=param.items,
|
||||
title=param.title,
|
||||
default=param.default,
|
||||
)
|
||||
for param in tool_def.parameters
|
||||
|
@ -840,6 +842,8 @@ class ChatAgent(ShieldRunnerMixin):
|
|||
param_type=param.parameter_type,
|
||||
description=param.description,
|
||||
required=param.required,
|
||||
items=param.items,
|
||||
title=param.title,
|
||||
default=param.default,
|
||||
)
|
||||
for param in tool_def.parameters
|
||||
|
|
|
@ -796,6 +796,10 @@ def convert_tooldef_to_openai_tool(tool: ToolDefinition) -> dict:
|
|||
properties[param_name].update(description=param.description)
|
||||
if param.default:
|
||||
properties[param_name].update(default=param.default)
|
||||
if param.items:
|
||||
properties[param_name].update(items=param.items)
|
||||
if param.title:
|
||||
properties[param_name].update(title=param.title)
|
||||
if param.required:
|
||||
required.append(param_name)
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ async def list_mcp_tools(endpoint: str, headers: dict[str, str]) -> ListToolDefs
|
|||
name=param_name,
|
||||
parameter_type=param_schema.get("type", "string"),
|
||||
description=param_schema.get("description", ""),
|
||||
required="default" not in param_schema,
|
||||
items=param_schema.get("items", None),
|
||||
title=param_schema.get("title", None),
|
||||
default=param_schema.get("default", None),
|
||||
)
|
||||
)
|
||||
tools.append(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue