0

I captured a JSON response from GPT-4 and saved it to a file named sample.json as can be seen here:

~/sandbox » cat sample.json                                                                                                                 
{"id":"chatcmpl-6zULJUpe6ENFKuVbsW5KWySa5oBPk","object":"chat.completion","created":1680112665,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":29,"completion_tokens":403,"total_tokens":432},"choices":[{"message":{"role":"assistant","content":"Player,Team,Position,Height,Weight,College,Salary,Points per game,Rebounds per game,Assists per game
LeBron James,Los Angeles Lakers,SF,6-9,250,Louisiana State University,39.2 million,25.0,7.8,10.6
Nikola Jokic,Denver Nuggets,C,7-0,284,N/A,29.5 million,26.5,10.9,8.4"},"finish_reason":"stop","index":0}]}

I am attempting to display the content portion on my CLI using the raw output flag:

~/sandbox » cat sample.json | jq -r '.choices[0].message.content'                                                                               
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 3, column 69

Is there something I can pass on the command line or to jq to resolve this issue? I have not modified the data that has come back from OpenAI's API.

oguz ismail
  • 1
  • 16
  • 47
  • 69
randombits
  • 47,058
  • 76
  • 251
  • 433

0 Answers0