Integrate logits processor with qwq (untested)

This commit is contained in:
Niels Geens
2025-04-07 13:35:20 +02:00
parent 023fc75aac
commit 50539f6d03
5 changed files with 101 additions and 33 deletions

View File

@@ -13,7 +13,7 @@ use token::*;
/// An XML validator that checks XML fragments against an XSD schema
#[derive(Clone, Debug)]
pub struct XmlValidator {
pub struct XmlSchemaValidator {
current_tokens: Vec<Box<Token>>,
}
@@ -22,7 +22,7 @@ pub struct XmlValidator {
/// This is a type alias for `std::result::Result` with our custom `Error` type
pub type Result<T> = std::result::Result<T, Error>;
impl XmlValidator {
impl XmlSchemaValidator {
/// Create a new validator with the given schema text
pub fn new(schema_text: &str) -> Result<Self> {
let schema: schema::XsSchema = quick_xml::de::from_str(schema_text)?;
@@ -66,7 +66,7 @@ mod tests {
fn test_element_open() {
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
let input = "<reasoning>";
let mut validator = XmlValidator::new(&schema_text).unwrap();
let mut validator = XmlSchemaValidator::new(&schema_text).unwrap();
validator.append(input).unwrap();
}
@@ -74,7 +74,7 @@ mod tests {
fn test_element_open_whitespace() {
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
let input = "<reasoning >";
let mut validator = XmlValidator::new(&schema_text).unwrap();
let mut validator = XmlSchemaValidator::new(&schema_text).unwrap();
validator.append(input).unwrap();
}
@@ -82,7 +82,7 @@ mod tests {
fn test_element_open_invalid_name() {
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
let input = "<rae";
let mut validator = XmlValidator::new(&schema_text).unwrap();
let mut validator = XmlSchemaValidator::new(&schema_text).unwrap();
validator.append(input).expect_err("Should fail");
}
@@ -90,7 +90,7 @@ mod tests {
fn test_element_close() {
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
let input = "<reasoning>test</reasoning>";
let mut validator = XmlValidator::new(&schema_text).unwrap();
let mut validator = XmlSchemaValidator::new(&schema_text).unwrap();
validator.append(input).unwrap();
}
@@ -98,7 +98,7 @@ mod tests {
fn test_element_close_mismatched() {
let schema_text = std::fs::read_to_string("../../action_schema.xsd").unwrap();
let input = "<reasoning>test</wrong>";
let mut validator = XmlValidator::new(&schema_text).unwrap();
let mut validator = XmlSchemaValidator::new(&schema_text).unwrap();
validator.append(input).expect_err("Should fail with mismatched closing tag");
}
}