From 5abf40473320abbdaf364fe939e05449eeaaa796 Mon Sep 17 00:00:00 2001 From: Libing Chen Date: Fri, 9 Aug 2024 11:25:45 +0800 Subject: [PATCH] chore: add json structure output --- index.http | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/index.http b/index.http index 22a9308..550527b 100644 --- a/index.http +++ b/index.http @@ -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 + } + } + } } \ No newline at end of file