Skip to content

Commit ffae386

Browse files
authored
feat(sagemaker): free tier Q Chat with auto-login for iam users and login option for pro tier users (#5858)
## Problem AmazonQ - IAM users didn't have access to Q Chat (Free Tier) - Sagemaker IAM users weren't automatically logged in using their Sagemaker studio credentials. - For Sagemaker users, login screen was disabled & users didn't have access to chat or code completion. - Sagemaker Pro Tier users code completion was broken & didn't generate any recommendations even after successful login. - Q Icon hides from Activity Bar when Toolkit extension is installed ## Solution - Add new Q Developer Client to enable Free tier chat. - Terminate all the conditions that used to force chat to get disabled for IAM users - Terminate the conditions that used to hide login screen for Sagemaker users - Login Sagemaker IAM users automatically using their environment credentials (Free tier) - Allow Sagemaker SSO pro tier users to login using the login screen. --- <!--- REMINDER: Ensure that your PR meets the guidelines in CONTRIBUTING.md --> License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6c420c7 commit ffae386

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+19947
-9748
lines changed

docs/build.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Build
22

3-
The AmazonQ features rely on the `codewhisperer-streaming` service, who's client
4-
is generated from the service's smithy models and placed in
5-
`src.gen/@amzn/codewhisperer-streaming` (For more
6-
information about this client and how it is generated, please see this
3+
The AmazonQ features rely on the `codewhisperer-streaming` service, to support both Sigv4 and Bearer token modes of this service,
4+
two clients are generated from the service's smithy models and placed in
5+
`src.gen/@amzn/amazon-q-developer-streaming-client` and `src.gen/@amzn/codewhisperer-streaming` respectively (For more
6+
information about these clients and how they are generated, please see this
77
[quip document](https://quip-amazon.com/2dAWAvTIYXXr/Build-instructions-for-AWS-CodeWhisperer-Streaming-Typescript-client)).
88

9+
## @amzn/amazon-q-developer-streaming client
10+
11+
This client is a standalone npm project in typescript, and it is added to
12+
the project as a workspace in the project's root `package.json` with the line `"workspaces": [ ..., "src.gen/@amzn/amazon-q-developer-streaming" ]`.
13+
The client may be manually built using `npm run build -w @amzn/amazon-q-developer-streaming"`.
14+
The `generateClients` run script ensures that this dependency is
15+
built before the toolkit project itself. Workspaces are automatically ready to
16+
be imported in the root toolkit project by their declared package.json name,
17+
(`@amzn/amazon-q-developer-streaming` in this case).
18+
19+
## @amzn/codewhisperer-streaming client
20+
921
This client is a standalone npm project in typescript, and it is added to
1022
the project as a workspace in the project's root `package.json` with the line `"workspaces": [ ..., "src.gen/@amzn/codewhisperer-streaming" ]`.
1123
The client may be manually built using `npm run build -w @amzn/codewhisperer-streaming"`.

package-lock.json

Lines changed: 10544 additions & 9687 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"scripts": {
2222
"prepare": "ts-node ./scripts/prepare.ts",
23-
"preinstall": "cd src.gen/@amzn/codewhisperer-streaming && npm i",
23+
"preinstall": "cd src.gen/@amzn/codewhisperer-streaming && npm i && cd ../amazon-q-developer-streaming-client && npm i",
2424
"postinstall": "npm run buildCustomLintPlugin && npm run postinstall -ws --if-present",
2525
"buildCustomLintPlugin": "npm run build -w plugins/eslint-plugin-aws-toolkits",
2626
"compile": "npm run compile -w packages/",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Use Sagemaker environment IAM Credentials for Code Completion when they're available"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Inline: Code completion not working for Sagemaker Pro Tier users."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Disable /transform and /dev commands for sagemaker users as they're not supported"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Enable Free Tier Chat for IAM users"
4+
}

packages/amazonq/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@
196196
"type": "webview",
197197
"id": "aws.amazonq.AmazonCommonAuth",
198198
"name": "%AWS.amazonq.login%",
199-
"when": "!aws.isSageMaker && !aws.isWebExtHost && aws.amazonq.showLoginView"
199+
"when": "!aws.isWebExtHost && aws.amazonq.showLoginView"
200200
},
201201
{
202202
"type": "webview",
203203
"id": "aws.AmazonQChatView",
204204
"name": "%AWS.amazonq.chat%",
205-
"when": "!aws.isSageMaker && !aws.isWebExtHost && !aws.amazonq.showLoginView"
205+
"when": "!aws.isWebExtHost && !aws.amazonq.showLoginView"
206206
},
207207
{
208208
"id": "aws.AmazonQNeverShowBadge",

packages/amazonq/src/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { SendMessageCommandOutput, SendMessageRequest } from '@amzn/amazon-q-developer-streaming-client'
67
import { GenerateAssistantResponseCommandOutput, GenerateAssistantResponseRequest } from '@amzn/codewhisperer-streaming'
78
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
89
import { ChatSession } from 'aws-core-vscode/codewhispererChat'
@@ -12,7 +13,11 @@ export default {
1213
chatApi: {
1314
async chat(request: GenerateAssistantResponseRequest): Promise<GenerateAssistantResponseCommandOutput> {
1415
const chatSession = new ChatSession()
15-
return chatSession.chat(request)
16+
return chatSession.chatSso(request)
17+
},
18+
async chatIam(request: SendMessageRequest): Promise<SendMessageCommandOutput> {
19+
const chatSession = new ChatSession()
20+
return chatSession.chatIam(request)
1621
},
1722
},
1823
authApi: {

packages/amazonq/src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
setContext,
4545
setupUninstallHandler,
4646
maybeShowMinVscodeWarning,
47+
isSageMaker,
4748
} from 'aws-core-vscode/shared'
4849
import { ExtStartUpSources, telemetry } from 'aws-core-vscode/telemetry'
4950
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
@@ -193,7 +194,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
193194
}
194195
}
195196
const currConn = AuthUtil.instance.conn
196-
if (currConn !== undefined && !isAnySsoConnection(currConn)) {
197+
if (currConn !== undefined && !(isAnySsoConnection(currConn) || isSageMaker())) {
197198
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
198199
}
199200

0 commit comments

Comments
 (0)