-
Notifications
You must be signed in to change notification settings - Fork 273
feat(amazonq): add image context support #5846
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
Changes from 3 commits
92b30dc
79f86f6
9d0fd61
4621012
eb596bd
2594dbe
42016ee
3df8ef9
410c68e
ac84d65
714a4a1
dfce2b1
0c18a65
024d33b
388b428
6218560
c303aac
b95ed96
351b6a1
566b82c
8e9fa3a
1834f27
fe318e4
cfe76d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "feature", | ||
"description" : "Add image context support" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ import com.intellij.ide.BrowserUtil | |
import com.intellij.notification.NotificationAction | ||
import com.intellij.notification.NotificationType | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.fileChooser.FileChooser | ||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory | ||
import com.intellij.openapi.fileChooser.FileChooserFactory | ||
import com.intellij.openapi.fileChooser.FileSaverDescriptor | ||
import com.intellij.openapi.fileEditor.FileEditorManager | ||
|
@@ -51,6 +53,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.FileP | |
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GET_SERIALIZED_CHAT_REQUEST_METHOD | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenFileDiffParams | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ShowOpenFileDialogParams | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ShowSaveFileDialogParams | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ShowSaveFileDialogResult | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.ConnectionMetadata | ||
|
@@ -249,6 +252,27 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC | |
) | ||
} | ||
|
||
override fun showOpenFileDialog(params: ShowOpenFileDialogParams): CompletableFuture<LSPAny> { | ||
return CompletableFuture.supplyAsync( | ||
{ | ||
val descriptor = if (params.canSelectMany) { | ||
FileChooserDescriptorFactory.createMultipleFilesNoJarsDescriptor().apply { | ||
title = "Select Files" | ||
description = "Choose files to open" | ||
} | ||
} else { | ||
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor() | ||
} | ||
|
||
val chosenFiles = FileChooser.chooseFiles(descriptor, project, null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't images from this flow subject to constraints? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they are now with the new commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about the file size and dimensional limits? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation of the images chosen from file picker is done in language-server |
||
val uris = chosenFiles.map { it.url } | ||
|
||
mapOf("uris" to uris) as LSPAny | ||
}, | ||
ApplicationManager.getApplication()::invokeLater | ||
) | ||
} | ||
|
||
override fun getSerializedChat(params: LSPAny): CompletableFuture<GetSerializedChatResult> { | ||
val requestId = UUID.randomUUID().toString() | ||
val result = CompletableFuture<GetSerializedChatResult>() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat | ||
|
||
data class ShowOpenFileDialogParams( | ||
val canSelectFiles: Boolean = false, | ||
val canSelectFolders: Boolean = false, | ||
val canSelectMany: Boolean = false, | ||
val filters: Map<String, List<String>> = emptyMap(), | ||
val defaultUri: String? = null, | ||
val title: String? = null, | ||
zuoyaofu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) |
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.
can you walk me through the message flow? does it actually need to transit through flare before requesting the file picker?
Uh oh!
There was an error while loading. Please reload this page.
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.
Flow:
openFileDialog
request to flarecanSelectMany
(multiple files),filters
(what file extension types are allowed)- does it actually need to transit through flare before requesting the file picker?