Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_ids incorrectly deprecated, causing runtime errors #883

Open
1 task done
ffxsam opened this issue Jun 5, 2024 · 3 comments
Open
1 task done

file_ids incorrectly deprecated, causing runtime errors #883

ffxsam opened this issue Jun 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ffxsam
Copy link

ffxsam commented Jun 5, 2024

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

I just updated openai from 4.28.0 to 4.48.2. I'm now seeing this error in my Lambda function:

400 Unknown parameter: threads.messages[0].file_ids

If I open my code, I see that file_ids is no longer a valid property in the code snippet cited below.

No overload matches this call.
  Overload 1 of 3, '(body: ThreadCreateAndRunParamsNonStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<Run>', gave the following error.
    Object literal may only specify known properties, and 'file_ids' does not exist in type 'Message'.
  Overload 2 of 3, '(body: ThreadCreateAndRunParamsStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<Stream<AssistantStreamEvent>>', gave the following error.
    Object literal may only specify known properties, and 'file_ids' does not exist in type 'Message'.
  Overload 3 of 3, '(body: ThreadCreateAndRunParamsBase, options?: RequestOptions<unknown> | undefined): APIPromise<Run | Stream<AssistantStreamEvent>>', gave the following error.
    Object literal may only specify known properties, and 'file_ids' does not exist in type 'Message'.

I'm curious why a breaking change was introduced, and openai's major version was not bumped to 5.x.x as is standard practice with semver. Looking through the changelog, I also see no mention of breaking changes.

To Reproduce

See code snippet.

Code snippets

let run = await openai.beta.threads.createAndRun({
    assistant_id: OPENAI_ASSISTANT_ID,
    thread: {
      messages: [
        {
          role: 'user',
          content:
            'Analyze the attached files.\n\n' +
            customInstructions
              .map(
                (instruction) =>
                  `If you think the vendor is ${instruction.vendorName}: ` +
                  instruction.instructions
              )
              .join('\n\n'),
          file_ids: savedFiles.map((file) => file.id),
        },
      ],
    },
  });

OS

macOS

Node version

Node v20.14.0

Library version

openai 4.48.2

@ffxsam ffxsam added the bug Something isn't working label Jun 5, 2024
@meorphis
Copy link
Contributor

meorphis commented Jun 6, 2024

Hey @ffxsam sorry for the trouble here. I agree that the changelog could have been clearer. The convention that we are using is that breaking changes in the beta namespace (e.g. openai/resources/beta/threads/threads) will not result in a major version bump, since we are still actively iterating on these APIs.

The equivalent in the latest version would be:

let run = await openai.beta.threads.createAndRun({
    assistant_id: OPENAI_ASSISTANT_ID,
    thread: {
      messages: [
        {
          role: 'user',
          content:
            'Analyze the attached files.\n\n' +
            customInstructions
              .map(
                (instruction) =>
                  `If you think the vendor is ${instruction.vendorName}: ` +
                  instruction.instructions
              )
              .join('\n\n'),
          attachments: savedFiles.map((file) => {file_id: file.id}),
        },
      ],
    },
  });

@ffxsam
Copy link
Author

ffxsam commented Jun 6, 2024

@meorphis Thanks for the help! I understand you have a convention, but package managers follow their own convention. Beta packages use 0.x.y for their versioning, which prevents breaking changes during routine package updates. Just something to keep in mind for future breaking changes with the OpenAI SDK. It would be appreciated to at least have notes in the changelog that point out anything that could potentially break production applications.

@meorphis
Copy link
Contributor

meorphis commented Jun 7, 2024

Thanks for the feedback. There's unfortunately no perfect option here. Since the openai package itself is not (and cannot be) a beta package, if we wanted the beta functionality to have its own versioning we would have to split it into its own package and users of the openai package wouldn't have access to these features. So that's why we've landed where we have. But we do understand that the convention we're using is uncommon so it's helpful to hear from users when it breaks workflows. We really appreciate the feedback and will continue to evaluate the options in future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants