{"name":"template_schema","description":"A generic template for JSON Schema","strict":true,"schema": {"type":"object","properties": {"field1": {"type":"string","description":"Description of field1" },"field2": {"type":"number","description":"Description of field2" },"field3": {"type":"array","description":"Description of field3","items": {"type":"string" } },"field4": {"type":"object","description":"Description of field4","properties": {"subfield1": {"type":"string","description":"Description of subfield1" } },"required": ["subfield1"],"additionalProperties":false } },"required": ["field1","field2","field3","field4"],"additionalProperties":false }}
步骤指导:
定义基本信息:
设置 name:为你的 schema 起一个描述性的名称。
添加 description:简要说明 schema 的用途。
设置 strict: true:确保严格模式。
创建 schema 对象:
设置 type: "object":指定根级别为对象类型。
添加 properties 对象:用于定义所有字段。
定义字段:
为每个字段创建一个对象,包含 type 和 description。
常见类型:string, number, boolean, array, object。
对于数组,使用 items 定义元素类型。
对于对象,递归定义 properties。
设置约束:
在每个级别添加 required 数组,列出所有必需字段。
在每个对象级别设置 additionalProperties: false。
特殊字段处理:
使用 enum 限制可选值。
使用 $ref 实现递归结构。
示例
1. 推理链(常规)
JSON Schema 文件示例
{"name":"math_reasoning","description":"Records steps and final answer for mathematical reasoning","strict":true,"schema": {"type":"object","properties": {"steps": {"type":"array","description":"Array of reasoning steps","items": {"type":"object","properties": {"explanation": {"type":"string","description":"Explanation of the reasoning step" },"output": {"type":"string","description":"Output of the reasoning step" } },"required": ["explanation","output"],"additionalProperties":false } },"final_answer": {"type":"string","description":"The final answer to the mathematical problem" } },"additionalProperties":false,"required": ["steps","final_answer"] }}
提示词参考
You are a helpful math tutor. You will be provided with a math problem,
and your goal will be to output a step by step solution, along with a final answer.
For each step, just provide the output as an equation use the explanation field to detail the reasoning.
UI 生成器(根递归模式)
{"name":"ui","description":"Dynamically generated UI","strict":true,"schema": {"type":"object","properties": {"type": {"type":"string","description":"The type of the UI component","enum": ["div","button","header","section","field","form"] },"label": {"type":"string","description":"The label of the UI component, used for buttons or form fields" },"children": {"type":"array","description":"Nested UI components","items": {"$ref":"#" } },"attributes": {"type":"array","description":"Arbitrary attributes for the UI component, suitable for any element","items": {"type":"object","properties": {"name": {"type":"string","description":"The name of the attribute, for example onClick or className" },"value": {"type":"string","description":"The value of the attribute" } },"additionalProperties":false,"required": ["name","value"] } } },"required": ["type","label","children","attributes"],"additionalProperties":false } }
提示词参考:
You are a UI generator AI. Convert the user input into a UI.