diff --git a/package-lock.json b/package-lock.json index eaeb530cc933..35b52f99f46c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1796,9 +1796,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.93.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.93.0.tgz", - "integrity": "sha512-kUK6jAHSR5zY8ps42xuW89NLcBpw1kOabah7yv38J8MyiYuOHxLQBi0e7zeXbQgVefDy/mZZetqEFC+Fl5eIEQ==", + "version": "1.96.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.96.0.tgz", + "integrity": "sha512-qvZbSZo+K4ZYmmDuaodMbAa67Pl6VDQzLKFka6rq+3WUTY4Kro7Bwoi0CuZLO/wema0ygcmpwow7zZfPJTs5jg==", "dev": true }, "node_modules/@types/which": { @@ -16065,9 +16065,9 @@ "dev": true }, "@types/vscode": { - "version": "1.93.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.93.0.tgz", - "integrity": "sha512-kUK6jAHSR5zY8ps42xuW89NLcBpw1kOabah7yv38J8MyiYuOHxLQBi0e7zeXbQgVefDy/mZZetqEFC+Fl5eIEQ==", + "version": "1.96.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.96.0.tgz", + "integrity": "sha512-qvZbSZo+K4ZYmmDuaodMbAa67Pl6VDQzLKFka6rq+3WUTY4Kro7Bwoi0CuZLO/wema0ygcmpwow7zZfPJTs5jg==", "dev": true }, "@types/which": { diff --git a/package.json b/package.json index 7f7df96289d7..eeda13a75123 100644 --- a/package.json +++ b/package.json @@ -1461,6 +1461,28 @@ "fileMatch": "meta.yaml", "url": "./schemas/conda-meta.json" } + ], + "languageModelTools": [ + { + "name": "python_get_active_environment", + "displayName": "Get Python Active Environment", + "modelDescription": "Gets the active Python environment for a given workspace.", + "tags": [ + ], + "icon": "$(files)", + "inputSchema": { + "type": "object", + "properties": { + "workspacePath": { + "type": "string" + } + }, + "required": [ + "workspacePath" + ] + }, + "canBeReferencedInPrompt": true + } ] }, "copilot": { diff --git a/src/client/copilotTools.ts b/src/client/copilotTools.ts new file mode 100644 index 000000000000..f2308f224d26 --- /dev/null +++ b/src/client/copilotTools.ts @@ -0,0 +1,39 @@ +import * as vscode from 'vscode'; + +interface IGetActiveEnvironment { + filePath: string; +} + +export class GetErrorsTool implements vscode.LanguageModelTool { + public static readonly toolName = 'getActiveEnvironment'; + + constructor(private isThisTrue: boolean) {} + + invoke( + options: vscode.LanguageModelToolInvocationOptions, + _token: vscode.CancellationToken, + ): vscode.ProviderResult { + const parameters: IGetActiveEnvironment = options.input; + if (!parameters.filePath) { + throw new Error('Invalid input'); + } + this.isThisTrue = true; + console.log('This is true', this.isThisTrue); + return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart('invoked finished!')]); + } + + prepareInvocation( + options: vscode.LanguageModelToolInvocationPrepareOptions, + _token: vscode.CancellationToken, + ): vscode.ProviderResult { + console.log(this.isThisTrue, options); + console.log('preparing invocation'); + return { + invocationMessage: 'preparing the invocation..... ', + }; + } +} + +export function registerChatTools(context: vscode.ExtensionContext): void { + context.subscriptions.push(vscode.lm.registerTool('python_get_active_environment', new GetErrorsTool(false))); +} diff --git a/src/client/extensionActivation.ts b/src/client/extensionActivation.ts index 38f2d6a56277..ab02c801fe85 100644 --- a/src/client/extensionActivation.ts +++ b/src/client/extensionActivation.ts @@ -55,6 +55,7 @@ import { registerReplCommands, registerReplExecuteOnEnter, registerStartNativeRe import { registerTriggerForTerminalREPL } from './terminals/codeExecution/terminalReplWatcher'; import { registerPythonStartup } from './terminals/pythonStartup'; import { registerPixiFeatures } from './pythonEnvironments/common/environmentManagers/pixi'; +import { registerChatTools } from './copilotTools'; export async function activateComponents( // `ext` is passed to any extra activation funcs. @@ -115,6 +116,8 @@ export function activateFeatures(ext: ExtensionState, _components: Components): registerStartNativeReplCommand(ext.disposables, interpreterService); registerReplCommands(ext.disposables, interpreterService, executionHelper, commandManager); registerReplExecuteOnEnter(ext.disposables, interpreterService, commandManager); + + registerChatTools(ext.context); } /// //////////////////////////