Skip to content

Commit 12ea8d7

Browse files
drbhaW3st
andauthored
Pr 2982 ci branch (#3046)
* Add json_schema alias for GrammarType * Add tests for all aliases * fix: various linter adjustments * fix: end-of-file-fixer lint * fix: add test snapshots and avoid docs change * fix: another end-of-file-fixer lint * feat: support json_schema grammar constraining and add tests * fix: bump openapi doc with new grammar option * fix: adjust test payload * fix: bump test snaps --------- Co-authored-by: Alex Weston <[email protected]>
1 parent 6afe430 commit 12ea8d7

File tree

11 files changed

+1169
-17
lines changed

11 files changed

+1169
-17
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
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"choices": [
3+
{
4+
"finish_reason": "stop",
5+
"index": 0,
6+
"logprobs": null,
7+
"message": {
8+
"content": "{ \"unit\": \"fahrenheit\", \"temperature\": [ 72, 79, 88 ] }",
9+
"role": "assistant"
10+
}
11+
}
12+
],
13+
"created": 1740095072,
14+
"id": "",
15+
"model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
16+
"object": "chat.completion",
17+
"system_fingerprint": "3.1.1-dev0-native",
18+
"usage": {
19+
"completion_tokens": 29,
20+
"prompt_tokens": 135,
21+
"total_tokens": 164
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"choices": [
3+
{
4+
"finish_reason": "stop",
5+
"index": 0,
6+
"logprobs": null,
7+
"message": {
8+
"content": "{ \"unit\": \"fahrenheit\", \"temperature\": [ 72, 79, 88 ] }",
9+
"role": "assistant"
10+
}
11+
}
12+
],
13+
"created": 1740095073,
14+
"id": "",
15+
"model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
16+
"object": "chat.completion",
17+
"system_fingerprint": "3.1.1-dev0-native",
18+
"usage": {
19+
"completion_tokens": 29,
20+
"prompt_tokens": 135,
21+
"total_tokens": 164
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"choices": [
3+
{
4+
"finish_reason": "stop",
5+
"index": 0,
6+
"logprobs": null,
7+
"message": {
8+
"content": "{\"firstName\":\"David\",\"lastName\":\"(Not provided)\",\"hobby\":\", nature\",\"numCats\":2}",
9+
"role": "assistant"
10+
}
11+
}
12+
],
13+
"created": 1746053368,
14+
"id": "",
15+
"model": "google/gemma-3-4b-it",
16+
"object": "chat.completion",
17+
"system_fingerprint": "3.2.3-dev0-native",
18+
"usage": {
19+
"completion_tokens": 35,
20+
"prompt_tokens": 32,
21+
"total_tokens": 67
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"choices": [
3+
{
4+
"finish_reason": "stop",
5+
"index": 0,
6+
"logprobs": null,
7+
"message": {
8+
"content": "{\"name\":\"John Smith\",\"age\":30,\"address\":{\"street\":\"Maple Street\",\"city\":\"Boston\"},\"hobbies\":[\"botany\",\"astronomy\",\"solving mathematical puzzles\"]}",
9+
"role": "assistant"
10+
}
11+
}
12+
],
13+
"created": 1746053373,
14+
"id": "",
15+
"model": "google/gemma-3-4b-it",
16+
"object": "chat.completion",
17+
"system_fingerprint": "3.2.3-dev0-native",
18+
"usage": {
19+
"completion_tokens": 44,
20+
"prompt_tokens": 37,
21+
"total_tokens": 81
22+
}
23+
}

0 commit comments

Comments
 (0)