Skip to content

Incorrect code in assistants/tools/file_search documentation #1199

@eric8he

Description

@eric8he

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

Note: This is not an issue with the library, but rather the official documentation on the OpenAI website.

Under Step 2 in [https://platform.openai.com/docs/assistants/tools/file-search](this doc), this block of code is shown:

const fileStreams = ["edgar/goog-10k.pdf", "edgar/brka-10k.txt"].map((path) =>
  fs.createReadStream(path),
);
 
// Create a vector store including our two files.
let vectorStore = await openai.beta.vectorStores.create({
  name: "Financial Statement",
});
 
await openai.beta.vectorStores.fileBatches.uploadAndPoll(vectorStore.id, fileStreams);

In the last line, uploadAndPoll expects a JSON object of the format { files: Uploadable[]; fileIds?: string[] }. However, in the given example, we directly pass in fileStreams, an object of type Uploadable[].

The last line in the documentation should then be updated to

await openai.beta.vectorStores.fileBatches.uploadAndPoll(vectorStore.id, { files: fileStreams });

To Reproduce

Attempt to run the code segments provided in the documentation.

Code snippets

No response

OS

macOS

Node version

Node v22.11.0

Library version

openai v4.72.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationopenai apiRelated to underlying OpenAI API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions