Skip to content

Commit 0d9d557

Browse files
authored
feat: add listAvailableModels request method (#593)
1 parent 3660267 commit 0d9d557

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

runtimes/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ The runtime supports chat by default
196196
| Send conversation or conversation action click event. If no action is provided, the default action is "open". | `aws/chat/conversationClick` | `ConversationClickParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `ConversationClickResult` |
197197
| Send request to list the MCP servers available: all or based on filter if provided. Similar to conversations, the filter in the request is a map of filter option ids to corresponding values. | `aws/chat/listMcpServers` | `ListMcpServersParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `ListMcpServersResult` |
198198
| Send MCP server or MCP server action click event. If no action is provided, the default action is "select". | `aws/chat/mcpServerClick` | `McpServerClickParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `McpServerClickResult` |
199+
| Send request to list available models for the current chat tab. | `aws/chat/listAvailableModels` | `ListAvailableModelsParams` | [Request](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage) Client to Server | `ListAvailableModelsResult` |
199200
| Send pinned context to client. Pinned context contains context commands that are pinned to the current tab. | `aws/chat/sendPinnedContext` | `PinnedContextParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) Server to Client | n/a |
200201
| Notify server that pinned context has been added by the client. | `aws/chat/pinnedContextAdd` | `PinnedContextParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) Client to Server | n/a |
201202
| Notify server that pinned context has been removed by the client. | `aws/chat/pinnedContextRemove` | `PinnedContextParams` | [Notification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage) Client to Server | n/a |

runtimes/protocol/chat.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ import {
8888
OPEN_FILE_DIALOG_METHOD,
8989
OpenFileDialogParams,
9090
OpenFileDialogResult,
91+
LIST_AVAILABLE_MODELS_REQUEST_METHOD,
92+
ListAvailableModelsResult,
93+
ListAvailableModelsParams,
9194
} from './lsp'
9295

9396
export const chatRequestType = new AutoParameterStructuresProtocolRequestType<
@@ -268,3 +271,11 @@ export const promptInputOptionChangeNotificationType = new ProtocolNotificationT
268271
PromptInputOptionChangeParams,
269272
void
270273
>(PROMPT_INPUT_OPTION_CHANGE_METHOD)
274+
275+
export const listAvailableModelsRequestType = new ProtocolRequestType<
276+
ListAvailableModelsParams,
277+
ListAvailableModelsResult,
278+
never,
279+
void,
280+
void
281+
>(LIST_AVAILABLE_MODELS_REQUEST_METHOD)

runtimes/runtimes/base-runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
onPinnedContextAddNotificationType,
6060
onPinnedContextRemoveNotificationType,
6161
openFileDialogRequestType,
62+
listAvailableModelsRequestType,
6263
} from '../protocol'
6364
import { createConnection } from 'vscode-languageserver/browser'
6465
import {
@@ -194,6 +195,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
194195
lspConnection.onNotification(promptInputOptionChangeNotificationType.method, handler),
195196
onOpenFileDialog: handler => lspConnection.onRequest(openFileDialogRequestType.method, handler),
196197
onRuleClick: handler => lspConnection.onRequest(ruleClickRequestType.method, handler),
198+
onListAvailableModels: handler => lspConnection.onRequest(listAvailableModelsRequestType.method, handler),
197199
}
198200

199201
const identityManagement: IdentityManagement = {

runtimes/runtimes/chat/baseChat.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ import {
8585
OpenFileDialogParams,
8686
OpenFileDialogResult,
8787
openFileDialogRequestType,
88+
ListAvailableModelsParams,
89+
ListAvailableModelsResult,
90+
listAvailableModelsRequestType,
8891
} from '../../protocol'
8992
import { Chat } from '../../server-interface'
9093

@@ -236,4 +239,8 @@ export class BaseChat implements Chat {
236239
public onRuleClick(handler: RequestHandler<RuleClickParams, RuleClickResult, void>) {
237240
this.connection.onRequest(ruleClickRequestType.method, handler)
238241
}
242+
243+
public onListAvailableModels(handler: RequestHandler<ListAvailableModelsParams, ListAvailableModelsResult, void>) {
244+
this.connection.onRequest(listAvailableModelsRequestType.method, handler)
245+
}
239246
}

runtimes/server-interface/chat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ import {
4949
RuleClickResult,
5050
PinnedContextParams,
5151
ActiveEditorChangedParams,
52+
ListAvailableModelsParams,
53+
ListAvailableModelsResult,
5254
} from '../protocol'
5355

5456
/**
@@ -75,6 +77,7 @@ export type Chat = {
7577
onOpenFileDialog: (
7678
handler: RequestHandler<OpenFileDialogParams, OpenFileDialogResult, OpenFileDialogResult>
7779
) => void
80+
onListAvailableModels: (handler: RequestHandler<ListAvailableModelsParams, ListAvailableModelsResult, void>) => void
7881
// Notifications
7982
onSendFeedback: (handler: NotificationHandler<FeedbackParams>) => void
8083
onReady: (handler: NotificationHandler<void>) => void

types/chat.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export const MCP_SERVER_CLICK_REQUEST_METHOD = 'aws/chat/mcpServerClick'
4848
// export
4949
export const GET_SERIALIZED_CHAT_REQUEST_METHOD = 'aws/chat/getSerializedChat'
5050

51+
// model selection
52+
export const LIST_AVAILABLE_MODELS_REQUEST_METHOD = 'aws/chat/listAvailableModels'
53+
5154
// button ids
5255
export const OPEN_WORKSPACE_INDEX_SETTINGS_BUTTON_ID = 'open-settings-for-ws-index'
5356

@@ -671,3 +674,18 @@ export interface PromptInputOptionChangeParams {
671674
optionsValues: Record<string, string>
672675
eventId?: string
673676
}
677+
678+
export interface Model {
679+
id: string
680+
name: string
681+
}
682+
683+
export interface ListAvailableModelsParams {
684+
tabId: string
685+
}
686+
687+
export interface ListAvailableModelsResult {
688+
tabId: string
689+
models: Model[]
690+
selectedModelId?: string
691+
}

0 commit comments

Comments
 (0)