openai / openai-cookbook

Examples and guides for using the OpenAI API
https://cookbook.openai.com
MIT License
59.86k stars 9.54k forks source link

[SUPPORT] json_schema does not work #1403

Open luoweiwei0908 opened 2 months ago

luoweiwei0908 commented 2 months ago

when i using json_schema , sometimes it work, but most time it does not. Error msg like 'socket hang up'.

{ "model": "gpt-4o-2024-08-06", "messages": [ { "role": "user", "content": "您是一个专业的消费者定性研究分析师、请从研究员的角度用Chinese帮我写一份访问提纲。" } ] ,"response_format": { "type": "json_schema", "json_schema": { "name": "doc_response", "schema": { "type": "object", "properties": { "paragraphs": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "the id of this paragraph" }, "parent_id": { "type": "string", "description": "the parent id of this paragraph" }, "level": { "type": "integer", "description": "the indent level of this paragraph" }, "contentType": { "type": "string", "description": "the type of content, eg: HEAD, BODY", "enum": [ "HEAD", "BODY" ] }, "content": { "type": "string", "description": "the text of each row" }, "children": { "type": "array", "items": { "$ref": "#" } } } } } }, "required": [ "paragraphs" ], "additionalProperties": false } } } }

image

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.