diff --git a/chat-agent-sample/package.json b/chat-agent-sample/package.json index 612e4b6a..4d80ad81 100644 --- a/chat-agent-sample/package.json +++ b/chat-agent-sample/package.json @@ -22,7 +22,7 @@ ], "enabledApiProposals": [ "chatAgents2", - "chatRequestAccess" + "languageModels" ], "main": "./out/extension.js", "scripts": { diff --git a/chat-agent-sample/src/extension.ts b/chat-agent-sample/src/extension.ts index 39692381..e7bf210b 100644 --- a/chat-agent-sample/src/extension.ts +++ b/chat-agent-sample/src/extension.ts @@ -18,7 +18,7 @@ export function activate(context: vscode.ExtensionContext) { // extension can use VS Code's `requestChatAccess` API to access the Copilot API. // The GitHub Copilot Chat extension implements this provider. if (request.command == 'teach') { - const access = await vscode.chat.requestLanguageModelAccess(LANGUAGE_MODEL_ID); + const access = await vscode.lm.requestLanguageModelAccess(LANGUAGE_MODEL_ID); const topics = ['linked list', 'recursion', 'stack', 'queue', 'pointers']; const topic = topics[Math.floor(Math.random() * topics.length)]; const messages = [ @@ -37,7 +37,7 @@ export function activate(context: vscode.ExtensionContext) { return { metadata: { command: 'teach' } }; } else if (request.command == 'play') { - const access = await vscode.chat.requestLanguageModelAccess(LANGUAGE_MODEL_ID); + const access = await vscode.lm.requestLanguageModelAccess(LANGUAGE_MODEL_ID); const messages = [ new vscode.LanguageModelSystemMessage('You are a cat that wants to play! Reply in a helpful way for a coder, but with the hidden meaning that all you want to do is play.'), new vscode.LanguageModelUserMessage(request.prompt) @@ -48,7 +48,7 @@ export function activate(context: vscode.ExtensionContext) { } return { metadata: { command: 'play' } }; } else { - const access = await vscode.chat.requestLanguageModelAccess(LANGUAGE_MODEL_ID); + const access = await vscode.lm.requestLanguageModelAccess(LANGUAGE_MODEL_ID); const messages = [ new vscode.LanguageModelSystemMessage('You are a cat! Reply in the voice of a cat, using cat analogies when appropriate.'), new vscode.LanguageModelUserMessage(request.prompt) diff --git a/chat-agent-sample/src/vscode.proposed.chatAgents2.d.ts b/chat-agent-sample/src/vscode.proposed.chatAgents2.d.ts index 82cdc761..63cad62d 100644 --- a/chat-agent-sample/src/vscode.proposed.chatAgents2.d.ts +++ b/chat-agent-sample/src/vscode.proposed.chatAgents2.d.ts @@ -19,10 +19,9 @@ declare module 'vscode' { readonly prompt: string; /** - * The ID of the chat agent to which this request was directed. + * The name of the chat agent and contributing extension to which this request was directed. */ - // TODO@API NAME: agentId shouldbe agentName or just agent (because it is ChatAgent#name) - readonly agent: { readonly extensionId: string; readonly agent: string; readonly agentId: string }; + readonly agent: { readonly extensionId: string; readonly agent: string }; /** * The name of the {@link ChatAgentCommand command} that was selected for this request. @@ -34,7 +33,7 @@ declare module 'vscode' { */ readonly variables: ChatAgentResolvedVariable[]; - private constructor(prompt: string, command: string | undefined, variables: ChatAgentResolvedVariable[], agent: { extensionId: string; agentId: string }); + private constructor(prompt: string, command: string | undefined, variables: ChatAgentResolvedVariable[], agent: { extensionId: string; agent: string }); } // TODO@API name: Turn? @@ -50,10 +49,12 @@ declare module 'vscode' { */ readonly result: ChatAgentResult2; - // TODO@API NAME: agentId shouldbe agentName or just agent (because it is ChatAgent#name) - readonly agent: { readonly extensionId: string; readonly agent: string; readonly agentId: string }; + /** + * The name of the chat agent and contributing extension to which this request was directed. + */ + readonly agent: { readonly extensionId: string; readonly agent: string }; - private constructor(response: ReadonlyArray, result: ChatAgentResult2, agentId: { extensionId: string; agentId: string }); + private constructor(response: ReadonlyArray, result: ChatAgentResult2, agentId: { extensionId: string; agent: string }); } export interface ChatAgentContext { @@ -276,6 +277,11 @@ declare module 'vscode' { */ sampleRequest?: string; + /** + * Whether invoking the agent puts the chat into a persistent mode, where the agent is automatically added to the chat input for the next message. + */ + isSticky?: boolean; + /** * An event that fires whenever feedback for a result is received, e.g. when a user up- or down-votes * a result. diff --git a/chat-agent-sample/src/vscode.proposed.chatRequestAccess.d.ts b/chat-agent-sample/src/vscode.proposed.languageModels.d.ts similarity index 98% rename from chat-agent-sample/src/vscode.proposed.chatRequestAccess.d.ts rename to chat-agent-sample/src/vscode.proposed.languageModels.d.ts index 633c28dc..0e353518 100644 --- a/chat-agent-sample/src/vscode.proposed.chatRequestAccess.d.ts +++ b/chat-agent-sample/src/vscode.proposed.languageModels.d.ts @@ -152,8 +152,10 @@ declare module 'vscode' { readonly removed: readonly string[]; } - //@API DEFINE the namespace for this: lm (languageModels), copilot, ai, env,? - export namespace chat { + /** + * Namespace for language model related functionality. + */ + export namespace lm { /** * Request access to a language model.