File tree Expand file tree Collapse file tree 2 files changed +169
-126
lines changed Expand file tree Collapse file tree 2 files changed +169
-126
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import { IModuleInstaller } from '../common/installer/types';
26
26
import { ModuleInstallerType } from '../pythonEnvironments/info' ;
27
27
import { IDiscoveryAPI } from '../pythonEnvironments/base/locator' ;
28
28
import { getEnvExtApi , useEnvExtension } from '../envExt/api.internal' ;
29
- import { traceError } from '../logging' ;
30
29
31
30
export interface IInstallPackageArgs extends IResourceReference {
32
31
packageList : string [ ] ;
@@ -55,15 +54,18 @@ export class InstallPackagesTool implements LanguageModelTool<IInstallPackageArg
55
54
if ( useEnvExtension ( ) ) {
56
55
const api = await getEnvExtApi ( ) ;
57
56
const env = await api . getEnvironment ( resourcePath ) ;
58
- if ( env && ( api as Partial < typeof api > ) . installPackages ) {
59
- await raceCancellationError ( api . installPackages ( env , options . input . packageList ) , token ) ;
57
+ if ( env ) {
58
+ await raceCancellationError ( api . managePackages ( env , { install : options . input . packageList } ) , token ) ;
60
59
const resultMessage = `Successfully installed ${ packagePlurality } : ${ options . input . packageList . join (
61
60
', ' ,
62
61
) } `;
63
62
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 } ` ) ;
63
+ } else {
64
+ return new LanguageModelToolResult ( [
65
+ new LanguageModelTextPart (
66
+ `Packages not installed. No environment found for: ${ resourcePath ?. fsPath } ` ,
67
+ ) ,
68
+ ] ) ;
67
69
}
68
70
}
69
71
You can’t perform that action at this time.
0 commit comments