Skip to content

Conversation

@Ki-Seki
Copy link
Member

@Ki-Seki Ki-Seki commented Nov 10, 2025

Fixes #52

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Ki-Seki Ki-Seki requested a review from Copilot November 10, 2025 12:23
Copy link
Contributor

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 PR adds support for custom CFG (Context-Free Grammar) definitions to MaskedTag, allowing users to specify structured generation constraints beyond regex patterns. The implementation ensures that only one constraint type (regex or grammar) can be used per tag and validates grammar syntax against LLGuidance specifications.

Key changes:

  • Added grammar field to MaskedTag with mutual exclusivity with regex
  • Implemented grammar validation in MaskedTag.__post_init__ to ensure proper syntax and prevent reserved rule name conflicts
  • Updated build_cfg to handle tags with custom grammars by removing the start: prefix and embedding the rules

Reviewed Changes

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

Show a summary per file
File Description
src/gimkit/schemas.py Added grammar field to MaskedTag dataclass and implemented validation logic including empty string checks, reserved name conflicts, start rule requirement, and syntax validation
src/gimkit/dsls.py Refactored grammar validation into standalone function, added constants for CFG rule naming and docs URL, updated build_cfg to handle tags with custom grammar by stripping start: prefix
tests/test_schemas.py Added tests for grammar validation including empty string, reserved names, missing start rule, and invalid syntax; updated global variable assertions to include grammar field
tests/test_dsls.py Updated test expectations to use new masked_tag_ prefix and added test case for building CFG with custom grammar
tests/models/test_utils.py Updated assertion to expect new masked_tag_ rule naming convention

@Ki-Seki Ki-Seki changed the title feat: add grammar support to MaskedTag and update related functionality feat: add llguidance grammar support to MaskedTag and update related functionality Nov 10, 2025
@Ki-Seki Ki-Seki requested a review from Copilot November 10, 2025 12:55
Copy link
Contributor

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

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.

feat: support llguidance grammar in MaskedTag and guide

2 participants