Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/llama_stack_client/lib/agents/client_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ def async_run_impl(self, **kwargs):

T = TypeVar("T", bound=Callable)

# python typehint to litellm/openai parameter spec
TYPEHINT_TO_LITELLM_TYPE = {
"int": "integer",
"float": "number",
"bool": "boolean",
"str": "string",
}


def client_tool(func: T) -> ClientTool:
"""
Expand Down Expand Up @@ -197,8 +205,7 @@ def get_params_definition(self) -> Dict[str, Parameter]:
params[name] = Parameter(
name=name,
description=param_doc or f"Parameter {name}",
# Hack: litellm/openai expects "string" for str type
parameter_type=type_hint.__name__ if type_hint.__name__ != "str" else "string",
parameter_type=TYPEHINT_TO_LITELLM_TYPE.get(type_hint.__name__, type_hint.__name__),
default=(param.default if param.default != inspect.Parameter.empty else None),
required=is_required,
)
Expand Down