Skip to content

Python: Fix Ollama settings issue with structured outputs - #12355 #12386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

xyang2013
Copy link

Issue heading:
Python: New Feature: OllamaChatPromptExecutionSettings does not support structured outputs #12355

Link:
#12355

@xyang2013 xyang2013 requested a review from a team as a code owner June 5, 2025 07:04
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Jun 5, 2025
@github-actions github-actions bot changed the title Fix Ollama settings issue with structured outputs - #12355 Python: Fix Ollama settings issue with structured outputs - #12355 Jun 5, 2025
@moonbox3
Copy link
Contributor

moonbox3 commented Jun 5, 2025

Hi @xyang2013, thanks for creating a PR for this. You'll want to make sure you properly set up your dev env so that you can install the pre-commit hooks. This will ensure that all checks have passed locally - like ruff and others. You can follow our setup guide here: https://github.com/microsoft/semantic-kernel/blob/main/python/DEV_SETUP.md#using-uv.

There are also some unit tests failing: https://github.com/microsoft/semantic-kernel/actions/runs/15460655067/job/43533345701?pr=12386#step:5:604. Please have a look, thank you.

@xyang2013
Copy link
Author

Thanks, @moonbox3. I’ll take a look at the documentation later.

Does that mean I need to update not only the Ollama settings file but also the associated unit tests?

@moonbox3
Copy link
Contributor

moonbox3 commented Jun 9, 2025

Thanks, @moonbox3. I’ll take a look at the documentation later.

Does that mean I need to update not only the Ollama settings file but also the associated unit tests?

If unit tests are not passing because of this change, then yes, they will need an update.

@xyang2013
Copy link
Author

Thanks @moonbox3. I spent some time setting up the environment and ran the following command:

uv run pytest tests/integration

It showed up many unrelated errors (not related to Ollama). Should I just focus on the ones related to the change?

@moonbox3
Copy link
Contributor

moonbox3 commented Jun 9, 2025

Thanks @moonbox3. I spent some time setting up the environment and ran the following command:

uv run pytest tests/integration

It showed up many unrelated errors (not related to Ollama). Should I just focus on the ones related to the change?

Please run the unit tests, not the integration tests.

@moonbox3
Copy link
Contributor

moonbox3 commented Jun 19, 2025

Hi @xyang2013, haven't seen a response from you in a bit. I've got a PR open that fixes this - we should still allow for Literal["json"] therefore:

format: Literal["json"] | dict[str, Any] | None = None

No tests are breaking.

@moonbox3 moonbox3 closed this Jun 19, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 19, 2025
### Motivation and Context

Ollama's execution settings currently only allow for `json` literal. We
also want to support structured outputs for models that support it.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

- Closes #12355
- Supersedes #12386

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants