languageModels.ts ×13

Frontier kind: Code frontier

unlabeled · c_99cd3edf1d86

37 tests · 32280 LOC · 158 files · introduces 0 tests · 51 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges51 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3283 ranges32280 lines · 158 files · Browse complete extent
All tests (intent)
37 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.

1 file ranked by introduced lines: 51 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/languageModels.ts 51 introduced LOC · 13 ranges

Open complete file

1086
1087 private async _resolveAllLanguageModels(vendorId: string, silent: boolean): Promise<void> {
1089 > const vendor = this._vendors.get(vendorId);
1090 >
1091 > if (!vendor) {
1092 return;
1093 }
1095 > // If a provider is already registered (e.g. a renderer-side provider
1096 > // such as the agent host), skip the activation wait — there's nothing
1097 > // more for an extension to contribute, and waiting would block on
1098 > // extension host startup unnecessarily.
1099 > let provider = this._providers.get(vendorId);
1100 > if (!provider) {
1101 // Activate extensions before requesting to resolve the models
1102 await this._extensionService.activateByEvent(`onLanguageModelChatProvider:${vendorId}`);
1103 provider = this._providers.get(vendorId);
1104 }
1105 > if (!provider) { languageModels.ts
1106 this._logService.warn(`[LM] No provider registered for vendor ${vendorId}`);
1107 return;
1108 }
1110 > return this._resolveLMSequencer.queue(vendorId, async () => {
1111 >
1112 > const allModels: ILanguageModelChatMetadataAndIdentifier[] = [];
1113 > const languageModelsGroups: ILanguageModelsGroup[] = [];
1114 >
1115 > try {
1116 > const models = await provider.provideLanguageModelChatInfo({ silent }, CancellationToken.None);
1117 > if (models.length) {
1118 allModels.push(...models);
1119 const modelIdentifiers = [];
1132 languageModelsGroups.push({ modelIdentifiers });
1133 }
1134 > } catch (error) { languageModels.ts
1135 languageModelsGroups.push({
1136 modelIdentifiers: [],
1141 });
1142 }
1144 > const groups = this._languageModelsConfigurationService.getLanguageModelsProviderGroups();
1145 > const perModelConfigurations = new Map<string, IStringDictionary<unknown>>();
1146 > for (const group of groups) {
1147 if (group.vendor !== vendorId) {
1148 continue;
1208 }
1209 }
1211 > const wasResolved = this._modelsGroups.has(vendorId);
1212 > const oldGroups = this._modelsGroups.get(vendorId) ?? [];
1213 > this._modelsGroups.set(vendorId, languageModelsGroups);
1214 > const oldModels = this._clearModelCache(vendorId);
1215 > let hasChanges = !wasResolved;
1216 > for (const model of allModels) {
1217 if (this._modelCache.has(model.identifier)) {
1218 this._logService.warn(`[LM] Model ${model.identifier} is already registered. Skipping.`);
1223 oldModels.delete(model.identifier);
1224 }
1225 > this._logService.trace(`[LM] Resolved language models for vendor ${vendorId}`, allModels); languageModels.ts
1226 > hasChanges = hasChanges || oldModels.size > 0;
1227 >
1228 > // Also detect group structure changes (added/removed groups, status changes)
1229 > // so the UI updates even when individual models haven't changed
1230 > if (!hasChanges) {
1231 hasChanges = this._hasGroupStructureChanged(oldGroups, languageModelsGroups);
1232 }
1234 > // Update per-model configurations for this vendor
1235 > this._clearModelConfigurations(vendorId);
1236 > for (const [identifier, config] of perModelConfigurations) {
1237 if (this._modelCache.has(identifier)) {
1238 this._modelConfigurations.set(identifier, config);
1239 }
1240 }
1242 > if (hasChanges) {
1243 > this._onLanguageModelChange.fire(vendorId);
1244 > } else {
1245 this._logService.trace(`[LM] No changes in language models for vendor ${vendorId}`);
1246 }
1247 > }); languageModels.ts
1248 > }
1249
1250 private _hasGroupStructureChanged(oldGroups: readonly ILanguageModelsGroup[], newGroups: readonly ILanguageModelsGroup[]): boolean {
2114
2115 private _clearModelConfigurations(vendor: string): void {
2116 > for (const [id] of this._modelConfigurations) { languageModels.ts
2117 if (this._modelCache.get(id)?.vendor === vendor || id.startsWith(`${vendor}/`)) {
2118 this._modelConfigurations.delete(id);
2119 }
2120 }
2122
2123 private async _resolveConfiguration(group: ILanguageModelsProviderGroup, schema: IJSONSchema | undefined): Promise<IStringDictionary<unknown>> {