@@ -13,7 +13,7 @@ import { AutoChatEndpoint, resolveAutoChatEndpoint } from '../../../platform/end
13
13
import { ChatEndpoint } from '../../../platform/endpoint/node/chatEndpoint' ;
14
14
import { EmbeddingEndpoint } from '../../../platform/endpoint/node/embeddingsEndpoint' ;
15
15
import { IModelMetadataFetcher , ModelMetadataFetcher } from '../../../platform/endpoint/node/modelMetadataFetcher' ;
16
- import { ProxyExperimentEndpoint } from '../../../platform/endpoint/node/proxyExperimentEndpoint' ;
16
+ import { applyExperimentModifications , getCustomDefaultModelExperimentConfig , ProxyExperimentEndpoint } from '../../../platform/endpoint/node/proxyExperimentEndpoint' ;
17
17
import { ExtensionContributedChatEndpoint } from '../../../platform/endpoint/vscode-node/extChatEndpoint' ;
18
18
import { IEnvService } from '../../../platform/env/common/envService' ;
19
19
import { ILogService } from '../../../platform/log/common/logService' ;
@@ -24,6 +24,7 @@ import { ITelemetryService } from '../../../platform/telemetry/common/telemetry'
24
24
import { TokenizerType } from '../../../util/common/tokenizer' ;
25
25
import { IInstantiationService , ServicesAccessor } from '../../../util/vs/platform/instantiation/common/instantiation' ;
26
26
27
+
27
28
export class ProductionEndpointProvider implements IEndpointProvider {
28
29
29
30
declare readonly _serviceBrand : undefined ;
@@ -90,7 +91,7 @@ export class ProductionEndpointProvider implements IEndpointProvider {
90
91
private getOrCreateProxyExperimentEndpointInstance ( name : string , id : string , endpoint : IChatEndpoint ) : IChatEndpoint {
91
92
let chatEndpoint = this . _chatEndpoints . get ( id ) ;
92
93
if ( ! chatEndpoint ) {
93
- chatEndpoint = new ProxyExperimentEndpoint ( name , id , endpoint ) ;
94
+ chatEndpoint = new ProxyExperimentEndpoint ( name , id , endpoint , /* isDefault: */ true ) ;
94
95
this . _chatEndpoints . set ( id , chatEndpoint ) ;
95
96
}
96
97
return chatEndpoint ;
@@ -104,22 +105,11 @@ export class ProductionEndpointProvider implements IEndpointProvider {
104
105
this . _embeddingEndpoints . set ( modelId , embeddingEndpoint ) ;
105
106
}
106
107
return embeddingEndpoint ;
107
-
108
- }
109
-
110
- private getExperimentData ( ) : { selected : string ; name : string ; id : string } | undefined {
111
- const selected = this . _expService . getTreatmentVariable < string > ( 'vscode' , 'custommodel1' ) ;
112
- const id = this . _expService . getTreatmentVariable < string > ( 'vscode' , 'custommodel1.id' ) ;
113
- const name = this . _expService . getTreatmentVariable < string > ( 'vscode' , 'custommodel1.name' ) ;
114
- if ( selected && id && name ) {
115
- return { selected, id, name } ;
116
- }
117
- return undefined ;
118
108
}
119
109
120
110
async getChatEndpoint ( requestOrFamilyOrModel : LanguageModelChat | ChatRequest | ChatEndpointFamily ) : Promise < IChatEndpoint > {
121
111
this . _logService . logger . trace ( `Resolving chat model` ) ;
122
- const experimentModelConfig = this . getExperimentData ( ) ;
112
+ const experimentModelConfig = getCustomDefaultModelExperimentConfig ( this . _expService ) ;
123
113
124
114
if ( this . _overridenChatModel ) {
125
115
// Override, only allowed by internal users. Sets model based on setting
@@ -142,16 +132,20 @@ export class ProductionEndpointProvider implements IEndpointProvider {
142
132
let endpoint : IChatEndpoint ;
143
133
if ( typeof requestOrFamilyOrModel === 'string' ) {
144
134
// The family case, resolve the chat model for the passed in family
145
- const modelMetadata = await this . _modelFetcher . getChatModelFromFamily ( requestOrFamilyOrModel ) ;
146
- endpoint = this . getOrCreateChatEndpointInstance ( modelMetadata ) ;
135
+ let modelMetadata = await this . _modelFetcher . getChatModelFromFamily ( requestOrFamilyOrModel ) ;
136
+ modelMetadata = applyExperimentModifications ( modelMetadata , experimentModelConfig ) ;
137
+ endpoint = this . getOrCreateChatEndpointInstance ( modelMetadata ! ) ;
147
138
} else {
148
139
const model = 'model' in requestOrFamilyOrModel ? requestOrFamilyOrModel . model : requestOrFamilyOrModel ;
149
140
if ( experimentModelConfig && model && model . id === experimentModelConfig . id ) {
150
141
endpoint = ( await this . getAllChatEndpoints ( ) ) . find ( e => e . model === experimentModelConfig . selected ) || await this . getChatEndpoint ( 'gpt-4.1' ) ;
151
142
} else if ( model && model . vendor === 'copilot' && model . id === AutoChatEndpoint . id ) {
152
143
return resolveAutoChatEndpoint ( this , this . _expService , ( requestOrFamilyOrModel as ChatRequest ) ?. prompt ) ;
153
144
} else if ( model && model . vendor === 'copilot' ) {
154
- const modelMetadata = await this . _modelFetcher . getChatModelFromApiModel ( model ) ;
145
+ let modelMetadata = await this . _modelFetcher . getChatModelFromApiModel ( model ) ;
146
+ if ( modelMetadata ) {
147
+ modelMetadata = applyExperimentModifications ( modelMetadata , experimentModelConfig ) ;
148
+ }
155
149
// If we fail to resolve a model since this is panel we give GPT-4.1. This really should never happen as the picker is powered by the same service.
156
150
endpoint = modelMetadata ? this . getOrCreateChatEndpointInstance ( modelMetadata ) : await this . getChatEndpoint ( 'gpt-4.1' ) ;
157
151
} else if ( model ) {
@@ -194,9 +188,10 @@ export class ProductionEndpointProvider implements IEndpointProvider {
194
188
const models : IChatModelInformation [ ] = await this . _modelFetcher . getAllChatModels ( ) ;
195
189
const chatEndpoints = [ ] ;
196
190
197
- const experimentModelConfig = this . getExperimentData ( ) ;
191
+ const experimentModelConfig = getCustomDefaultModelExperimentConfig ( this . _expService ) ;
198
192
199
- for ( const model of models ) {
193
+ for ( let model of models ) {
194
+ model = applyExperimentModifications ( model , experimentModelConfig ) ?? model ;
200
195
const chatEndpoint = this . getOrCreateChatEndpointInstance ( model ) ;
201
196
chatEndpoints . push ( chatEndpoint ) ;
202
197
if ( experimentModelConfig && chatEndpoint . model === experimentModelConfig . selected ) {
0 commit comments