Closed maxesse closed 1 month ago
I think you're mixing in v2 code with v1. attachments
is expected in v2
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.
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.
I started drafting the integration here, if you'd like to take a look: https://github.com/danny-avila/LibreChat/pull/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.
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.
@maxesse I see thank you for clarifying! I was wondering what happened, if I had broken something or not
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.
Pull Request Template
⚠️ Before Submitting a PR, Please Review:
⚠️ Documentation Updates Notice:
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.
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.