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

Add Azure AI Studio as provider #7549

Merged
merged 11 commits into from
Aug 27, 2024

Conversation

helioLJ
Copy link
Contributor

@helioLJ helioLJ commented Aug 22, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

This PR adds Azure AI Studio as a new model provider in Dify. It implements support for both LLM and rerank models, allowing users to leverage Azure AI Studio's capabilities within the Dify ecosystem. This addition is particularly beneficial for organizations that exclusively use Azure and need access to models like the Cohere Reranker through Azure AI Studio Catalog.

Close #7326

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please test the following to verify the changes:

  • Test Azure AI Studio LLM model integration
    • Configure Azure AI Studio credentials in Dify
    • Create a new application using an Azure AI Studio LLM model
    • Test text generation with the configured model
  • Test Azure AI Studio Rerank model integration
    • Configure Azure AI Studio credentials for a rerank model
    • Use the rerank model in a relevant Dify feature (e.g., semantic search)
    • Verify that document reranking works as expected
  • Verify that existing model providers still function correctly

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. dependencies Pull requests that update a dependency file ⚙️ feat:model-runtime 💪 enhancement New feature or request labels Aug 22, 2024
@crazywoola
Copy link
Member

Thanks for your contribution :) Please resolve the deps conflict and add tests to the new provider accordingly.

@helioLJ
Copy link
Contributor Author

helioLJ commented Aug 22, 2024

Thanks for your contribution :) Please resolve the deps conflict and add tests to the new provider accordingly.

You are welcome :)

Conflicts solved, added the tests files and update the larger icon to a better one!

Copy link

@dyohan9 dyohan9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few points to adjust, congratulations on your contribution, I'm sure it will help many people.

@helioLJ
Copy link
Contributor Author

helioLJ commented Aug 22, 2024

I left a few points to adjust, congratulations on your contribution, I'm sure it will help many people.

Good observations, mate! I ran Ruff linter in the files and added proper exception mapping.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 27, 2024
@crazywoola crazywoola merged commit 7b7576a into langgenius:main Aug 27, 2024
6 checks passed
cuiks pushed a commit to cuiks/dify that referenced this pull request Sep 2, 2024
Co-authored-by: Hélio Lúcio <canais.hlucio@voegol.com.br>
@bhctest123
Copy link

bhctest123 commented Sep 3, 2024

Hey guys, I was doing some testing for the community and hit an error. I set up the keys correctly and everything in Azure Ai Studio. see images to see the errors! @crazywoola @takatost @laipz8200 @helioLJ

Screenshot 2024-09-02 at 8 52 55 PM

@helioLJ
Copy link
Contributor Author

helioLJ commented Sep 3, 2024

Hey guys, I was doing some testing for the community and hit an error. I set up the keys correctly and everything in Azure Ai Studio. see images to see the errors! @crazywoola @takatost @laipz8200 @helioLJ

Screenshot 2024-09-02 at 8 52 55 PM Screenshot 2024-09-02 at 8 54 13 PM

Analyzing your deployment and mine that I used for test it (ibm-re2g-reranker-nq-3), they have different Compute Types, the one from IBM uses Managed type, while Cohere models use Consumption type, so I suspect the Authentication type are different for both.

Can you send me the sample code for consumption, in Python, in that "Consume" tab, I will fix that later.

Also, I'm almost pretty sure that using this inference endpoint and API Key can work with Cohere Provider Model, but not 100% sure.

@bhctest123
Copy link

Hey @helioLJ I see the reranker you used. that is $80+ dollars per month because you are deploying an actual server with that reranker model running. The cohere endpoint is an API hosted by Microsoft and only costs $2 per 1000 queries. It seems more cost efficient and more likely to help the Dify community. Do you think its possible to support the cohere type of reranker?

Screenshot by Dropbox Capture

Screenshot by Dropbox Capture

Screenshot by Dropbox Capture

@helioLJ
Copy link
Contributor Author

helioLJ commented Sep 3, 2024

Hey @helioLJ I see the reranker you used. that is $80+ dollars per month because you are deploying an actual server with that reranker model running. The cohere endpoint is an API hosted by Microsoft and only costs $2 per 1000 queries. It seems more cost efficient and more likely to help the Dify community. Do you think its possible to support the cohere type of reranker?

Screenshot by Dropbox Capture

Screenshot by Dropbox Capture

Screenshot by Dropbox Capture

Sure! I will update to support it, would you mind message me at Discord? I'll probably need your help. 'heliolj' at Dify's server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file 💪 enhancement New feature or request ⚙️ feat:model-runtime lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Azure AI Studio Catalog" as a Model Provider in Dify
4 participants