Skip to content

types: expose prompt_eval_cached_count in BaseGenerateResponse (#779) - #780

Open
pfolex wants to merge 1 commit into
ollama:mainfrom
pfolex:fix/expose-prompt-eval-cached-count
Open

pfolex wants to merge 1 commit into
ollama:mainfrom
pfolex:fix/expose-prompt-eval-cached-count

Conversation

@pfolex

@pfolex pfolex commented Oct 24, 2026

Copy link
Copy Markdown

Summary

Fixes #779 (and #773).

Declares prompt_eval_cached_count: Optional[int] = None on BaseGenerateResponse so that prompt caching metrics returned by the Ollama server on /api/generate and /api/chat are preserved rather than silently dropped by Pydantic during response parsing.

Changes

  • In ollama/_types.py, added prompt_eval_cached_count to BaseGenerateResponse with docstring.
  • In tests/test_type_serialization.py, added unit test test_response_prompt_eval_cached_count.
  • In tests/test_client.py, added integration test test_client_chat_with_prompt_eval_cached_count.

Validation

  • All 119 unit tests pass in pytest tests/.
  • ruff check passes cleanly.

…a#779)

- Declare prompt_eval_cached_count: Optional[int] = None on BaseGenerateResponse so it is not dropped by Pydantic during parsing of generate and chat responses.
- Add unit tests for GenerateResponse and ChatResponse model serialization and client chat parsing.

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.

GenerateResponse/ChatResponse silently drop the server's prompt_eval_cached_count field

1 participant