The openai.beta.vectorStores.files.list function in the node library returns everything instead of only the response body

Hello there!

I’m using the node library "openai": "^4.38.2".

When calling the ## List vector store files endpoint via the nodejs openai library, it seems to be returning the full response with the headers, etc instead of simply receiving the response body.

For example

export async function getVectorStoreFiles(
  openAiClient: OpenAI,
  vectorStoreId: string
) {
  const openAiVectorStoreFiles =
    await openAiClient.beta.vectorStores.files.list(vectorStoreId);

  console.log(openAiVectorStoreFiles);

  return openAiVectorStoreFiles;
}

I would expect, according to the function typing, the return object to be the following:

{
  "object": "list",
  "data": [
    {
      "id": "file-abc123",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    },
    {
      "id": "file-abc456",
      "object": "vector_store.file",
      "created_at": 1699061776,
      "vector_store_id": "vs_abc123"
    }
  ],
  "first_id": "file-abc123",
  "last_id": "file-abc456",
  "has_more": false
}

but I’m receiving the full response with headers, etc instead and have to access the data from openAiVectorStoreFiles.body.

export async function getVectorStoreFiles(
  openAiClient: OpenAI,
  vectorStoreId: string
) {
  const openAiVectorStoreFiles =
    // @ts-ignore
    (await openAiClient.beta.vectorStores.files.list(vectorStoreId)).body;

  console.log(openAiVectorStoreFiles);

  return openAiVectorStoreFiles;
}

Now it’s OK but it’s not consistent with the other functions and with the typings.

1 Like