File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed
panels/ai_assistance/agents Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,33 @@ describeWithEnvironment('AidaClient', () => {
144144 } ) ;
145145 } ) ;
146146
147+ it ( 'adds no model id if configured as empty string' , ( ) => {
148+ updateHostConfig ( {
149+ aidaAvailability : {
150+ disallowLogging : false ,
151+ } ,
152+ devToolsConsoleInsights : {
153+ enabled : true ,
154+ modelId : '' ,
155+ temperature : 0.5 ,
156+ } ,
157+ } ) ;
158+ const request = Host . AidaClient . AidaClient . buildConsoleInsightsRequest ( 'foo' ) ;
159+ assert . deepEqual ( request , {
160+ current_message : { parts : [ { text : 'foo' } ] , role : Host . AidaClient . Role . USER } ,
161+ client : 'CHROME_DEVTOOLS' ,
162+ options : {
163+ temperature : 0.5 ,
164+ } ,
165+ client_feature : 1 ,
166+ functionality_type : 2 ,
167+ metadata : {
168+ disable_user_content_logging : false ,
169+ client_version : 'unit_test' ,
170+ } ,
171+ } ) ;
172+ } ) ;
173+
147174 it ( 'adds metadata to disallow logging' , ( ) => {
148175 updateHostConfig ( {
149176 aidaAvailability : {
Original file line number Diff line number Diff line change @@ -267,12 +267,6 @@ export class AidaBlockError extends Error {}
267267export class AidaClient {
268268 static buildConsoleInsightsRequest ( input : string ) : AidaRequest {
269269 const { hostConfig} = Root . Runtime ;
270- let temperature = - 1 ;
271- let modelId = '' ;
272- if ( hostConfig . devToolsConsoleInsights ?. enabled ) {
273- temperature = hostConfig . devToolsConsoleInsights . temperature ?? - 1 ;
274- modelId = hostConfig . devToolsConsoleInsights . modelId || '' ;
275- }
276270 const disallowLogging = hostConfig . aidaAvailability ?. disallowLogging ?? true ;
277271 const chromeVersion = Root . Runtime . getChromeVersion ( ) ;
278272 if ( ! chromeVersion ) {
@@ -289,6 +283,12 @@ export class AidaClient {
289283 } ,
290284 } ;
291285
286+ let temperature = - 1 ;
287+ let modelId ;
288+ if ( hostConfig . devToolsConsoleInsights ?. enabled ) {
289+ temperature = hostConfig . devToolsConsoleInsights . temperature ?? - 1 ;
290+ modelId = hostConfig . devToolsConsoleInsights . modelId ;
291+ }
292292 if ( temperature >= 0 ) {
293293 request . options ??= { } ;
294294 request . options . temperature = temperature ;
Original file line number Diff line number Diff line change @@ -87,6 +87,14 @@ describeWithEnvironment('AiAgent', () => {
8787 ) ;
8888 } ) ;
8989
90+ it ( 'builds a request without a model id it is configured as an empty string' , async ( ) => {
91+ const agent = new AiAgentMock ( {
92+ aidaClient : mockAidaClient ( ) ,
93+ } ) ;
94+ agent . options . modelId = '' ;
95+ assert . isUndefined ( agent . buildRequest ( { text : 'test input' } , Host . AidaClient . Role . USER ) . options ?. model_id ) ;
96+ } ) ;
97+
9098 it ( 'builds a request with logging' , async ( ) => {
9199 const agent = new AiAgentMock ( {
92100 aidaClient : mockAidaClient ( ) ,
Original file line number Diff line number Diff line change @@ -302,7 +302,7 @@ export abstract class AiAgent<T> {
302302 ...( enableAidaFunctionCalling ? { function_declarations : declarations } : { } ) ,
303303 options : {
304304 temperature : validTemperature ( this . options . temperature ) ,
305- model_id : this . options . modelId ,
305+ model_id : this . options . modelId || undefined ,
306306 } ,
307307 metadata : {
308308 disable_user_content_logging : ! ( this . #serverSideLoggingEnabled ?? false ) ,
You can’t perform that action at this time.
0 commit comments