Skip to content
Open
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
12 changes: 8 additions & 4 deletions packages/toolbox-core/src/toolbox_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@

def create_func_docstring(description: str, params: Sequence[ParameterSchema]) -> str:
"""Convert tool description and params into its function docstring"""
docstring = description
docstring = description.rstrip()

if not params:
return docstring

docstring += "\n\nArgs:"

for p in params:
annotation = p.to_param().annotation
docstring += f"\n {p.name} ({getattr(annotation, '__name__', str(annotation))}): {p.description}"

param_desc = p.description.strip() if p.description else ""

docstring += f"\n {p.name} ({getattr(annotation, '__name__', str(annotation))}): {param_desc}"
return docstring


Expand Down Expand Up @@ -88,7 +94,6 @@ def identify_auth_requirements(

# find which of the required authn params are covered by available services.
for param, services in req_authn_params.items():

# if we don't have a token_getter for any of the services required by the param,
# the param is still required
matched_authn_services = [s for s in services if s in auth_service_names]
Expand Down Expand Up @@ -119,7 +124,6 @@ def params_to_pydantic_model(
"""Converts the given parameters to a Pydantic BaseModel class."""
field_definitions = {}
for field in params:

# Determine the default value based on the 'required' flag and the 'default' field.
# '...' (Ellipsis) signifies a required field in Pydantic.
# If a default value is provided in the schema, it should be used.
Expand Down
Loading