Merge pull request #13372 from therealmichaelberna/main
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11.x) (push) Waiting to run
Python CI / Format Backend (3.12.x) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run

**fix** convert_function_to_pydantic_model returning empty descriptions
This commit is contained in:
Tim Jaeryang Baek 2025-04-30 13:36:22 -07:00 committed by GitHub
commit f3b38e9777
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -279,8 +279,8 @@ def convert_function_to_pydantic_model(func: Callable) -> type[BaseModel]:
docstring = func.__doc__
description = parse_description(docstring)
function_descriptions = parse_docstring(docstring)
function_description = parse_description(docstring)
function_param_descriptions = parse_docstring(docstring)
field_defs = {}
for name, param in parameters.items():
@ -288,15 +288,15 @@ def convert_function_to_pydantic_model(func: Callable) -> type[BaseModel]:
type_hint = type_hints.get(name, Any)
default_value = param.default if param.default is not param.empty else ...
description = function_descriptions.get(name, None)
param_description = function_param_descriptions.get(name, None)
if description:
field_defs[name] = type_hint, Field(default_value, description=description)
if param_description:
field_defs[name] = type_hint, Field(default_value, description=param_description)
else:
field_defs[name] = type_hint, default_value
model = create_model(func.__name__, **field_defs)
model.__doc__ = description
model.__doc__ = function_description
return model