Skip to content

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Feb 11, 2026

Resolves #27

@mattt mattt requested a review from Copilot February 11, 2026 14:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements guided generation (structured output) support for the OllamaLanguageModel, allowing it to generate responses conforming to Swift types annotated with @Generable, not just plain strings.

Changes:

  • Removed the String-only restriction that previously caused a fatal error for structured types
  • Added schema conversion and format parameter support to guide Ollama's output generation
  • Updated response parsing logic to handle both String and structured JSON responses in both streaming and non-streaming modes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Sources/AnyLanguageModel/Models/OllamaLanguageModel.swift Implements structured generation by converting GenerationSchema to JSONSchema format, passing it via the format parameter to Ollama API, and parsing JSON responses into structured types
Tests/AnyLanguageModelTests/OllamaLanguageModelTests.swift Adds test struct OllamaStructuredForecast and two tests (structuredResponse and streamingStructured) to verify structured generation works correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit a391cc7 into main Feb 11, 2026
3 checks passed
@mattt mattt deleted the mattt/ollama-guided-generation branch February 11, 2026 15:17
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.

@Generable & @Guide

1 participant