When testing, the .js file has #!/usr/bin/env node
written at the top of the code.
If this code is removed, the file uploads successfully, but if it is present, the file does not upload.
If #!/usr/bin/env node
is present, it will return a response like the following.
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Invalid file format application/javascript. Supported formats: "c", "cpp", "css", "csv", "docx", "gif", "html", "java", "jpeg", "jpg", "js", "json", "md", "pdf", "php", "png", "pptx", "py", "rb", "tar", "tex", "ts", "txt", "webp", "xlsx", "xml", "zip"', 'type': 'invalid_request_error', 'param': None, 'code': None}}
from openai import OpenAI
client = OpenAI(
api_key=settings.LLM_API_KEY['openai'],
)
file_id = client.files.create(
file=open('./example/bin.js', "rb"),
purpose="assistants"
)
test code
#!/usr/bin/env node
'use strict';
console.log(1);