-
Notifications
You must be signed in to change notification settings - Fork 2
Azure OpenAI OAuth - R Shiny chat app #202
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
base: main
Are you sure you want to change the base?
Conversation
extensions/rshiny-chat-app/app.R
Outdated
azure_chat <- ellmer::chat_azure_openai( | ||
deployment_id = "gpt-4o-mini", | ||
api_version = "2024-12-01-preview", | ||
endpoint = "https://8ul4l3wq0g.openai.azure.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a generic api endpoint or something tied to a specific integration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a specific Azure OpenAI resource endpoint within the posit org
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha okay. So sort of separate from the oauth integration itself but also tied to it in a way. Name-wise, it would seem that this would be information that would be bundled with the integration itself versus needing to know the endpoint as a separate piece of information. For AWS bedrock, you just specify the model and and the creds tell AWS what you have access to. Shame Azure doesnt do the same thing :)
Was that detail discussed at all when building the integration? It sort of continues moving the feature from "OAuth integrations" to just "integrations" which I like since some services we want to use require more metadata to be managed by admins like this endpoint.
I don't feel super strongly about this, but does raise a question in my mind. cc @zackverham @nihara-thomas
extensions/rshiny-chat-app/app.R
Outdated
if (Sys.getenv("POSIT_PRODUCT") == "CONNECT") { | ||
|
||
client <- connectapi::connect() | ||
|
||
user_session_token <- session$request$HTTP_POSIT_CONNECT_USER_SESSION_TOKEN | ||
oauth_response <- connectapi::get_oauth_credentials(client, user_session_token) | ||
credentials <- list(Authorization = paste("Bearer", oauth_response$access_token)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added this in 271f481!
It's a messier implementation than the example you linked, but that's mainly because connectapi::connect
surfaces the 212 error code as a message instead of explicitly throwing the error. It seems like "grep"-ing the captured message output consistently captures the error code we're looking for, but maybe there's a much easier way to do this that I'm not yet aware of.
This approach is also limited in that it's checking for any enabled oauth integration, not specifically the azure openai one, but my guess is that it's okay for this application.
"tags": ["r", "shiny"], | ||
"minimumConnectVersion": "2025.06.0", | ||
"requiredFeatures": ["OAuth Integrations"], | ||
"version": "0.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can bump this to 0.0.1 to release it
extensions/rshiny-chat-app/README.md
Outdated
@@ -0,0 +1,19 @@ | |||
# R Shiny Chat App |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this should be named something more specific than this since the goal is to showcase the Azure OpenAI integration. Building something more generic other than this example could then not be tied to this newer Connect version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good point. I'll go ahead and change the name of the directory as well as all other instances of the name.
Overall, great work! Some comments of things that may need some clarification or tweaking. |
work to fulfill: https://github.com/posit-dev/connect/issues/31840
Very open to feedback on how best to market/present this gallery app since it's so reliant on specific users being given the correct data action roles to access an Azure OpenAI model deployment. I tried my best to document this in the "Usage" section of the
README.md
.This app has been deployed as an example here, but only members of the "Connect" user group will be able to properly interact with it.