mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-22 15:32:08 +00:00
fix: reject grammars without properties (#2309)
This commit is contained in:
parent
23a3927eb6
commit
a574381cb4
@ -353,6 +353,14 @@ impl Validation {
|
||||
.compile(&json)
|
||||
.map_err(|e| ValidationError::InvalidGrammar(e.to_string()))?;
|
||||
|
||||
// The schema can be valid but lack properties.
|
||||
// We need properties for the grammar to be successfully parsed in Python.
|
||||
// Therefore, we must check and throw an error if properties are missing.
|
||||
json.get("properties")
|
||||
.ok_or(ValidationError::InvalidGrammar(
|
||||
"Grammar must have a 'properties' field".to_string(),
|
||||
))?;
|
||||
|
||||
// Serialize json to string
|
||||
ValidGrammar::Json(
|
||||
serde_json::to_string(&json)
|
||||
|
Loading…
Reference in New Issue
Block a user