状态:JSON 语法有效
{
"type": "object",
"properties": {
"title": { "type": "string" },
"category": { "type": "string" },
"readMinutes": { "type": "integer" },
"isProductionReady": { "type": "boolean" },
"tags": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["title", "category", "readMinutes", "isProductionReady", "tags"],
"additionalProperties": false
}
结构化输出(Structured Outputs)在 Chrome Built-in AI 与 Gemini API 中的价值
传统正则解析大模型自由文本极易在边界场景崩溃。无论是浏览器端的 Chrome Prompt API(通过 responseConstraint 参数)还是云端 Gemini API(通过 responseSchema),传入严格的 JSON Schema 都能在解码阶段强制约束输出格式,让前端组件直接安全消费返回数据。