Skip to content

Commit 27e5400

Browse files
committed
updates
1 parent b30c743 commit 27e5400

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/client/chat/installPackagesTool.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IModuleInstaller } from '../common/installer/types';
2626
import { ModuleInstallerType } from '../pythonEnvironments/info';
2727
import { IDiscoveryAPI } from '../pythonEnvironments/base/locator';
2828
import { getEnvExtApi, useEnvExtension } from '../envExt/api.internal';
29+
import { traceError } from '../logging';
2930

3031
export interface IInstallPackageArgs extends IResourceReference {
3132
packageList: string[];
@@ -54,11 +55,16 @@ export class InstallPackagesTool implements LanguageModelTool<IInstallPackageArg
5455
if (useEnvExtension()) {
5556
const api = await getEnvExtApi();
5657
const env = await api.getEnvironment(resourcePath);
57-
if (env) {
58+
if (env && (api as Partial<typeof api>).installPackages) {
5859
await raceCancellationError(api.installPackages(env, options.input.packageList), token);
60+
const resultMessage = `Successfully installed ${packagePlurality}: ${options.input.packageList.join(
61+
', ',
62+
)}`;
63+
return new LanguageModelToolResult([new LanguageModelTextPart(resultMessage)]);
64+
}
65+
if (env && !(api as Partial<typeof api>).installPackages) {
66+
traceError(`API does not expose installPackages method for environment: ${env.displayName}`);
5967
}
60-
const resultMessage = `Successfully installed ${packagePlurality}: ${options.input.packageList.join(', ')}`;
61-
return new LanguageModelToolResult([new LanguageModelTextPart(resultMessage)]);
6268
}
6369

6470
try {

0 commit comments

Comments
 (0)