-
Notifications
You must be signed in to change notification settings - Fork 418
Move template grammar to GBNF crate #1119
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
📝 WalkthroughWalkthroughThis change refactors grammar handling across the codebase by replacing static grammar files and string-based selection with a new serializable Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Editor UI
participant Desktop as Desktop App
participant Template as Template Plugin
participant LLM as Local LLM Provider
UI->>Desktop: Trigger Enhance Mutation
Desktop->>Template: Fetch Template (with ID)
Template-->>Desktop: Return Template Object
Desktop->>LLM: streamText({ grammar: Grammar { task: "enhance", sections } })
LLM->>Desktop: Generate Enhanced Content (using built grammar)
Desktop-->>UI: Display Enhanced Content
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)error: failed to load source for dependency Caused by: Caused by: Caused by: 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (8)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
crates/gbnf/src/lib.rs (1)
175-177: Remove or fix the commented test assertion.The test has a commented assertion that should either be removed or fixed.
let _gbnf = gbnf_validator::Validator::new().unwrap(); -// assert!(gbnf.validate(ENHANCE_AUTO, input_1).unwrap());If the test is needed, update it to use the new grammar system:
-let _gbnf = gbnf_validator::Validator::new().unwrap(); -// assert!(gbnf.validate(ENHANCE_AUTO, input_1).unwrap()); +let gbnf = gbnf_validator::Validator::new().unwrap(); +let grammar = Grammar::Enhance { sections: None }; +assert!(gbnf.validate(&grammar.build(), input_1).unwrap());
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (12)
apps/desktop/src/components/editor-area/index.tsx(4 hunks)crates/gbnf/Cargo.toml(1 hunks)crates/gbnf/assets/enhance-hypr.gbnf(0 hunks)crates/gbnf/assets/enhance-other.gbnf(0 hunks)crates/gbnf/assets/tags.gbnf(0 hunks)crates/gbnf/assets/title.gbnf(0 hunks)crates/gbnf/src/lib.rs(3 hunks)crates/llama/src/lib.rs(1 hunks)plugins/local-llm/src/server.rs(1 hunks)plugins/template/Cargo.toml(1 hunks)plugins/template/js/bindings.gen.ts(1 hunks)plugins/template/src/lib.rs(1 hunks)
💤 Files with no reviewable changes (4)
- crates/gbnf/assets/tags.gbnf
- crates/gbnf/assets/title.gbnf
- crates/gbnf/assets/enhance-hypr.gbnf
- crates/gbnf/assets/enhance-other.gbnf
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".
**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
plugins/template/src/lib.rsplugins/template/js/bindings.gen.tsplugins/local-llm/src/server.rscrates/llama/src/lib.rsapps/desktop/src/components/editor-area/index.tsxcrates/gbnf/src/lib.rs
🧬 Code Graph Analysis (4)
plugins/template/src/lib.rs (1)
plugins/template/js/bindings.gen.ts (1)
Grammar(28-28)
plugins/local-llm/src/server.rs (1)
plugins/template/js/bindings.gen.ts (1)
Grammar(28-28)
crates/llama/src/lib.rs (1)
plugins/template/js/bindings.gen.ts (1)
Grammar(28-28)
apps/desktop/src/components/editor-area/index.tsx (1)
plugins/template/js/bindings.gen.ts (1)
Grammar(28-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: ci (windows, windows-latest)
- GitHub Check: ci (macos, macos-latest)
- GitHub Check: ci
🔇 Additional comments (7)
crates/gbnf/Cargo.toml (1)
6-8: LGTM! Dependencies correctly added for Grammar enum serialization.The
serdeandspectadependencies with derive features are properly configured to support the new serializableGrammarenum functionality.plugins/template/Cargo.toml (1)
18-18: LGTM! Dependency correctly added for Grammar enum integration.The
hypr-gbnfdependency enables the template plugin to use the newGrammartypes, aligning with the refactoring objectives.plugins/template/src/lib.rs (1)
32-32: LGTM! Grammar type properly registered for TypeScript bindings.The
.typ::<hypr_gbnf::Grammar>()registration enables tauri-specta to generate the corresponding TypeScript types, ensuring type safety across the Rust-TypeScript boundary.crates/llama/src/lib.rs (1)
394-394: LGTM! Grammar construction correctly updated to new API.The change from
hypr_gbnf::GBNF::EnhanceOther.build()tohypr_gbnf::Grammar::Enhance { sections: None }.build()properly reflects the refactoring to the new parameterized Grammar enum.plugins/template/js/bindings.gen.ts (1)
28-28: LGTM! TypeScript Grammar type correctly mirrors Rust enum structure.The discriminated union properly represents the three grammar variants with appropriate typing for the
sectionsfield in theenhancevariant.apps/desktop/src/components/editor-area/index.tsx (2)
285-297: Clean refactoring of template retrieval logic.The extraction of template retrieval into the
getTemplatefunction improves readability and maintains consistent null handling.
358-362: Proper type-safe grammar metadata implementation.The use of the
Grammartype withsatisfiesensures type safety while maintaining the correct structure for the enhance task.
No description provided.