Skip to content

types: make ChatRequest serialization None-safe for tools without parameters - #755

Open
DeepanshuPal wants to merge 2 commits into
ollama:mainfrom
DeepanshuPal:fix-chatrequest-none-tools
Open

DeepanshuPal wants to merge 2 commits into
ollama:mainfrom
DeepanshuPal:fix-chatrequest-none-tools

Conversation

@DeepanshuPal

Copy link
Copy Markdown

ChatRequest.serialize_model assumed every serialized tool has a function with a parameters mapping. A Tool with no function, or a Function with no parameters, made model_dump() and model_dump_json() raise PydanticSerializationError unless exclude_none=True was passed. The serializer now skips tools that have no parameters, and the defs to $defs rename still applies when parameters is present. Adds tests for both cases. Fixes #733.

Note: an earlier fix (#736) was closed unmerged by its author; this is a fresh take with tests covering both missing function and missing parameters.

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.

ChatRequest.model_dump() crashes when a tool has no parameters or no function

1 participant