Skip to content

feat(gemini): enforce JSON schema for structured AI output#68

Merged
thomas-vilte merged 3 commits intomasterfrom
dev
Dec 30, 2025
Merged

feat(gemini): enforce JSON schema for structured AI output#68
thomas-vilte merged 3 commits intomasterfrom
dev

Conversation

@thomas-vilte
Copy link
Owner

@thomas-vilte thomas-vilte commented Dec 30, 2025

Description

This PR migrates the Gemini AI provider to use native JSON schema enforcement for structured outputs. Previously, the JSON schema was defined within the prompt text, and the application relied on manual regex-based extraction and sanitization of the response. By utilizing the ResponseJsonSchema property in the Gemini API, we ensure type safety and valid JSON directly from the model, significantly reducing prompt token usage and improving reliability.

Fixes #68

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Unit tests: Updated commit_summarizer_service_test.go, helper_test.go, release_generator_test.go, and prompts_test.go to verify the new schema-driven logic.
  • Manual test: Verified that commit suggestions and PR summaries are correctly generated and parsed without the previous manual extraction logic.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

🧪 Test Plan & Evidence

Suggested Manual Verification

  • API/Backend: Attach JSON response or logs as evidence of correct behavior
  • Performance: Ensure no significant latency increase
  • Unit Tests: Run go test ./... and ensure all tests pass
  • No Regressions: Verify that related features still work as expected

@thomas-vilte thomas-vilte added feature New features refactor Code restructuring or cleaning without functional changes labels Dec 30, 2025
@thomas-vilte thomas-vilte merged commit 331e5d0 into master Dec 30, 2025
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features refactor Code restructuring or cleaning without functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant