Repository navigation
fix: use RetrievalModel type for retrieval_model field in HitTestingPayload - #33750
asukaminato0721 merged 2 commits into
Conversation
…ayload Previously, retrieval_model was typed as dict[str, Any] | None, which caused Flask-RESTX to generate incorrect Swagger documentation where the 'weights' field (a nested WeightModel object) was shown as a primitive float instead of its correct object structure. Changed to use the structured RetrievalModel Pydantic model, consistent with DatasetCreatePayload and DatasetUpdatePayload. Pydantic's model_dump(exclude_none=True) in parse_args correctly serializes the nested model to dict, so downstream behavior is unchanged.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where the OpenAPI (Swagger) documentation for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Pyrefly DiffNo changes detected. |
There was a problem hiding this comment.
Code Review
This pull request correctly updates the retrieval_model field in HitTestingPayload from a generic dict[str, Any] | None to the more specific RetrievalModel | None. This change is crucial for enabling Flask-RESTX's Swagger documentation generator to produce an accurate OpenAPI schema, particularly for nested fields like weights. The addition of the RetrievalModel import is also correctly handled. The change aligns with the stated problem and fix, improving type clarity and API documentation accuracy without altering existing runtime behavior, as model_dump correctly serializes the RetrievalModel to a dictionary for downstream services.
After changing retrieval_model from dict[str, Any] to RetrievalModel, update test fixtures to supply the required fields (search_method, reranking_enable, score_threshold_enabled) and use the correct enum value 'semantic_search' instead of 'semantic'.
Pyrefly DiffNo changes detected. |
Problem
HitTestingPayload.retrieval_modelwas typed asdict[str, Any] | None:This caused Flask-RESTX's Swagger documentation generator to emit an incorrect schema for the
weightsfield. Sincedict[str, Any]carries no structural information, the generated OpenAPI schema describedweightsas a primitivefloatrather than the actual nestedWeightModelobject:Fix
Changed
retrieval_modelinHitTestingPayloadfromdict[str, Any] | NonetoRetrievalModel | None, consistent withDatasetCreatePayloadandDatasetUpdatePayload.The existing
parse_argsbehavior is fully preserved: Pydantic'smodel_dump(exclude_none=True)correctly serializes the nestedRetrievalModelto a dict, so all downstream callers (e.g.HitTestingService.retrieve) receive the same structure as before.Affected Files
api/controllers/console/datasets/hit_testing_base.pyChange Summary