Skip to content

Commit

Permalink
starting
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Jan 16, 2025
1 parent 5945fda commit 02c9904
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
39 changes: 39 additions & 0 deletions src/client/copilotTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as vscode from 'vscode';

interface IGetActiveEnvironment {
filePath: string;
}

export class GetErrorsTool implements vscode.LanguageModelTool<IGetActiveEnvironment> {
public static readonly toolName = 'getActiveEnvironment';

constructor(private isThisTrue: boolean) {}

invoke(
options: vscode.LanguageModelToolInvocationOptions<IGetActiveEnvironment>,
_token: vscode.CancellationToken,
): vscode.ProviderResult<vscode.LanguageModelToolResult> {
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<IGetActiveEnvironment>,
_token: vscode.CancellationToken,
): vscode.ProviderResult<vscode.PreparedToolInvocation> {
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)));
}
3 changes: 3 additions & 0 deletions src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

/// //////////////////////////
Expand Down

0 comments on commit 02c9904

Please sign in to comment.