-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I asked the to return the response in JSON type in the chatGPT prompt. But it returns always in a raw_text manner inside {"message":{"role":"assistant","content":
How can I ask/make the actual response inside {"message":{"role":"assistant","content":
as JSON object instead of simple strings
To Reproduce
curl --location --insecure --request POST 'https://api.openai.com/v1/chat/completions' --header 'Authorization: Bearer token' --header 'Content-Type: application/json' --data-raw '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "What is the OpenAI mission?Put the result in JSON format"}]
}'
It returns output as
{"id":"chatcmpl-6wpbfhG1c0k0D4d74mhdwBWf66APk","object":"chat.completion","created":1679479419,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":19,"completion_tokens":131,"total_tokens":150},"choices":[{"message":{"role":"assistant","content":"\n\n{\n \"mission\": \"The mission of OpenAI is to ensure that artificial intelligence (AI) benefits humanity as a whole, and to create and advance AI in a way that is safe and beneficial for everyone.\",\n \"focus_areas\": [\n \"Developing and advancing cutting-edge AI technologies\",\n \"Conducting research in AI safety and ethics\",\n \"Promoting responsible AI development and deployment\",\n \"Advocating for policy changes that support the safe and ethical development of AI\"\n ],\n \"values\": [\n \"Collaboration\",\n \"Transparency\",\n \"Responsibility\",\n \"Impact\"\n ]\n}"},"finish_reason":"stop","index":0}]}
The content is still in string format not json
Code snippets
No response
OS
Ubuntu
Python version
Python3.9
Library version
openai==0.27.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working