mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Update
This commit is contained in:
1
chat-sample/package-lock.json
generated
1
chat-sample/package-lock.json
generated
@ -7,7 +7,6 @@
|
||||
"": {
|
||||
"name": "chat-sample",
|
||||
"version": "0.1.0",
|
||||
"hasInstallScript": true,
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.5.9",
|
||||
"@types/vscode": "^1.90.0",
|
||||
|
||||
@ -66,11 +66,7 @@
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"postinstall": "npm run setupTiktoken",
|
||||
"setupTiktoken": "run-script-os",
|
||||
"setupTiktoken:linux:darwin": "cp node_modules/@vscode/prompt-tsx/dist/base/tokenizer/cl100k_base.tiktoken out/",
|
||||
"setupTiktoken:windows": "copy node_modules\\@vscode\\prompt-tsx\\dist\\base\\tokenizer\\cl100k_base.tiktoken out\\"
|
||||
"watch": "tsc -watch -p ./"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.5.9",
|
||||
|
||||
@ -96,7 +96,7 @@ function registerChatParticipant(context: vscode.ExtensionContext) {
|
||||
const tool = vscode.lm.tools.find(tool => tool.id === part.name);
|
||||
if (!tool) {
|
||||
// BAD tool choice?
|
||||
continue;
|
||||
throw new Error('Got invalid tool choice: ' + part.name);
|
||||
}
|
||||
|
||||
let parameters: any;
|
||||
@ -109,7 +109,7 @@ function registerChatParticipant(context: vscode.ExtensionContext) {
|
||||
stream.progress(`Calling tool: ${tool.id} with ${part.parameters}`);
|
||||
toolCalls.push({
|
||||
call: part,
|
||||
result: vscode.lm.invokeTool(tool.id, { parameters: JSON.parse(part.parameters) }, token),
|
||||
result: vscode.lm.invokeTool(tool.id, { parameters: JSON.parse(part.parameters), toolInvocationToken: request.toolInvocationToken }, token),
|
||||
tool
|
||||
});
|
||||
}
|
||||
|
||||
@ -36,6 +36,11 @@ declare module 'vscode' {
|
||||
constructor(value: string | MarkdownString, vulnerabilities: ChatVulnerability[]);
|
||||
}
|
||||
|
||||
export class ChatResponseCodeblockUriPart {
|
||||
value: Uri;
|
||||
constructor(value: Uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a {@link Command command} as a button in the chat response.
|
||||
*/
|
||||
@ -70,7 +75,7 @@ declare module 'vscode' {
|
||||
constructor(value: Uri, license: string, snippet: string);
|
||||
}
|
||||
|
||||
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseDetectedParticipantPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2;
|
||||
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseDetectedParticipantPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart;
|
||||
|
||||
export class ChatResponseWarningPart {
|
||||
value: MarkdownString;
|
||||
@ -87,7 +92,7 @@ declare module 'vscode' {
|
||||
/**
|
||||
* The reference target.
|
||||
*/
|
||||
value: Uri | Location | { variableName: string; value?: Uri | Location };
|
||||
value: Uri | Location | { variableName: string; value?: Uri | Location } | string;
|
||||
|
||||
/**
|
||||
* The icon for the reference.
|
||||
@ -109,7 +114,7 @@ declare module 'vscode' {
|
||||
* @param value A uri or location
|
||||
* @param iconPath Icon for the reference shown in UI
|
||||
*/
|
||||
constructor(value: Uri | Location | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | {
|
||||
constructor(value: Uri | Location | { variableName: string; value?: Uri | Location } | string, iconPath?: Uri | ThemeIcon | {
|
||||
/**
|
||||
* The icon path for the light theme.
|
||||
*/
|
||||
@ -121,6 +126,26 @@ declare module 'vscode' {
|
||||
}, options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } });
|
||||
}
|
||||
|
||||
export class ChatResponseMovePart {
|
||||
|
||||
readonly uri: Uri;
|
||||
readonly range: Range;
|
||||
|
||||
constructor(uri: Uri, range: Range);
|
||||
}
|
||||
|
||||
// Extended to add `SymbolInformation`. Would also be added to `constructor`.
|
||||
export interface ChatResponseAnchorPart {
|
||||
/**
|
||||
* The target of this anchor.
|
||||
*
|
||||
* If this is a {@linkcode Uri} or {@linkcode Location}, this is rendered as a normal link.
|
||||
*
|
||||
* If this is a {@linkcode SymbolInformation}, this is rendered as a symbol link.
|
||||
*/
|
||||
value2: Uri | Location | SymbolInformation;
|
||||
}
|
||||
|
||||
export interface ChatResponseStream {
|
||||
|
||||
/**
|
||||
@ -135,6 +160,7 @@ declare module 'vscode' {
|
||||
|
||||
textEdit(target: Uri, edits: TextEdit | TextEdit[]): void;
|
||||
markdownWithVulnerabilities(value: string | MarkdownString, vulnerabilities: ChatVulnerability[]): void;
|
||||
codeblockUri(uri: Uri): void;
|
||||
detectedParticipant(participant: string, command?: ChatCommand): void;
|
||||
push(part: ChatResponsePart | ChatResponseTextEditPart | ChatResponseDetectedParticipantPart | ChatResponseWarningPart | ChatResponseProgressPart2): void;
|
||||
|
||||
@ -161,7 +187,7 @@ declare module 'vscode' {
|
||||
|
||||
reference(value: Uri | Location | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | { light: Uri; dark: Uri }): void;
|
||||
|
||||
reference2(value: Uri | Location | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | { light: Uri; dark: Uri }, options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } }): void;
|
||||
reference2(value: Uri | Location | string | { variableName: string; value?: Uri | Location }, iconPath?: Uri | ThemeIcon | { light: Uri; dark: Uri }, options?: { status?: { description: string; kind: ChatResponseReferencePartStatusKind } }): void;
|
||||
|
||||
codeCitation(value: Uri, license: string, snippet: string): void;
|
||||
|
||||
@ -195,8 +221,37 @@ declare module 'vscode' {
|
||||
documents: ChatDocumentContext[];
|
||||
}
|
||||
|
||||
export interface ChatParticipant {
|
||||
/**
|
||||
* Provide a set of variables that can only be used with this participant.
|
||||
*/
|
||||
participantVariableProvider?: { provider: ChatParticipantCompletionItemProvider; triggerCharacters: string[] };
|
||||
}
|
||||
|
||||
export interface ChatParticipantCompletionItemProvider {
|
||||
provideCompletionItems(query: string, token: CancellationToken): ProviderResult<ChatCompletionItem[]>;
|
||||
}
|
||||
|
||||
export class ChatCompletionItem {
|
||||
id: string;
|
||||
label: string | CompletionItemLabel;
|
||||
values: ChatVariableValue[];
|
||||
fullName?: string;
|
||||
icon?: ThemeIcon;
|
||||
insertText?: string;
|
||||
detail?: string;
|
||||
documentation?: string | MarkdownString;
|
||||
command?: Command;
|
||||
|
||||
constructor(id: string, label: string | CompletionItemLabel, values: ChatVariableValue[]);
|
||||
}
|
||||
|
||||
export type ChatExtendedRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
|
||||
|
||||
export interface ChatRequest {
|
||||
toolInvocationToken: ChatParticipantToolToken;
|
||||
}
|
||||
|
||||
export interface ChatResult {
|
||||
nextQuestion?: {
|
||||
prompt: string;
|
||||
@ -211,19 +266,13 @@ declare module 'vscode' {
|
||||
*/
|
||||
export function createChatParticipant(id: string, handler: ChatExtendedRequestHandler): ChatParticipant;
|
||||
|
||||
/**
|
||||
* Current version of the proposal. Changes whenever backwards-incompatible changes are made.
|
||||
* If a new feature is added that doesn't break existing code, the version is not incremented. When the extension uses this new feature, it should set its engines.vscode version appropriately.
|
||||
* But if a change is made to an existing feature that would break existing code, the version should be incremented.
|
||||
* The chat extension should not activate if it doesn't support the current version.
|
||||
*/
|
||||
export const _version: 1 | number;
|
||||
export function registerChatParticipantDetectionProvider(participantDetectionProvider: ChatParticipantDetectionProvider): Disposable;
|
||||
}
|
||||
|
||||
export interface ChatParticipantMetadata {
|
||||
participant: string;
|
||||
command?: string;
|
||||
disambiguation: { categoryName: string; description: string; examples: string[] }[];
|
||||
disambiguation: { category: string; description: string; examples: string[] }[];
|
||||
}
|
||||
|
||||
export interface ChatParticipantDetectionResult {
|
||||
@ -231,6 +280,10 @@ declare module 'vscode' {
|
||||
command?: string;
|
||||
}
|
||||
|
||||
export interface ChatParticipantDetectionProvider {
|
||||
provideParticipantDetection(chatRequest: ChatRequest, context: ChatContext, options: { participants?: ChatParticipantMetadata[]; location: ChatLocation }, token: CancellationToken): ProviderResult<ChatParticipantDetectionResult>;
|
||||
}
|
||||
|
||||
/*
|
||||
* User action events
|
||||
*/
|
||||
@ -257,6 +310,8 @@ declare module 'vscode' {
|
||||
codeBlockIndex: number;
|
||||
totalCharacters: number;
|
||||
newFile?: boolean;
|
||||
userAction?: string;
|
||||
codeMapper?: string;
|
||||
}
|
||||
|
||||
export interface ChatTerminalAction {
|
||||
@ -299,4 +354,8 @@ declare module 'vscode' {
|
||||
*/
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface ChatResultFeedback {
|
||||
readonly unhelpfulReason?: string;
|
||||
}
|
||||
}
|
||||
|
||||
4
chat-sample/vscode.proposed.lmTools.d.ts
vendored
4
chat-sample/vscode.proposed.lmTools.d.ts
vendored
@ -103,7 +103,11 @@ declare module 'vscode' {
|
||||
export function invokeTool(id: string, options: LanguageModelToolInvocationOptions, token: CancellationToken): Thenable<LanguageModelToolResult>;
|
||||
}
|
||||
|
||||
export type ChatParticipantToolToken = unknown;
|
||||
|
||||
export interface LanguageModelToolInvocationOptions {
|
||||
toolInvocationToken: ChatParticipantToolToken | undefined;
|
||||
|
||||
/**
|
||||
* Parameters with which to invoke the tool.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user