diff --git a/docs/openapi.json b/docs/openapi.json index bcaa8bfd..502f3564 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1746,7 +1746,7 @@ "type": { "type": "string", "enum": [ - "json_schema" + "json" ] }, "value": { @@ -2406,4 +2406,4 @@ "description": "Hugging Face Text Generation Inference API" } ] -} +} \ No newline at end of file diff --git a/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.1.json b/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.1.json new file mode 100644 index 00000000..c4f804fc --- /dev/null +++ b/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.1.json @@ -0,0 +1,23 @@ +{ + "choices": [ + { + "finish_reason": "stop", + "index": 0, + "logprobs": null, + "message": { + "content": "{ \"unit\": \"fahrenheit\", \"temperature\": [ 72, 79, 88 ] }", + "role": "assistant" + } + } + ], + "created": 1740095072, + "id": "", + "model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0", + "object": "chat.completion", + "system_fingerprint": "3.1.1-dev0-native", + "usage": { + "completion_tokens": 29, + "prompt_tokens": 135, + "total_tokens": 164 + } +} diff --git a/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.2.json b/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.2.json new file mode 100644 index 00000000..1be656ee --- /dev/null +++ b/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.2.json @@ -0,0 +1,23 @@ +{ + "choices": [ + { + "finish_reason": "stop", + "index": 0, + "logprobs": null, + "message": { + "content": "{ \"unit\": \"fahrenheit\", \"temperature\": [ 72, 79, 88 ] }", + "role": "assistant" + } + } + ], + "created": 1740095073, + "id": "", + "model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0", + "object": "chat.completion", + "system_fingerprint": "3.1.1-dev0-native", + "usage": { + "completion_tokens": 29, + "prompt_tokens": 135, + "total_tokens": 164 + } +} diff --git a/router/src/lib.rs b/router/src/lib.rs index 48a8d606..e3b8aee9 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -223,8 +223,8 @@ pub(crate) enum GrammarType { /// /// JSON Schema is a declarative language that allows to annotate JSON documents /// with types and descriptions. - #[serde(rename = "json_schema")] - #[serde(alias = "json")] + #[serde(rename = "json")] + #[serde(alias = "json_schema")] #[serde(alias = "json_object")] #[schema(example = json ! ({"properties": {"location":{"type": "string"}}}))] Json(serde_json::Value),