ollama / ollama/ollama-python

Simple Enums missing from structured outputs

Open
#496 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.5k
Forks
1.2k
Avg merge
4m
Merged PRs (30d)
1

Description

Structured outputs currently only support Pydantic models (which are very useful), but is presently missing support for simple Enums, and requires redundant wrapping into a Pydantic model.

I want to be able to perform queries such as:

class SomeEnum(Enum):
    SomeType: 'SomeType',
    AnotherType: 'AnotherType'

response = ollama.chat(
    model=..., 
    messages=...,
    format=SomeEnum)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how ollama.chat handles the format argument and how the existing Pydantic structured-output path is implemented. Add support for passing a simple Python Enum directly, then verify that structured responses are constrained to the Enum values and that the existing Pydantic behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.