From c3e84dc5caacd4e9d59e6828dcaaa9c503e57e75 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Jan 2025 16:42:54 +0100 Subject: [PATCH] Fix function tool naming to avoid overriding the name input (#5165) fix function tool naming to avoid overriding the name input --- .../autogen-core/src/autogen_core/_function_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/packages/autogen-core/src/autogen_core/_function_utils.py b/python/packages/autogen-core/src/autogen_core/_function_utils.py index 7f11e458a..503b89120 100644 --- a/python/packages/autogen-core/src/autogen_core/_function_utils.py +++ b/python/packages/autogen-core/src/autogen_core/_function_utils.py @@ -304,18 +304,18 @@ def normalize_annotated_type(type_hint: Type[Any]) -> Type[Any]: def args_base_model_from_signature(name: str, sig: inspect.Signature) -> Type[BaseModel]: fields: Dict[str, tuple[Type[Any], Any]] = {} - for name, param in sig.parameters.items(): + for param_name, param in sig.parameters.items(): # This is handled externally - if name == "cancellation_token": + if param_name == "cancellation_token": continue if param.annotation is inspect.Parameter.empty: raise ValueError("No annotation") type = normalize_annotated_type(param.annotation) - description = type2description(name, param.annotation) + description = type2description(param_name, param.annotation) default_value = param.default if param.default is not inspect.Parameter.empty else PydanticUndefined - fields[name] = (type, Field(default=default_value, description=description)) + fields[param_name] = (type, Field(default=default_value, description=description)) return cast(BaseModel, create_model(name, **fields)) # type: ignore