languageModels.ts ×19

Frontier kind: Code frontier

unlabeled · c_8108e3bcc981

51 tests · 32166 LOC · 158 files · introduces 0 tests · 83 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
22 ranges83 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3252 ranges32166 lines · 158 files · Browse complete extent
All tests (intent)
51 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 83 introduced LOC across 22 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/languageModels.ts 78 introduced LOC · 19 ranges

Open complete file

926
927 constructor(
928 > @IExtensionService private readonly _extensionService: IExtensionService, languageModels.ts
929 > @ILogService private readonly _logService: ILogService,
930 > @IStorageService private readonly _storageService: IStorageService,
931 > @IContextKeyService private readonly _contextKeyService: IContextKeyService,
932 > @ILanguageModelsConfigurationService private readonly _languageModelsConfigurationService: ILanguageModelsConfigurationService,
933 > @IQuickInputService private readonly _quickInputService: IQuickInputService,
934 > @ISecretStorageService private readonly _secretStorageService: ISecretStorageService,
935 > @IProductService private readonly _productService: IProductService,
936 > @IRequestService private readonly _requestService: IRequestService,
937 > @INotificationService private readonly _notificationService: INotificationService,
938 > @IOpenerService private readonly _openerService: IOpenerService,
939 > @ITelemetryService private readonly _telemetryService: ITelemetryService,
940 > ) {
941 > this._hasUserSelectableModels = ChatContextKeys.languageModelsAreUserSelectable.bindTo(_contextKeyService);
942 > this._hasNonCopilotUserSelectableModels = ChatContextKeys.nonCopilotLanguageModelsAreUserSelectable.bindTo(_contextKeyService);
943 > this._recentlyUsedModelIds = this._readRecentlyUsedModels();
944 > this._pinnedModelIds = this._readPinnedModels();
945 > this._readVisibility();
946 > this._initChatControlData();
947 >
948 > this._store.add(this.onDidChangeLanguageModels(() => {
949 let hasUserSelectable = false;
950 let hasNonCopilotUserSelectable = false;
962 this._hasNonCopilotUserSelectableModels.set(hasNonCopilotUserSelectable);
963 this._refreshModelsControlManifest();
964 > })); languageModels.ts
965 > this._store.add(this._languageModelsConfigurationService.onDidChangeLanguageModelGroups(changedGroups => this._onDidChangeLanguageModelGroups(changedGroups)));
966 >
967 > this._store.add(languageModelChatProviderExtensionPoint.setHandler((extensions, { added, removed }) => {
968 const addedVendors: IUserFriendlyLanguageModel[] = [];
969 const removedVendors: IUserFriendlyLanguageModel[] = [];
994
995 this.deltaLanguageModelChatProviderDescriptors(addedVendors, removedVendors);
996 > })); languageModels.ts
997 > }
998
999 deltaLanguageModelChatProviderDescriptors(added: IUserFriendlyLanguageModel[], removed: IUserFriendlyLanguageModel[]): void {
1000 > const addedVendorIds: string[] = []; languageModels.ts
1001 > const removedVendorIds: string[] = [];
1002 >
1003 > for (const item of added) {
1004 > if (this._vendors.has(item.vendor)) {
1005 this._logService.error(`The vendor '${item.vendor}' is already registered and cannot be registered twice`);
1006 continue;
1007 }
1008 > if (isFalsyOrWhitespace(item.vendor)) { languageModels.ts
1009 this._logService.error('The vendor field cannot be empty.');
1010 continue;
1011 }
1012 > if (item.vendor.trim() !== item.vendor) { languageModels.ts
1013 this._logService.error('The vendor field cannot start or end with whitespace.');
1014 continue;
1015 }
1016 > const vendor: ILanguageModelProviderDescriptor = { languageModels.ts
1017 > vendor: item.vendor,
1018 > displayName: item.displayName,
1019 > configuration: item.configuration,
1020 > managementCommand: item.managementCommand,
1021 > deprecation: item.deprecation,
1022 > when: item.when,
1023 > isDefault: item.vendor === COPILOT_VENDOR_ID
1024 > };
1025 > this._vendors.set(item.vendor, vendor);
1026 > addedVendorIds.push(item.vendor);
1027 > // Have some models we want from this vendor, so activate the extension
1028 > }
1029 >
1030 > for (const item of removed) {
1031 this._vendors.delete(item.vendor);
1032 this._providers.delete(item.vendor);
1035 removedVendorIds.push(item.vendor);
1036 }
1038 > for (const [vendor, _] of this._providers) {
1039 if (!this._vendors.has(vendor)) {
1040 this._providers.delete(vendor);
1041 }
1042 }
1044 > if (addedVendorIds.length > 0 || removedVendorIds.length > 0) {
1045 > this._onDidChangeLanguageModelVendors.fire([...addedVendorIds, ...removedVendorIds]);
1046 > if (removedVendorIds.length > 0) {
1047 for (const vendor of removedVendorIds) {
1048 this._onLanguageModelChange.fire(vendor);
1049 }
1050 }
1052 > }
1053
1054 private async _onDidChangeLanguageModelGroups(changedGroups: readonly ILanguageModelsProviderGroup[]): Promise<void> {
2198
2199 private _readRecentlyUsedModels(): string[] {
2200 > return this._storageService.getObject<string[]>(CHAT_MODEL_RECENTLY_USED_STORAGE_KEY, StorageScope.PROFILE, []); languageModels.ts
2201 > }
2202
2203 private _saveRecentlyUsedModels(): void {
2241
2242 private _readPinnedModels(): string[] {
2243 > return this._storageService.getObject<string[]>(CHAT_MODEL_PINNED_STORAGE_KEY, StorageScope.PROFILE, []); languageModels.ts
2244 > }
2245
2246 private _savePinnedModels(): void {
2313
2314 private _readVisibility(): void {
2315 > const raw = this._storageService.getObject<{ hiddenModels?: string[] }>(CHAT_MODEL_VISIBILITY_STORAGE_KEY, StorageScope.PROFILE, {}); languageModels.ts
2316 > this._hiddenModelIds = new Set(Array.isArray(raw?.hiddenModels) ? raw.hiddenModels : []);
2317 > }
2318
2319 private _saveVisibility(): void {
2418 //#region Chat control data
2419 private _initChatControlData(): void {
2420 > this._chatControlUrl = this._productService.chatParticipantRegistry; languageModels.ts
2421 > if (!this._chatControlUrl) {
2422 > return;
2423 > }
2424
2425 // Restore participant registry from storage
2426 const raw = this._storageService.get(CHAT_PARTICIPANT_NAME_REGISTRY_STORAGE_KEY, StorageScope.APPLICATION);
2427 try {
2428 > this._restrictedChatParticipants.set(JSON.parse(raw ?? '{}'), undefined); languageModels.ts
2429 > } catch (err) {
2430 this._storageService.remove(CHAT_PARTICIPANT_NAME_REGISTRY_STORAGE_KEY, StorageScope.APPLICATION);
2431 }
2434 const rawModels = this._storageService.get(CHAT_MODELS_CONTROL_STORAGE_KEY, StorageScope.APPLICATION);
2435 try {
2436 > const models = JSON.parse(rawModels ?? '{}'); languageModels.ts
2437 > if (isObject(models)) {
2438 this._setModelsControlManifest(models);
2439 }
2440 > } catch (err) { languageModels.ts
2441 this._storageService.remove(CHAT_MODELS_CONTROL_STORAGE_KEY, StorageScope.APPLICATION);
2442 }
2443
2444 this._refreshChatControlData();
2446
2447 private _refreshChatControlData(): void {
2503
2504 dispose() {
2505 > this._chatControlDisposed = true; languageModels.ts
2506 > this._store.dispose();
2507 > this._providers.clear();
2508 > }
2509
2510 }
src/vs/base/common/strings.ts 3 introduced LOC · 2 ranges

Open complete file

10
11 export function isFalsyOrWhitespace(str: string | undefined): boolean {
12 > if (!str || typeof str !== 'string') { strings.ts
13 return true;
14 }
15 > return str.trim().length === 0; strings.ts
16 > }
17
18 const _formatRegexp = /{(\d+)}/g;
src/vs/workbench/services/extensions/common/extensionsRegistry.ts 2 introduced LOC · 1 range

Open complete file

135 return {
136 dispose: () => {
137 > this._handler = null; extensionsRegistry.ts
138 > }
139 };
140 }