It seems it doesn’t upload json file anymore.
I’ve always used this python method:
def file_upload(self,
file_name: str
) -> object:
"""
Upload a file to openai with given file_name
Parameters
----------
file : object
DESCRIPTION.
Returns
-------
object
DESCRIPTION.
"""
file = None
with open(file_name,'rb') as f:
try:
file = openai.files.create(
file=(os.path.basename(file_name),f),
purpose='assistants',
)
except Exception as e:
self.logger.error(e)
return file
But today it seems it accecpt only some json files.
ERROR 2024-01-02 10:38:42,182 Error code: 400 - {'error': {'message': "Invalid file format. Supported formats: ['c', 'cpp', 'csv', 'docx', 'html', 'java', 'json', 'md', 'pdf', 'php', 'pptx', 'py', 'rb', 'tex', 'txt', 'css', 'jpeg', 'jpg', 'js', 'gif', 'png', 'tar', 'ts', 'xlsx', 'xml', 'zip']", 'type': 'invalid_request_error', 'param': None, 'code': None}}
Same problem experienced on playground.
Why?
p.s.
Happy New Year everyone!!
EDIT:
i think it depends on how is json file formatted.
With a json like this:
{
"test":"test"
}
it doesn’t work.
With json like this:
{
test:"test"
}
It works…
but both are valid json files
EDIT 2:
I think there’s something weird with JSON file:
This JSON file is uploaded fine even if is malformed (the comma at the end):
{
"40268" : {
"id" : 3
},
"40268" : {
"id" : 4
},
}
This JSON doesn’t work even if formally is correct!!!
{
"40268" : {
"id" : 3
},
"40268" : {
"id" : 4
}
}
I really don’t understand what could be the problem