Skip to content

Commit

Permalink
chore: add json structure output
Browse files Browse the repository at this point in the history
  • Loading branch information
linux-china committed Aug 9, 2024
1 parent 37b4763 commit 5abf404
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions index.http
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,61 @@ Content-Type: application/json
}
}
]
}

### json structure output
POST https://api.openai.com/v1/chat/completions
Authorization: Bearer {{OPENAI_API_KEY}}
Content-Type: application/json

{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful Java language assistant."
},
{
"role": "user",
"content": "Write a simple JUnit 5 example."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "JavaExample",
"strict": true,
"schema": {
"type": "object",
"properties": {
"explanation": {
"type": "string",
"description": "The explanation for answer."
},
"answer": {
"type": "string",
"description": "The final answer."
},
"code": {
"type": "string",
"description": "The generated code within the answer."
},
"dependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "The dependencies for the generated code."
}
},
"required": [
"explanation",
"answer",
"code",
"dependencies"
],
"additionalProperties": false
}
}
}
}

0 comments on commit 5abf404

Please sign in to comment.