forked from microsoft/vscode-copilot-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththinkTool.tsx
More file actions
39 lines (32 loc) · 1.41 KB
/
thinkTool.tsx
File metadata and controls
39 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type * as vscode from 'vscode';
import { LanguageModelTextPart, LanguageModelToolResult } from '../../../vscodeTypes';
import { ToolName } from '../common/toolNames';
import { ToolRegistry } from '../common/toolsRegistry';
import { checkCancellation } from './toolUtils';
interface IThinkToolParams {
thoughts: string;
}
class ThinkTool implements vscode.LanguageModelTool<IThinkToolParams> {
public static readonly toolName = ToolName.Think;
constructor() { }
async invoke(options: vscode.LanguageModelToolInvocationOptions<IThinkToolParams>, token: vscode.CancellationToken) {
const thoughts = options.input.thoughts;
if (!thoughts) {
throw new Error('Invalid arguments');
}
checkCancellation(token);
return new LanguageModelToolResult([
new LanguageModelTextPart(thoughts)
]);
}
async prepareInvocation(options: vscode.LanguageModelToolInvocationPrepareOptions<IThinkToolParams>, token: vscode.CancellationToken): Promise<vscode.PreparedToolInvocation> {
return {
invocationMessage: 'Thinking'
};
}
}
ToolRegistry.registerTool(ThinkTool);