Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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?

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.