Repository navigation
fix: resolve windows tempfile locking, tool schema generation, and add client improvements - #778
Open
SiddardhaShayini wants to merge 1 commit into
Open
SiddardhaShayini wants to merge 1 commit into
SiddardhaShayini wants to merge 1 commit into
Conversation
…d client improvements - Fix ollama#676: replace tempfile.NamedTemporaryFile with tmp_path in tests to prevent Windows file locking PermissionError - Fix ollama#733: guard ChatRequest.serialize_model against None tool functions and parameters - Fix ollama#735: filter *args and **kwargs in convert_function_to_tool and correctly map default parameter values - Preserve array items, enum, and in tool property generation - Preserve empty string content in _copy_messages - Add bearer token validation in AsyncClient.web_search and web_fetch to match Client - Add direct api_key support to BaseClient, Client, and AsyncClient - Add id and type fields to Message.ToolCall - Export public client methods in ollama.__all__ and add create_blob - Remove unused _as_path dead code in _client.py - Add CONTRIBUTING.md guide and new examples (web-fetch, context-manager)
This branch has not been deployed
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 of Changes
This pull request addresses cross-platform Windows test failures, fixes tool parameter schema generation bugs, and introduces quality-of-life client enhancements:
1. Bug Fixes
NamedTemporaryFilefile-locking (Fixes Tests fail on Windows due to NamedTemporaryFile locking behavior #676): Replacedtempfile.NamedTemporaryFile()in tests with pytest's standardtmp_pathfixture (matching existing tests liketest_client_chat_images) to avoid WindowsPermissionError: [Errno 13] Permission denied. All 8 previously failing Windows tests now pass.ChatRequest.serialize_modelagainst tools wherefunctionorparametersisNone.*args(VAR_POSITIONAL) and**kwargs(VAR_KEYWORD) inconvert_function_to_toolso arbitrary arguments are not exposed as required parameters.required.items(e.g.list[str]) andenum/$refon properties produced byconvert_function_to_tool._copy_messagesin_client.pyusingif v is not None:so empty content (content='') is retained.AsyncClient.web_searchandAsyncClient.web_fetchto matchClient._as_pathhelper function and unusedPathLikeimport from_client.py.2. Improvements & Features
api_keyargument: Added first-classapi_key: Optional[str] = Nonesupport directly toClient(..., api_key=...)andAsyncClient(..., api_key=...).Message.ToolCallenhancements: Addedid: Optional[str] = Noneandtype: Optional[str] = 'function'fields toMessage.ToolCall.__all__: Added public functions (chat,generate,embed, etc.) toollama.__all__and added module-levelcreate_blob = _client.create_blob.3. Documentation & Examples
CONTRIBUTING.mdwith development setup, testing, formatting, and PR submission guidelines.examples/web-fetch.pyandexamples/context-manager.py.README.mdandexamples/README.md.Verification
uvx hatch test: 133 / 133 tests passing.uv run ruff check .anduv run ruff format --check .(49 files clean).uv lock --check.