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

fix: Azure OpenAI Assistants v1 file uploads #4573

Closed
wants to merge 1 commit into from

Conversation

maxesse
Copy link
Contributor

@maxesse maxesse commented Oct 29, 2024

Pull Request Template

⚠️ Before Submitting a PR, Please Review:

  • Please ensure that you have thoroughly read and understood the Contributing Docs before submitting your Pull Request.

⚠️ Documentation Updates Notice:

  • Kindly note that documentation updates are managed in this repository: librechat.ai

Summary

This PR fixes file uploads to Azure OpenAI Assistants, which still use the v1 API (I believe the v2 branch was never merged into main right?). Trying to upload any file to an assistant with code interpreter enabled will result in a 400 Unknown parameter message[0].file_ids, and return a general error in the UI saying the assistant run can't be started. This fix adds the files to the attachments parameter, which is what the Azure OpenAI API expects.

Change Type

Please delete any irrelevant options.

  • Bug fix (non-breaking change which fixes an issue)

Testing

Upload a file such as a PDF or XLSX to an azure openai assistant with code interpreter enabled using the main branch, and then with this fix.

Test Configuration:

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings

@danny-avila
Copy link
Owner

danny-avila commented Oct 29, 2024

I think you're mixing in v2 code with v1. attachments is expected in v2

@maxesse
Copy link
Contributor Author

maxesse commented Oct 29, 2024

Now I'm confused. I've been debugging this for a whole morning, and it seems like librechat always call the v1 api for azure assistants. I tried to add version: "2" in the librechat.yaml for azureAssistants as it was mentioned in the code, but it still uses the v1 api. So could it be that azure is automatically using v2 api's but librechat is reverting to use v1 and this causes errors? Another thing, if I try to update an assistant, the retrieval capability is not found and it returns an api error, as it expects file_search, but if I put file_search that causes an error on Librechat launch because it doesn't exist in the array. Really not sure what to do here, do I just force it to call the v2 api directly in code? I seem to remember someone in the github discussions having to do that a few weeks ago.

@danny-avila
Copy link
Owner

v2 is not supported, as I implemented Azure Assistants with v1, and there is more than 1 change needed to support it, and it's not as simple as changing the version number in the API call.

@danny-avila
Copy link
Owner

I started drafting the integration here, if you'd like to take a look: #2820

However I don't have time to start on this and would rather focus on our own native Agents solution, which would support Azure OpenAI.

@maxesse
Copy link
Contributor Author

maxesse commented Oct 29, 2024

Ok, but to clarify, it looks like azure is expecting requests whether they're to the v1 or v2 endpoint to follow v2 specs - this is a recent change, because it used to work fine until a week or so ago. I can't wait for your native agents to roll out, as it's a much more elegant solution, but for now I guess I'll have to keep my frankenstein fix, otherwise they're just broken.

@danny-avila
Copy link
Owner

@maxesse I see thank you for clarifying! I was wondering what happened, if I had broken something or not

@maxesse
Copy link
Contributor Author

maxesse commented Oct 29, 2024

Ok, thanks to your clarifications I thought about what could have changed in Azure. Normally I'd use the 2024-05-01-preview API. That was the first one to support v2 assistants. The 2024-06-01 never worked with librechat and it wouldn't even be able to enumerate assistants. Newer APIs are a mixed bag, 2024-10-01-preview works ok usually with the base model, or with the fix in this PR. So I thought they must have fixed an oversight where using the 2024-05-01-preview api would let you upload files using the v1 parameters. Now I went to try and put it back to the 2024-02-15-preview api (the last one to support assistants v1) and lo-and-behold, it works fine, without the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants