Skip to content

Conversation

@heyitsaamir
Copy link
Collaborator

Had a bug where if you specified the function parameters as a Dict (and not a pydantic model), then the Dynamic model wouldn't correctly build the parameters. The fix was pretty simple - allowing "extra". Also added some unit tests.

Copilot AI review requested due to automatic review settings October 16, 2025 23:57
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 PR fixes a bug where function parameters specified as dictionaries (rather than Pydantic models) couldn't be properly handled when creating dynamic models for parsing. The fix allows dynamic models to accept arbitrary fields using Pydantic's extra="allow" configuration.

Key changes:

  • Added ConfigDict(extra="allow") to dynamic model creation to handle empty or arbitrary parameter dictionaries
  • Updated type hints from Function[BaseModel] to Function[Any] to better reflect the actual usage
  • Added comprehensive unit tests covering various parameter schema scenarios including the specific bug case

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/openai/src/microsoft/teams/openai/function_utils.py Fixed dynamic model creation to allow extra fields and updated type hints
packages/openai/tests/test_function_utils.py Added comprehensive test suite covering all parameter schema scenarios and edge cases

@heyitsaamir heyitsaamir changed the title Fix Empty Function Params Fix construction of DynamicBaseModel if the parameter schema is a dict Oct 17, 2025
@heyitsaamir heyitsaamir merged commit eb1284e into main Oct 17, 2025
7 of 8 checks passed
@heyitsaamir heyitsaamir deleted the aamirj/fixEmptyParams branch October 17, 2025 23:39
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.

4 participants