Conversation
There was a problem hiding this comment.
⚠️ CI failed
Show all
| Platform | Name | Status | Details |
|---|---|---|---|
| All | Formatting | ❌ | Details |
| macOS | Build library | ✅ | Details |
| macOS | Build library (no default features) | ⏩ | Details |
| macOS | Build binaries | ✅ | Details |
| macOS | Build tests | ✅ | Details |
| macOS | Build examples | ✅ | Details |
| macOS | Run tests | ✅ | Details |
| macOS | Run doctests | ✅ | Details |
| Linux | Build library | ✅ | Details |
| Linux | Build library (no default features) | ⏩ | Details |
| Linux | Build binaries | ✅ | Details |
| Linux | Build tests | ✅ | Details |
| Linux | Build examples | ✅ | Details |
| Linux | Run tests | ✅ | Details |
| Linux | Run doctests | ✅ | Details |
| Windows | Build library | ✅ | Details |
| Windows | Build library (no default features) | ⏩ | Details |
| Windows | Build binaries | ✅ | Details |
| Windows | Build tests | ✅ | Details |
| Windows | Build examples | ✅ | Details |
| Windows | Run tests | ✅ | Details |
| Windows | Run doctests | ✅ | Details |
=============================================
| Platform | Name | Status | Details |
|---|---|---|---|
| All | Formatting | ❌ | Details |
|
@race-of-sloths score 5 |
|
@oleksandrvoyager Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: executed
Your contribution is much appreciated with a final score of 5! @artob received 25 Sloth Points for reviewing and scoring this pull request. What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for specifying a GBNF grammar file to constrain model decoding via the -g flag. The implementation removes the bon builder pattern dependency in favor of a simpler struct initialization approach.
Key changes:
- Added
-g/--grammarCLI option to specify GBNF grammar files - Added grammar field to Options struct with file reading logic
- Removed
bondependency and its builder pattern - Added documentation showing GBNF usage example
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/prompter/main.rs | Added CLI options for grammar, input, and output files; implemented grammar file reading |
| src/lib.rs | Removed bon builder, added grammar field to Options struct, modified request to include grammar parameter |
| Cargo.toml | Removed bon dependency |
| Cargo.lock | Removed bon and related transitive dependencies |
| README.md | Added GBNF grammar usage example with documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if let Value::Object(obj) = &mut req { | ||
| obj.insert("grammar".into(), Value::String(g.clone())); | ||
| } |
There was a problem hiding this comment.
[nitpick] The json! macro creates an immutable Value, but you're attempting to mutate it. The let mut req declaration is necessary, but the pattern match on line 32 is checking the type unnecessarily since json!({...}) always produces a Value::Object.
Consider simplifying to:
let mut req = json!({
"model": options.model,
"messages": [{ "role": "user", "content": input.as_ref() }],
"stream": false
});
if let Some(g) = &options.grammar {
req["grammar"] = Value::String(g.clone());
}This is cleaner and avoids the unnecessary type check.
| if let Value::Object(obj) = &mut req { | |
| obj.insert("grammar".into(), Value::String(g.clone())); | |
| } | |
| req["grammar"] = Value::String(g.clone()); |
#1