deep-chat icon indicating copy to clipboard operation
deep-chat copied to clipboard

Azure OpenAI Assistants API

Open bruffridge opened this issue 1 year ago • 3 comments

Has anyone tried deep-chat with Azure Assistants API? I'm in the process of getting an Azure OpenAI account setup, and thought I'd ask to see if deep-chat supports it.

Looks like MS has an NPM package for it too: https://learn.microsoft.com/en-us/javascript/api/overview/azure/openai-readme?view=azure-node-preview

bruffridge avatar Jul 30 '24 18:07 bruffridge

Hi @bruffridge.

I personally haven't had the chance to play around with it.

Due to a high amount of other features that I have in the priority list - its exploration would unfortunately need to wait. However if you are keen to use it, you can always adapt it along with its npm library by simply using the handler function.

Let me know what your findings are. Thanks!

OvidijusParsiunas avatar Jul 30 '24 22:07 OvidijusParsiunas

It has become a requirement for my project to support Assistants API on Azure. I don't think deep-chat will support Assistants API on Azure without a couple of changes.

1. User-defined API endpoint prefixes

Looks like deep-chat would need to add support for user-defined API endpoints for Azure perhaps by creating a new file azureOpenAIAssistantIO.ts or modifying openAIAssistantIO.ts

For example, in this file: https://github.com/OvidijusParsiunas/deep-chat/blob/d07a4770f529101edcdb2bda20c0eee2b8f5348a/component/src/services/openAI/openAIAssistantIO.ts#L43

The API endpoint for OpenAIAssistants is hardcoded as https://api.openai.com/v1/threads whereas its equivalent prefix on Azure is https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads according to the Azure OpenAI Assistants API docs here -> https://learn.microsoft.com/en-us/azure/ai-services/openai/assistants-reference?tabs=rest and Assistants Quickstart here -> https://learn.microsoft.com/en-us/azure/ai-services/openai/assistants-quickstart?tabs=command-line%2Ctypescript&pivots=rest-api

2. API_KEY header change

Another difference is instead of setting the api-key as Authorization: Bearer OPENAI_API_KEY header, in Azure it is set as a custom api-key header

curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_API_KEY" \
  -d ''

Otherwise I think the API methods are parameters are identical between the two. As such, I don't think adding support will be too difficult, but I might be missing something. I could fork and try to implement and then submit a PR. Thoughts?

bruffridge avatar Jul 31 '24 18:07 bruffridge

Hi @bruffridge. That sounds good! You are more than welcome to create a PR and I can make any further changes to adhere to our API and coding patterns.

OvidijusParsiunas avatar Jul 31 '24 18:07 OvidijusParsiunas

This is currently available in the deep-chat-dev and deep-chat-react-dev version 9.0.197. Please refer to the following comment for more information.

OvidijusParsiunas avatar Oct 25 '24 10:10 OvidijusParsiunas