I want to use .csv
or .json
files with openai-agents-js
. It works for pdf
with the following code but gives 400 The file type you uploaded is not supported. Please try again with a pdf
error for other types.
const result = await runner.run(
categoryExtractorAgent,
[
{
role: 'user',
content: [
{
type: 'input_file',
file: fileDataUrl,
providerData: {
filename: req.file.originalname,
}
}
],
}
],
);
Giving a file url instead of base64 file is not also working.
It is weird that we can only use pdfs. I wonder if there is a way of using these extensions with Agents SDK.
We have discussed this in Using .csv or .json with Agents SDK · Issue #411 · openai/openai-agents-js · GitHub w/ @seratch .
A short summary:
You can only use pdf
or image
as input_file
file right now. You can give model a local file
(base64 encoding), a file URL
, or a file id
from OpenAI Files API
.
To use file id
from OpenAI Files API
, you need to upload a file using the dashboard or the API. You can upload almost any type of files to storage but still you can only use pdf
or image
as input_file
. However, uploading a file to storage gives you some other capabilities:
uploading different types of files to OpenAI platform and passing them to a Code Interpreter container to do calculation using Python code. You can ask “Use Python tool to do XYZ; the input CSV files are available in the sandbox environment” or so.
As a result if you need to use a file type other than pdf
or image
without a code interpreter, only option is:
… to include CSV/JSON data, you can simply put them as part of text prompt and you can clearly tell what the part is (e.g., the following section is a raw CSV format data to analyze … etc.).