File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import { IModuleInstaller } from '../common/installer/types';
2626import { ModuleInstallerType } from '../pythonEnvironments/info' ;
2727import { IDiscoveryAPI } from '../pythonEnvironments/base/locator' ;
2828import { getEnvExtApi , useEnvExtension } from '../envExt/api.internal' ;
29+ import { traceError } from '../logging' ;
2930
3031export 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 {
You can’t perform that action at this time.
0 commit comments