I am trying to use json format to get json response, it worked well when I give same short example, but when I use production data to test it, prompt_token = 2966, then it start to response with all “\n \n \n \n”, till max token. Then, I use the same prompt without response_format, it worked well though it’s not a json object.
(test with a another shorter user message still failed, is that the “#” matter?)
model: gpt-1106
usingAzure: True
To Reproduce
tsg = """
# TSG for debugging openai
## 1. install openai
### 1.1. install openai with pip
### 1.2. install openai with conda
## 2. import openai
### 2.1. import openai in python
### 2.2. import openai in jupyter notebook
## 3. use openai
### 3.1. use openai in python
### 3.2. use openai in jupyter notebook
"""
messages = [
{
"role": "system",
"content":
"""
You are an expert of reading troubeshooting guidance.
The users will provide you a troubleshooting guide in markdown format, which consists of several steps.
You need to break down the document into steps based on the text semantics and markdown structure and return JSON format
Note that: (1) Ignore the document title if it does not indicate a step. (2) Only do text slicing from front to back, can't lose any content of the step. (3) Maintain the original text in task_description without any summarization or abbreviation. (4) Don't lose the prefix and serial number of the title displayed in the document. (5) If the step itself has a title in document, the task_title should use the original content.
You will respond with the list of steps as a JSON object. Here's an example of your output format:
[{
"task_title": "",
"task_description": "",
},
{
"task_title": "",
"task_description": "",
}].
Here is an example of the input markdown document:
# Troubleshooting guide for buying a puppy
## 1. know what puppy you want
### 1.1. you could surf the internet to find the puppy you want
### 1.2. visit friends who have puppies to see if you like them
## 2. buy healthy puppies
### 2.1. you could go to puppy selling websites to find healthy puppies, if you prefer buying puppies online, please go to step 3 for more information
### 2.2. you could go to pet stores to find healthy puppies
## 3. buy puppies online
here is a list of puppy selling websites: www.happydog.com, www.puppy.com, www.puppylove.com
Here is an example of the output json object:
[{
"task_title": "1. know what puppy you want",
"task_description": "### 1.1. you could surf the internet to find the puppy you want\n### 1.2. visit friends who have puppies to see if you like them"
},
{
"task_title": "2. buy healthy puppies",
"task_description": "### 2.1. you could go to puppy selling websites to find healthy puppies, if you prefer buying puppies online, please go to step 3 for more information\n### 2.2. you could go to pet stores to find healthy puppies"
},
{
"task_title": "3. buy puppies online",
"task_description": "here is a list of puppy selling websites: www.happydog.com, www.puppy.com, www.puppylove.com"
}
]
"""
},
{
"role": "user",
"content": tsg
}
]
response = llm.client.chat.completions.create(
model = llm.engine,
messages = messages,
response_format={"type": "json_object"},
temperature = 0,
)```