Skip to content

client: accept Enum classes as structured output formats - #753

Open
WitBlue6 wants to merge 1 commit into
ollama:mainfrom
WitBlue6:feat/enum-structured-output-format
Open

WitBlue6 wants to merge 1 commit into
ollama:mainfrom
WitBlue6:feat/enum-structured-output-format

Conversation

@WitBlue6

Copy link
Copy Markdown

Summary

Allow a Python Enum class as the format argument for chat and generate, in both synchronous and asynchronous clients. The request model converts the enum to its JSON Schema with Pydantic TypeAdapter before serialization. Existing string and mapping formats remain unchanged.

Closes #496.

Tests

  • Added request-level tests for sync/async chat and generate, asserting that the JSON sent to Ollama contains the enum schema.
  • pytest tests/test_client.py -k "not connection_error": 76 passed, 2 deselected. The two existing localhost connection-error tests receive HTTP 502 from the current environment's proxy.
  • ruff check and ruff format --check pass for all changed files.

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.

Simple Enums missing from structured outputs

1 participant