OpenAI API - could not parse JSON body of request

Hello!

I have two OpenAI API calls, 1 that feeds into the 2nd through a body parameter <apipt.1>, although I’m hitting the below issue:


Here is my 1st API call:

{
  "model": "gpt-4-0125-preview",
  "messages": [
    {
      "role": "system",
      "content": "[instructions]\\nPlease format your response in JSON and in the following structure: Write the task titles you're analyzing in bold and underlined.\\nProvide an analysis of the project or workflow, preceed this with an underscore.\\nThen detail your response under the following labels, each on a new line and bolded in BBCode: '_[your title]', 'Description:', '_Assignee:', 'Due Date:' (no earlier than <todaysdate>), 'Priority:', '~Task ID: ~<taskID>~'. Tag insights as 'Type: -Addition', and improvements as 'Type: -Improvements'. Separate each with a line break and a backslash.\\n[/instructions]"
    },
    {
      "role": "user",
      "content": "Analyze tasks in workspace <workspace> and project <project>, considering <tasktitle>, <assignee>, <description>, <Duedate>, <Status>, <priority>, <Taskgroup>, <boardmembers> and <jobrole>."
    }
  ],
  "temperature": 0.3,
  "max_tokens": 1000
}

And here is my 2nd API call which formats the first 1st call:

{
  "model": "ft:davinci-002:personal::8vBItY4G",
  "prompt": "Refine the analysis from <apipt.1> by strictly adhering to the detailed formatting and structural guidelines as outlined. Ensure the output matches the specified format to effectively address potential risks with actionable insights. Seperate each analysis with a line break and a backslash. Keep a very close eye on the use of underscores, tildes and backslashes, making sure you match their exact placement. Please apply the structural and formatting guidelines from the example to refine the initial analysis response <apipt.1>. The formatting must be exact, enhancing the analytical depth and insight into potential risks. Strictly adhere to the formatting guidelines, ensuring each task analysis is separated by a line break and backslash. The content should remain unchanged, except for formatting to meet the example's specifications.\n",
  "temperature": 0,
  "max_tokens": 256,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0
}

Is there something happening with the fact that my second API call is for a fine tuned davinci model and not a gpt4 model as is the first API call?
Please help! Any insight is appreciated!
Thanks

The issue you’re encountering is likely not due to the use of different models (davinci is just more fine tuned model). The error suggests that there’s a problem with the JSON format. In your case I would look into how you’re handling the <apipt.1> placeholder. Ensure that the output from the first call is valid JSON before using it in the second call.

Thanks for the repsonse.

In the first API call I prompted it to return its response in JSON format, and I’ve even added 'formatted as JSON-safe" to API#2’s workflow - still no luck though…

Any other ideas as to what’s going on? Any help is appreciated!
Thanks

So when I change the ‘format as JSON safe’ to ‘format as text’ the API call seems to complete, although the content is absolute nonsense and doesn’t include any data from the body parameter <apipt.1> …

Maybe it’s because you’re passing a list of messages to the parameter instead of one, but it’s tough to suggest anything here without seeing what the response is from the first API.

@mikolaj So in the first API prompt I instructed it to return in json, here’s one message from the results:

{
  "__Design website UI": {
    "Risk Analysis": "The task lacks clear deadlines and specific milestones, which can lead to delays and inefficiencies in project execution. Without set deadlines, it's challenging to prioritize this task against other project activities, potentially causing resource allocation issues.",
    "_Set Clear Milestones for UI Design": {
      "Description": "Define and document specific milestones within the UI design process, including wireframe completion, mockup approval, and final design handoff.",
      "_Assignee": "UI

Any help or insights are super appreciated! Thanks all!

It looks here like the response was suddenly stopped. You are missing end quotes and the assignee value was cut short. Are you hitting any limits on the number of tokens you are using? Perhaps modify your prompt in a way that makes sure it’s a valid JSON.

Following is how the JSON should look like:

{
  "__Design website UI": {
    "Risk Analysis": "The task lacks clear deadlines and specific milestones, which can lead to delays and inefficiencies in project execution. Without set deadlines, it's challenging to prioritize this task against other project activities, potentially causing resource allocation issues.",
    "_Set Clear Milestones for UI Design": {
      "Description": "Define and document specific milestones within the UI design process, including wireframe completion, mockup approval, and final design handoff.",
      "_Assignee": "UI Designer",
      "_someOtherField": "value"
    }
  }
}

You can check here if JSON is valid: https://jsonlint.com/

This topic was automatically closed after 70 days. New replies are no longer allowed.