Skip to content

Commit 54b4e7f

Browse files
committed
Allow the guide to consume the eos_token
1 parent af7426f commit 54b4e7f

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ next_allowed_tokens = guide.advance(allowed_tokens[-1])
135135

136136
# To check if Guide is finished:
137137
guide.is_finished()
138-
139-
# If it's finished then this assertion holds:
140-
assert guide.get_tokens() == [vocabulary.get_eos_token_id()]
141138
```
142139

143140
## How to contribute?

src/index.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ impl Index {
226226

227227
/// Returns transition state for a given state and token id or `None` otherwise.
228228
pub fn next_state(&self, state: &StateId, token_id: &TokenId) -> Option<StateId> {
229-
if token_id == &self.eos_token_id {
230-
return None;
231-
}
232229
Some(*self.transitions.get(state)?.get(token_id)?)
233230
}
234231

@@ -284,7 +281,7 @@ mod tests {
284281
assert_eq!(index.next_state(&initial_state, token_id), Some(state));
285282
assert!(index.is_final_state(&state));
286283

287-
assert_eq!(index.next_state(&state, &eos_token_id), None);
284+
assert_eq!(index.next_state(&state, &eos_token_id), Some(state));
288285
assert_eq!(index.next_state(&state, token_id), None);
289286
}
290287

src/json_schema/parsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a> Parser<'a> {
6565

6666
fn parse_empty_object(&mut self) -> Result<String> {
6767
// JSON Schema Spec: Empty object means unconstrained, any json type is legal
68-
let types = vec![
68+
let types = [
6969
json!({"type": "boolean"}),
7070
json!({"type": "null"}),
7171
json!({"type": "number"}),

0 commit comments

Comments
 (0)