Skip to content

Conversation

@adityagesh
Copy link
Contributor

Refactor get_weather function to use Pydantic for parameter validation. LLM does not pass the name of the city if the parameter description is not provided.

@adityagesh adityagesh requested a review from a team as a code owner January 23, 2026 05:31
Copilot AI review requested due to automatic review settings January 23, 2026 05:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the get_weather tool example in the documentation to use Pydantic models with Field descriptions for parameter validation. The change addresses an issue where LLMs do not properly pass the city parameter when parameter descriptions are not provided, as Field descriptions become part of the JSON schema exposed to the LLM.

Changes:

  • Added Pydantic BaseModel import and Field import to the Python example
  • Created a GetWeatherParams class with a city field that includes a description
  • Updated the get_weather function signature to accept GetWeatherParams instead of dict
  • Changed parameter access from dictionary-style (params["city"]) to attribute-style (params.city)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Refactor get_weather function to use Pydantic for parameter validation.
LLM does not reliably pass the name of the city if the parameter description is not provided.
@friggeri friggeri added this pull request to the merge queue Jan 23, 2026
Merged via the queue into github:main with commit 8b70d1d Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants