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 it support Azure openai? Or an endpoint that can be customized for api access? #18

Closed
suikaremilia opened this issue Apr 14, 2023 · 10 comments

Comments

@suikaremilia
Copy link

https://learn.microsoft.com/en-us/azure/cognitive-services/openai/overview

Azure also has openai service, which can do more customizable things than openai, so can the bot support azure openai?

@nalgeon
Copy link
Owner

nalgeon commented Apr 14, 2023

According to the link, both gpt-3.5 and gpt-4 are not yet publicly available on Azure. Do you already have access to them?

@suikaremilia
Copy link
Author

https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?tabs=command-line&pivots=programming-language-python

Like openai, they use two items as a preview version, but they can easily apply for access rights.

GPT4 needs to wait, GPT-3.5 is actually open.

@nalgeon
Copy link
Owner

nalgeon commented Apr 14, 2023

Do you have access to the GPT 3.5 Azure OpenAI API? Will you be able to test the implementation if the bot supports it?

@suikaremilia
Copy link
Author

Yes, I can test it.

nalgeon added a commit that referenced this issue Apr 14, 2023
@nalgeon
Copy link
Owner

nalgeon commented Apr 14, 2023

Okay, please try with the latest bot version (5fa0144). You'll need to set the actual values for all three parameters in the openai.azure config property (endpoint, version, and deployment):

openai:
    # ...
    azure:
        endpoint: https://example-endpoint.openai.azure.com
        version: 2023-03-15-preview
        deployment: deployment-name

@suikaremilia
Copy link
Author

Thanks for your work, now both GPT-4 and GPT-3.5 of azure openai are working fine.

It works normally with the built-in model, and can also reply as an attachment.

From my tests it looks like only /imagine is not working, but this is an Azure issue.

imagine:
    enabled: users_only

When users_only is set, you will get such prompts:

The imagine command is disabled for group users.

Maybe image can call DALLE2 alone instead of sharing API_KEY with chat.

@suikaremilia
Copy link
Author

Image generation is quite pricey ($0.016-$0.020 per image). By default it's only enabled for users listed in telegram.usernames, not for group members. You can change this with the imagine.enabled config property.

I am bad, I noticed this tip.

I thought the prompt of the image was wrong, because I didn't add users when I first tested the image.
Now the prompt is normal:
Failed to answer. Reason: openai.error.AuthenticationError: Incorrect API key provided:

Also, why filter users by username and not by user id? Not everyone has a telegram username set up.

@suikaremilia
Copy link
Author

I tested all the items in the readme with gpt-4 and gpt-3.5 of azure openai, and found no other problems.
Thanks again for your work.

@HeySlava
Copy link
Contributor

HeySlava commented Apr 14, 2023

Also, why filter users by username and not by user id? Not everyone has a telegram username set up.

If I've got it correctly, you can specify your users in config.telegram.chat_ids and it will work as you expected
Source code of python-telegram-bot filters Chat

@nalgeon
Copy link
Owner

nalgeon commented Apr 15, 2023

According to Azure docs, it does not support the DALL-E model (please correct me if I am wrong). So I didn't add any Azure API params for the /imagine command (which uses DALL-E).

Also, why filter users by username and not by user id?

Because it's much easier to ask a user for their username than to try to find out their user id. And if they don't have a username, they can easily get one.

@nalgeon nalgeon closed this as completed Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants