[Rust Frontend] Replay roundtrip output grammars through XGrammar (#59143)
Signed-off-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fcd317cf33
commit
87228cff01
@@ -5,6 +5,7 @@
|
||||
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_with::{DeserializeFromStr, SerializeDisplay};
|
||||
use thiserror::Error;
|
||||
use xgrammar_structural_tag::builders::{StructuralTagBuilder, StructuralTagOptions};
|
||||
@@ -20,7 +21,8 @@ use crate::tool::Tool;
|
||||
pub type Result<T> = std::result::Result<T, OutputGrammarError>;
|
||||
|
||||
/// How much of the generated stream an output grammar covers.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GrammarCoverage {
|
||||
/// The grammar covers reasoning and advances from the first generated token.
|
||||
FromTokenZero,
|
||||
@@ -29,7 +31,7 @@ pub enum GrammarCoverage {
|
||||
}
|
||||
|
||||
/// One parser-built output grammar and its generated-stream coverage.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
pub struct BuiltOutputGrammar {
|
||||
/// Typed XGrammar structural-tag format.
|
||||
pub format: Format,
|
||||
|
||||
Reference in New Issue
Block a user