Skip to content

Commit e9e987f

Browse files
committed
fix: more types in client_tool type conversion
Summary: Test Plan:
1 parent 8c00bcb commit e9e987f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/llama_stack_client/lib/agents/client_tool.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def async_run_impl(self, **kwargs):
129129

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

132+
# python typehint to litellm/openai parameter spec
133+
TYPEHINT_TO_LITELLM_TYPE = {
134+
"int": "integer",
135+
"float": "number",
136+
"bool": "boolean",
137+
"str": "string",
138+
}
139+
132140

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

0 commit comments

Comments
 (0)