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

OpenAI Assistant can't run with a file #7665

Closed
5 tasks done
zachary-nguyen opened this issue Feb 6, 2025 · 1 comment · Fixed by #7664
Closed
5 tasks done

OpenAI Assistant can't run with a file #7665

zachary-nguyen opened this issue Feb 6, 2025 · 1 comment · Fixed by #7664
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@zachary-nguyen
Copy link
Contributor

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { OpenAIAssistantRunnable } from "langchain/experimental/openai_assistant";
import { OpenAIFiles } from "langchain/experimental/openai_files";

const openAIFiles = new OpenAIFiles();
const file = await openAIFiles.createFile({
  file: fs.createReadStream(path.resolve(__dirname, `./test.txt`)),
  purpose: "assistants",
});

const assistant = await OpenAIAssistantRunnable.createAssistant({
  model: "gpt-3.5-turbo-1106",
  instructions:
    "You are a weather bot. Use the provided functions to answer questions.",
  name: "Weather Assistant",
  tools
});

const response = await assistant.invoke({
  content: "Please look at the weather data from the provided file and give some insights"
  fileIds: [file.id]   // This is the current payload required from the code
});

// Fix should be this
const response = await assistant.invoke({
  content: "Please look at the weather data from the provided file and give some insights"
  attachments: [{
                file_id: fileId,
                tools: [{type: "code_interpreter"}]
    }]
});

Error Message and Stack Trace (if applicable)

error: {
  message: "Unknown parameter: 'file_ids'.",
  type: 'invalid_request_error',
  param: 'file_ids',
  code: 'unknown_parameter'
}

Description

I'm trying to use an assistant to parse a file and provide some feedback on the data.
Getting the above error when trying to invoke the assistant

System Info

Linux
Node: 18.18.2

Copy link

dosubot bot commented Feb 6, 2025

@zachary-nguyen Hello! I'm here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together.

To resolve the "Unknown parameter: 'file_ids'" error, you should adjust the structure of the invoke method call. The error indicates that the file_ids parameter is not recognized, and it seems like the correct approach is to use the attachments field instead. Here's how you can modify your code:

const response = await assistant.invoke({
  content: "Please look at the weather data from the provided file and give some insights",
  attachments: [{
    file_id: file.id,
    tools: [{ type: "code_interpreter" }]
  }]
});

This change aligns with the expected structure for handling file attachments in the invoke method, using the attachments array to specify the file_id and any associated tools [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant