From 65c6008847b466b5b673c91dccd90d19913619f9 Mon Sep 17 00:00:00 2001 From: drbh Date: Mon, 17 Mar 2025 14:51:33 +0000 Subject: [PATCH] fix: bump openapi doc with new grammar option --- docs/openapi.json | 34 ++++++++++++++++++++++++++++++++++ router/src/lib.rs | 4 ---- router/src/server.rs | 3 ++- router/src/validation.rs | 4 ---- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/docs/openapi.json b/docs/openapi.json index 85ca3f977..2d3a023a5 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1771,6 +1771,24 @@ "type": "string" } } + }, + { + "type": "object", + "required": [ + "type", + "value" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "json_schema" + ] + }, + "value": { + "$ref": "#/components/schemas/JsonSchemaConfig" + } + } } ], "discriminator": { @@ -1864,6 +1882,22 @@ } } }, + "JsonSchemaConfig": { + "type": "object", + "required": [ + "schema" + ], + "properties": { + "name": { + "type": "string", + "description": "Optional name identifier for the schema", + "nullable": true + }, + "schema": { + "description": "The actual JSON schema definition" + } + } + }, "Message": { "allOf": [ { diff --git a/router/src/lib.rs b/router/src/lib.rs index e1a9a839a..e1ee05415 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -222,10 +222,6 @@ struct JsonSchemaConfig { #[serde(skip_serializing_if = "Option::is_none")] name: Option, - /// Whether to enforce strict validation (optional) - #[serde(skip_serializing_if = "Option::is_none")] - strict: Option, - /// The actual JSON schema definition schema: serde_json::Value, } diff --git a/router/src/server.rs b/router/src/server.rs index 45d2b9f3c..1cf345460 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -13,7 +13,6 @@ use crate::sagemaker::{ }; use crate::validation::ValidationError; use crate::vertex::vertex_compatibility; -use crate::ChatTokenizeResponse; use crate::{ usage_stats, BestOfSequence, Details, ErrorResponse, FinishReason, FunctionName, GenerateParameters, GenerateRequest, GenerateResponse, GrammarType, HubModelInfo, @@ -28,6 +27,7 @@ use crate::{ ChatRequest, Chunk, CompatGenerateRequest, Completion, CompletionComplete, CompletionFinal, CompletionRequest, CompletionType, DeltaToolCall, Function, Prompt, Tool, }; +use crate::{ChatTokenizeResponse, JsonSchemaConfig}; use crate::{FunctionDefinition, HubPreprocessorConfig, ToolCall, ToolChoice}; use crate::{MessageBody, ModelInfo, ModelsInfo}; use async_stream::__private::AsyncStream; @@ -1339,6 +1339,7 @@ CompatGenerateRequest, SagemakerRequest, GenerateRequest, GrammarType, +JsonSchemaConfig, ChatRequest, Message, MessageContent, diff --git a/router/src/validation.rs b/router/src/validation.rs index 625a4bdcd..3068b14b8 100644 --- a/router/src/validation.rs +++ b/router/src/validation.rs @@ -396,10 +396,6 @@ impl Validation { "Grammar must have a 'properties' field".to_string(), ))?; - // TODO: - // Apply strictness if specified - let _strict = schema_config.strict.unwrap_or(false); - // Do compilation in the router for performance let grammar_regex = json_schema_to_regex(json, None, json) .map_err(ValidationError::RegexFromSchema)?;