Skip to content

Commit 4b354ce

Browse files
authored
Add support for retrieving available models in chat (#499)
Adds support to dynamically retrieve available models for a region(e.g., Claude 4, Claude 3.7, Claude 3.5) from the backend. Wires up the aws/chat/listAvailableModels protocol handler to support model selection in AmazonQ chat.
1 parent d7ad658 commit 4b354ce

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

plugin/src/software/aws/toolkits/eclipse/amazonq/chat/ChatCommunicationManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@ public void sendMessageToChatServer(final Command command, final ChatMessage mes
278278
Activator.getLogger().error("Error processing ruleClick: " + e);
279279
}
280280
break;
281+
case LIST_AVAILABLE_MODELS:
282+
try {
283+
Object listModelsResponse = amazonQLspServer.listAvailableModels(message.getData()).get();
284+
var listModelsCommand = ChatUIInboundCommand.createCommand(ChatUIInboundCommandName.ListAvailableModels.getValue(),
285+
listModelsResponse);
286+
Activator.getEventBroker().post(ChatUIInboundCommand.class, listModelsCommand);
287+
} catch (Exception e) {
288+
Activator.getLogger().error("Error processing listAvailableModels: " + e);
289+
}
290+
break;
281291
case PINNED_CONTEXT_ADD:
282292
amazonQLspServer.pinnedContextAdd(message.getData());
283293
break;

plugin/src/software/aws/toolkits/eclipse/amazonq/chat/models/ChatUIInboundCommandName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public enum ChatUIInboundCommandName {
1818
McpServerClick("aws/chat/mcpServerClick"),
1919
ListRules("aws/chat/listRules"),
2020
RuleClick("aws/chat/ruleClick"),
21+
ListAvailableModels("aws/chat/listAvailableModels"),
2122
SendPinnedContext("aws/chat/sendPinnedContext");
2223

2324
private final String value;

plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/AmazonQLspServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ <T extends Configuration> CompletableFuture<LspServerConfigurations<T>> getConfi
136136
@JsonRequest("aws/chat/ruleClick")
137137
CompletableFuture<Object> ruleClick(Object params);
138138

139+
@JsonRequest("aws/chat/listAvailableModels")
140+
CompletableFuture<Object> listAvailableModels(Object params);
141+
139142
@JsonNotification("aws/chat/pinnedContextAdd")
140143
void pinnedContextAdd(Object params);
141144

plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatViewActionHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public final void handleCommand(final ParsedCommand parsedCommand, final Browser
7373
case RULE_CLICK:
7474
case PINNED_CONTEXT_ADD:
7575
case PINNED_CONTEXT_REMOVE:
76+
case LIST_AVAILABLE_MODELS:
7677
chatCommunicationManager.sendMessageToChatServer(command, message);
7778
break;
7879
case CHAT_INFO_LINK_CLICK:

plugin/src/software/aws/toolkits/eclipse/amazonq/views/model/Command.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public enum Command {
4444
RULE_CLICK("aws/chat/ruleClick"),
4545
PINNED_CONTEXT_ADD("aws/chat/pinnedContextAdd"),
4646
PINNED_CONTEXT_REMOVE("aws/chat/pinnedContextRemove"),
47+
LIST_AVAILABLE_MODELS("aws/chat/listAvailableModels"),
4748
// Auth
4849
LOGIN_BUILDER_ID("loginBuilderId"),
4950
LOGIN_IDC("loginIdC"),

0 commit comments

Comments
 (0)