You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. I have searched related issues but cannot get the expected help.
2. The bug has not been fixed in the latest version.
3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
5. Please use English, otherwise it will be closed.
Describe the bug
When multiple requests hit SGlang's chat completions endpoint and one of them has a JSON schema and the other one doesn't, the one without a schema will output some random tokens, if there are multiple JSON schemas, at least one of them will get cutoff or overflow. Outlines backend works fine.
Reproduction
Run sglang openai server on localhost:30000 with any model with --grammar-backend xgrammar
asyncfunctionfetchChatCompletions(){constendpoint="http://localhost:30000/v1/chat/completions";constheaders={"Content-Type": "application/json","Authorization": "Bearer YOUR_API_KEY"};constquestion="Can you provide a detailed plan for building a sustainable city including energy, transportation, and waste management systems?";constschemas=[null,// No schema for the first request{type: "object",properties: {energy: {type: "string"},transportation: {type: "string"},wasteManagement: {type: "string"}},required: ["energy","transportation","wasteManagement"]},{type: "object",properties: {urbanPlanning: {type: "string"},sustainability: {type: "string"},publicServices: {type: "string"}},required: ["urbanPlanning","sustainability","publicServices"]}];constrequests=schemas.map(schema=>({model: "local",messages: [{role: "user",content: question}],
...(schema&&{response_format: {type: "json_schema",json_schema: {name: "city_plan",strict: true, schema }}})}));try{const[res1,res2,res3]=awaitPromise.all(requests.map(req=>fetch(endpoint,{method: "POST", headers,body: JSON.stringify(req)})));console.log("Response 1:",awaitres1.json());console.log("Response 2:",awaitres2.json());console.log("Response 3:",awaitres3.json());}catch(error){console.error("Error:",error);}}fetchChatCompletions();
Checklist
Describe the bug
When multiple requests hit SGlang's chat completions endpoint and one of them has a JSON schema and the other one doesn't, the one without a schema will output some random tokens, if there are multiple JSON schemas, at least one of them will get cutoff or overflow. Outlines backend works fine.
Reproduction
--grammar-backend xgrammar
Environment
The text was updated successfully, but these errors were encountered: