Merge pull request #960 from microsoft/isidorn/toxic-parrot

upadte to latest api
This commit is contained in:
Isidor Nikolic
2024-02-16 11:20:42 +01:00
committed by GitHub
4 changed files with 21 additions and 13 deletions

View File

@ -22,7 +22,7 @@
],
"enabledApiProposals": [
"chatAgents2",
"chatRequestAccess"
"languageModels"
],
"main": "./out/extension.js",
"scripts": {

View File

@ -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)

View File

@ -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<ChatResponseTextPart | ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatAgentResult2, agentId: { extensionId: string; agentId: string });
private constructor(response: ReadonlyArray<ChatResponseTextPart | ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, 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.

View File

@ -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.