Skip to content

Commit 8430d87

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[AI] Do not send an empty string as a model id
Bug: none Change-Id: I50bdde2a8275d279f8578ed2edf10a706c962b35 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6308775 Commit-Queue: Alex Rudenko <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]>
1 parent 0ed45a6 commit 8430d87

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

front_end/core/host/AidaClient.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff 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: {

front_end/core/host/AidaClient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,6 @@ export class AidaBlockError extends Error {}
267267
export 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;

front_end/panels/ai_assistance/agents/AiAgent.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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(),

front_end/panels/ai_assistance/agents/AiAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)