Skip to main content

Structured Output

Structured output is an advanced feature that enables AI models to generate formatted, predictable response content. By using structured output, you can better control the format of AI output, making it more suitable for program processing and data analysis.

ConsoleX AI provides debugging functionality for structured output, currently supporting only OpenAI models.

Usage Method

1. Enable JSON Mode

When selecting an OpenAI model that supports structured output, click the more options icon in the top right corner to find the Enable JSON Mode toggle. After enabling it, you can also choose to attach a specific JSON Schema.

  • If attached, the large model will provide generation results according to the attached JSON Schema;
  • If not attached, the large model will generate corresponding results based on user question instructions. In this case, the user's instructions should clearly inform the model to output JSON-structured results (otherwise the model may report an error).

2. Define JSON Schema (Optional)

You can also define and use JSON Schema descriptions in conversations to more precisely instruct the model to generate JSON results with specific structures.

For the definition and usage of JSON Schema, refer to OpenAI's documentation on JSON schemas.

For example: Here's a JSON schema description example for describing the reasoning process of math problems:

{
"name": "math_response",
"strict": true,
"schema":
{
"type": "object",
"properties":
{
"steps":
{
"type": "array",
"items":
{
"type": "object",
"properties":
{
"explanation":
{
"type": "string"
},
"output":
{
"type": "string"
}
},
"required": ["explanation", "output"],
"additionalProperties": false
}
},
"final_answer":
{
"type": "string"
}
},
"required": ["steps", "final_answer"],
"additionalProperties": false
}
}

3. Ask the Large Model

Assuming the JSON Schema above has been attached to the conversation, here's an example question:

Solve the linear equations (2x + 3y = 6) and (x - y = 3)

The large model will provide generation results according to the JSON schema you provided. Here's an example response:

{
"steps": [
{
"explanation": "Step 1: Use substitution or elimination method to solve the system of equations.",
"output": "First step"
},
{
"explanation": "Step 2: From the second equation, solve for x: x = y + 3",
"output": "x = y + 3"
},
{
"explanation": "Step 3: Substitute x = y + 3 into the first equation: 2(y + 3) + 3y = 6",
"output": "2y + 6 + 3y = 6"
},
{
"explanation": "Step 4: Combine like terms: 5y + 6 = 6",
"output": "5y + 6 = 6"
},
{
"explanation": "Step 5: Solve for y by isolating the variable: 5y = 0",
"output": "y = 0"
},
{
"explanation": "Step 6: Substitute y = 0 into x = y + 3 to solve for x: x = 0 + 3",
"output": "x = 3"
}
],
"final_answer": "x = 3, y = 0"
}

Reference Documentation