Skip to content

Conversation

@pardeep-singh
Copy link

Fix TypeError: argument of type 'bool' is not iterable when launching the Gradio weather agent UI.

Changes:

  • Replace dict[str, Any] return type with WeatherResponse Pydantic model in get_weather tool to avoid boolean additionalProperties in JSON schema
  • Add monkey patch for Gradio's JSON schema parser to handle boolean additionalProperties gracefully
  • Remove explicit type hints from Gradio callback functions to avoid schema introspection issues
  • Add api_name=False to submit handler to disable API generation
  • Remove unused typing.Any import

The issue was caused by dict[str, Any] generating a JSON schema with additionalProperties: true (boolean), which Gradio's schema parser could not process. Using a proper Pydantic model resolves this.

Fix TypeError: argument of type 'bool' is not iterable when launching
the Gradio weather agent UI.

Changes:
- Replace dict[str, Any] return type with WeatherResponse Pydantic model
  in get_weather tool to avoid boolean additionalProperties in JSON schema
- Add monkey patch for Gradio's JSON schema parser to handle boolean
  additionalProperties gracefully
- Remove explicit type hints from Gradio callback functions to avoid
  schema introspection issues
- Add api_name=False to submit handler to disable API generation
- Remove unused typing.Any import

The issue was caused by dict[str, Any] generating a JSON schema with
additionalProperties: true (boolean), which Gradio's schema parser
could not process. Using a proper Pydantic model resolves this.
) from e

# Monkey patch to fix Gradio's JSON schema parser for boolean additionalProperties
_original_json_schema_to_python_type = gradio_utils._json_schema_to_python_type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be fixed in Gradio instead?

If using a BaseModel fixes it, we don't need this here right?

@github-actions
Copy link

This PR is stale, and will be closed in 3 days if no reply is received.

@github-actions github-actions bot added the Stale label Oct 23, 2025
@DouweM DouweM removed the Stale label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants