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

Can we use the azure gpt key? #7

Open
YongLD opened this issue Feb 24, 2024 · 6 comments
Open

Can we use the azure gpt key? #7

YongLD opened this issue Feb 24, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@YongLD
Copy link

YongLD commented Feb 24, 2024

As the title said, How can I use the azure gpt key in DataDreamer?

@AjayP13
Copy link
Collaborator

AjayP13 commented Feb 26, 2024

Hi @YongLD, yes, you can, see the documentation for OpenAI here. It supports taking in parameters like "base_url" which can be used to connect to the Azure OpenAI service:

https://datadreamer.dev/docs/latest/datadreamer.llms.html#datadreamer.llms.OpenAI

So you can set base_url="https://YOUR_RESOURCE_NAME.openai.azure.com" and api_version="YOUR_API_VERSION" and set api_key="YOUR_AZURE_API_KEY".

@AjayP13 AjayP13 closed this as completed Feb 26, 2024
@AjayP13 AjayP13 added the question Further information is requested label Feb 26, 2024
@seanbenhur
Copy link

Hi @AjayP13 , can you provide a sample code?, I am trying to use Azure OAI and have provided my resource name in the model_name but I am getting the below error

[ 🤖 DataDreamer 💤 ] Step 'Generate Attributes' is running. ⏳
[ 🤖 DataDreamer 💤 ] [ 🧠 OpenAI (gpt4)] Finished call to 'datadreamer.llms.openai.OpenAI.retry_wrapper.<locals>._retry_wrapper' after 0.525(s), this was the 1st time calling it.
[ 🤖 DataDreamer 💤 ] [ 🧠 OpenAI (gpt4)] Retrying datadreamer.llms.openai.OpenAI.retry_wrapper.<locals>._retry_wrapper in 3.0 seconds as it raised NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}.
[ 🤖 DataDreamer 💤 ] [ 🧠 OpenAI (gpt4)] Finished call to 'datadreamer.llms.openai.OpenAI.retry_wrapper.<locals>._retry_wrapper' after 3.624(s), this was the 2nd time calling it.
[ 🤖 DataDreamer 💤 ] [ 🧠 OpenAI (gpt4)] Retrying datadreamer.llms.openai.OpenAI.retry_wrapper.<locals>._retry_wrapper in 3.0 seconds as it raised NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}.

@AjayP13
Copy link
Collaborator

AjayP13 commented Mar 22, 2024

Hi @seanbenhur, I actually don't use Azure OpenAI, so I've never tested this directly since I don't have a Azure OpenAI key, but you can see on this line:

else openai.AzureOpenAI(**other_kwargs, **self.kwargs)

how we pass base_url, api_version, and api_key to the underlying AzureOpenAI class from the openai Python library.

If you don't mind debugging this for me and seeing if you can get it to work or seeing if there's a bug I can fix it. And if you get it to work, it would be great if you could report back on what was the issue and a code snippet for others. If you want to reach me you can email me at ajayp@seas.upenn.edu and I can help assist you as well trying to figure this out further if you can't get it to work / we could debug over a video call if needed.

@seanbenhur
Copy link

Sure, I will work on it

@jonasherfort
Copy link

@AjayP13 The problem seems to be that in the code Azure OpenAI uses azure_ad_token if you're using Azure Active Directory (AAD) tokens. If you're using API keys, you should continue using api_key, not azure_ad_token.

@AjayP13
Copy link
Collaborator

AjayP13 commented Sep 19, 2024

Hi @jonasherfort, thanks for identifying the issue. I will work on fixing this soon, in the mean time you can override the OpenAI class to fix the issue to unblock yourself if you are comfortable doing overrides.

@AjayP13 AjayP13 reopened this Sep 19, 2024
@AjayP13 AjayP13 added bug Something isn't working and removed question Further information is requested labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants