Skip to content

Commit 4e4d2bc

Browse files
committed
fix: bump openapi doc with new grammar option
1 parent ec84721 commit 4e4d2bc

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

docs/openapi.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,24 @@
17711771
"type": "string"
17721772
}
17731773
}
1774+
},
1775+
{
1776+
"type": "object",
1777+
"required": [
1778+
"type",
1779+
"value"
1780+
],
1781+
"properties": {
1782+
"type": {
1783+
"type": "string",
1784+
"enum": [
1785+
"json_schema"
1786+
]
1787+
},
1788+
"value": {
1789+
"$ref": "#/components/schemas/JsonSchemaConfig"
1790+
}
1791+
}
17741792
}
17751793
],
17761794
"discriminator": {
@@ -1864,6 +1882,22 @@
18641882
}
18651883
}
18661884
},
1885+
"JsonSchemaConfig": {
1886+
"type": "object",
1887+
"required": [
1888+
"schema"
1889+
],
1890+
"properties": {
1891+
"name": {
1892+
"type": "string",
1893+
"description": "Optional name identifier for the schema",
1894+
"nullable": true
1895+
},
1896+
"schema": {
1897+
"description": "The actual JSON schema definition"
1898+
}
1899+
}
1900+
},
18671901
"Message": {
18681902
"allOf": [
18691903
{

router/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ struct JsonSchemaConfig {
208208
#[serde(skip_serializing_if = "Option::is_none")]
209209
name: Option<String>,
210210

211-
/// Whether to enforce strict validation (optional)
212-
#[serde(skip_serializing_if = "Option::is_none")]
213-
strict: Option<bool>,
214-
215211
/// The actual JSON schema definition
216212
schema: serde_json::Value,
217213
}
@@ -970,7 +966,7 @@ impl ChatRequest {
970966
let stop = stop.unwrap_or_default();
971967
// enable greedy only when temperature is 0
972968
let (do_sample, temperature) = match temperature {
973-
Some(temperature) if temperature == 0.0 => (false, None),
969+
Some(0.0) => (false, None),
974970
other => (true, other),
975971
};
976972

@@ -1033,7 +1029,7 @@ impl ChatRequest {
10331029
seed,
10341030
top_n_tokens: top_logprobs,
10351031
grammar,
1036-
adapter_id: model.filter(|m| *m != "tgi").map(String::from),
1032+
adapter_id: model.filter(|m| *m != "tgi"),
10371033
},
10381034
},
10391035
using_tools,

router/src/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::sagemaker::{
1212
};
1313
use crate::validation::ValidationError;
1414
use crate::vertex::vertex_compatibility;
15-
use crate::ChatTokenizeResponse;
1615
use crate::{
1716
usage_stats, BestOfSequence, Details, ErrorResponse, FinishReason, FunctionName,
1817
GenerateParameters, GenerateRequest, GenerateResponse, GrammarType, HubModelInfo,
@@ -27,6 +26,7 @@ use crate::{
2726
ChatRequest, Chunk, CompatGenerateRequest, Completion, CompletionComplete, CompletionFinal,
2827
CompletionRequest, CompletionType, DeltaToolCall, Function, Prompt, Tool,
2928
};
29+
use crate::{ChatTokenizeResponse, JsonSchemaConfig};
3030
use crate::{FunctionDefinition, HubPreprocessorConfig, ToolCall, ToolChoice};
3131
use crate::{MessageBody, ModelInfo, ModelsInfo};
3232
use async_stream::__private::AsyncStream;
@@ -723,7 +723,7 @@ pub(crate) async fn completions(
723723
let stop = stop.unwrap_or_default();
724724
// enable greedy only when temperature is 0
725725
let (do_sample, temperature) = match temperature {
726-
Some(temperature) if temperature == 0.0 => (false, None),
726+
Some(0.0) => (false, None),
727727
other => (true, other),
728728
};
729729

@@ -1528,6 +1528,7 @@ CompatGenerateRequest,
15281528
SagemakerRequest,
15291529
GenerateRequest,
15301530
GrammarType,
1531+
JsonSchemaConfig,
15311532
ChatRequest,
15321533
Message,
15331534
MessageContent,

router/src/validation.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ impl Validation {
395395
"Grammar must have a 'properties' field".to_string(),
396396
))?;
397397

398-
// TODO:
399-
// Apply strictness if specified
400-
let _strict = schema_config.strict.unwrap_or(false);
401-
402398
// Do compilation in the router for performance
403399
let grammar_regex = json_schema_to_regex(json, None, json)
404400
.map_err(ValidationError::RegexFromSchema)?;

0 commit comments

Comments
 (0)