Skip to content

Use model key presence when resolving get defaults - #777

Open
shayanxcyber wants to merge 1 commit into
ollama:mainfrom
shayanxcyber:fix/model-get-defaults
Open

shayanxcyber wants to merge 1 commit into
ollama:mainfrom
shayanxcyber:fix/model-get-defaults

Conversation

@shayanxcyber

Copy link
Copy Markdown

For Message(role='user'), message['content'] raises KeyError, but message.get('content', '') returns None. A non-field name such as model_dump also returns the model's method rather than the fallback.

Use the same key-presence check as indexing. Explicit None and empty strings still retain their values, and model defaults such as Tool.type remain available.

This also makes the fallback used by the chat and generate logprobs examples work when the response omits logprobs.

The mapping tests and type doctests pass (10 tests), as do Ruff checks and formatting. A broader serialization run had 28 passes and two temporary-file failures on Windows; both failing tests also fail at the base revision.

This branch has not been deployed

No deployments
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.

1 participant