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

feat: Add AzureOpenAIGenerator and AzureOpenAIChatGenerator #6648

Merged
merged 13 commits into from
Jan 5, 2024

Conversation

vblagoje
Copy link
Member

Why:

Add support for OpenAI LLMs like GPT-3.5 and GPT-4, which are available through Azure's services.

What:

Two main components have been added:

  1. AzureGenerator: This class extends the capabilities of the OpenAIGenerator to use Azure's deployment of OpenAI's models. It involves numerous parameters and methods that facilitate text generation with customizable settings tailored to Azure's API structure and authentication mechanisms.

  2. AzureChatGenerator: Similar to AzureGenerator, this class is tailored for chat-based applications, providing functionalities to utilize Azure's deployment of OpenAI models in chatbots or other conversational AI applications.

Additionally, both components are registered in their respective __init__.py files.

How can it be used:

Developers and researchers can use these components to integrate Azure's powerful language models into their applications for a variety of tasks, including but not limited to:

  • Generating text based on prompts
  • Building conversational agents
  • Automating content creation

These generators provide easy access to advanced NLP capabilities and can be customized with different parameters to suit specific needs, such as adjusting the model's creativity or response length.

How did you test it:

Manually. Unit tests were not added as we use the already tested OpenAIGenerator and OpenAIChatGenerator

Notes for the reviewer:

  • Omission of super init call: Azure generators intentionally omit super init call to parent components. This is intentional, see if that is the best approach possible.

  • Understanding Azure: As these changes involve integration with Azure, understanding the Azure environment, its authentication mechanisms, and how it hosts OpenAI models is crucial.

  • Reviewing Dependencies: Changes include imports specific to Azure's SDK (openai.lib.azure) and other related utilities, which should be reviewed for compatibility and stability.

  • Considerations for Deployment: Ensure that the addition of these new components aligns with the overall architecture and does not introduce any issues or conflicts with existing functionalities.

@vblagoje vblagoje requested review from a team as code owners December 26, 2023 15:48
@vblagoje vblagoje requested review from dfokina and julian-risch and removed request for a team December 26, 2023 15:48
@github-actions github-actions bot added 2.x Related to Haystack v2.0 type:documentation Improvements on the docs labels Dec 26, 2023
@julian-risch
Copy link
Member

@vblagoje I saw that there are two issues about this topic here: #6620 and here: deepset-ai/haystack-core-integrations#141 What do you think about those? Why not put this PR into the haystack-core-integrations?

@julian-risch
Copy link
Member

Alright, after a quick sync we decided that AzureGenerator can stay in core for now. It's very similar to OpenAIGenerator using just a different client and it doesn't add any dependencies. If a good reason to move it to core-integrations comes up later, we can do that.
@vblagoje When you start working on the AzureEmbedder you can self-assign the corresponding issue deepset-ai/haystack-core-integrations#138

Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks very good to me already. I just have a few smaller change requests.

  1. Skipping the super. _ _init _ _ call is fine. Adding a comment there would help readability.
  2. Let's rename to AzureOpenAIGenerator and AzureOpenAIChatGenerator.
  3. We should add unit tests at least for to_dict, from_dict and init as these methods are not covered by the OpenAIGenerator tests.

Bigger values mean the model will be less likely to repeat the same token in the text.
- `logit_bias`: Add a logit bias to specific tokens. The keys of the dictionary are tokens, and the
values are the bias to add to that token.
"""
Copy link
Member

Choose a reason for hiding this comment

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

It can be helpful to add a comment here explaining that super().init() call is skipped on purpose and that this is done because we need to initialize an AzureOpenAI client instead of the OpenAI client.

haystack/components/generators/azure.py Outdated Show resolved Hide resolved
@vblagoje
Copy link
Member Author

vblagoje commented Jan 4, 2024

Ready for another review @julian-risch 🚀

@julian-risch julian-risch self-requested a review January 5, 2024 13:00
@julian-risch julian-risch changed the title feat: Add AzureGenerator and AzureChatGenerator feat: Add AzureOpenAIGenerator and AzureOpenAIChatGenerator Jan 5, 2024
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks very good to me! Please double check the updated component name also in the release note and the CI tests with the added secrets before merging.

---
features:
- |
Adds support for Azure OpenAI models with AzureGenerator and AzureChatGenerator components.
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename here to AzureOpenAIGenerator and AzureOpenAIChatGenerator

@vblagoje vblagoje merged commit b7159ad into main Jan 5, 2024
21 checks passed
@vblagoje vblagoje deleted the azure_generators branch January 5, 2024 14:48
@dfokina dfokina mentioned this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants