Skip to content

Type '"batch"' is not assignable to type '"fine-tune" | "assistants" #830

@euclid1990

Description

@euclid1990

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

According to the document Uploading Your Batch Input File. I tried the following code:

import fs from "fs";
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const file = await openai.files.create({
    file: fs.createReadStream("batchinput.jsonl"),
    purpose: "batch",
  });

  console.log(file);
}

main();

However, it outputs the error:

TSError: ⨯ Unable to compile TypeScript:
worker/generate.ts:18:4 - error TS2322: Type '"batch"' is not assignable to type '"fine-tune" | "assistants"'.

18    purpose: "batch",
      ~~~~~~~

  node_modules/openai/resources/files.d.ts:119:5
    119     purpose: 'fine-tune' | 'assistants';
            ~~~~~~~
    The expected type comes from property 'purpose' which is declared here on type 'FileCreateParams'

Maybe the type batch is missing in this line of the openai package source code:

purpose: 'fine-tune' | 'assistants';

We can fix it by adding batch

purpose: 'fine-tune' | 'assistants' | 'batch';

To Reproduce

Easy to reproduce: look at official documentation page - https://platform.openai.com/docs/guides/batch/2-uploading-your-batch-input-file
Run above code in nodejs / typescript.

Code snippets

No response

OS

macOS

Node version

v20.11.0

Library version

v4.42.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions