fix(types): make ShowResponse.model_info optional so cloud models without model_info parse (#607)#684
Open
Missing-Identity wants to merge 1 commit into
Conversation
…hout model_info parse (ollama#607) Co-authored-by: Unmilan Mukherjee <Missing-Identity@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #607.
ShowResponse.modelinfois annotatedOptional[Mapping[str, Any]]but declared withField(alias='model_info')and no default. In pydantic, a field with an alias and no default is still required at validation time, so any/api/showresponse that omitsmodel_inforaises:This is observed with several cloud models whose
/api/showpayload does not includemodel_info(e.g.glm-4.7:cloud,qwen3-next:80b-cloud,deepseek-v3.2:cloud), and it breaksollama.show()as well as downstream tools such asllm-ollama.Every other field on
ShowResponse(modified_at,template,modelfile,license,details,parameters,capabilities) already has a default and is therefore optional.modelinfois the only field that is accidentally required.Change
Giving the
Fielda default ofNonemakes the field truly optional, matching itsOptional[...]annotation and the rest of the model. The wire aliasmodel_infois unchanged, so responses that includemodel_infocontinue to populate.modelinfoexactly as before.Tests
Added two focused regression tests to
tests/test_type_serialization.py:test_show_response_missing_model_info— a payload withoutmodel_infonow validates and.modelinfo is None(other fields likecapabilities/templatestill parse).test_show_response_with_model_info— a payload withmodel_infostill populates.modelinfocorrectly.Full suite for the touched file:
ruffreportsAll checks passed!.Notes
This is a minimal, backwards-compatible change. No public API or wire format changes.