Skip to content

Commit 8cceca5

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[Freestyler] Add AiAgent test to build
The file was omitted so the test were never run. Fixed the test and re-wrote a part to be easier to use Bug: none Change-Id: I18e635d07eee297e161fe6ad8acc87c29fff13f6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5962000 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Alex Rudenko <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 641a621 commit 8cceca5

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

front_end/panels/freestyler/AiAgent.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AiAgentMock extends AiAgent<unknown> {
2424

2525
options: Freestyler.AidaRequestOptions = {
2626
temperature: 1,
27-
model_id: 'test model',
27+
modelId: 'test model',
2828
};
2929
}
3030

@@ -110,7 +110,7 @@ describeWithEnvironment('AiAgent', () => {
110110
aidaClient: {} as Host.AidaClient.AidaClient,
111111
});
112112
const request = agent.buildRequest({input: 'test input'});
113-
assert.strictEqual(request.metadata?.string_session_id, 'session_id');
113+
assert.strictEqual(request.metadata?.string_session_id, 'sessionId');
114114
});
115115

116116
it('builds a request with preamble', async () => {

front_end/panels/freestyler/AiAgent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ export interface HistoryChunk {
9898

9999
export interface AidaRequestOptions {
100100
temperature?: number;
101-
// eslint-disable-next-line @typescript-eslint/naming-convention
102-
model_id?: string;
101+
modelId?: string;
103102
}
104103

105104
interface AgentOptions {
@@ -205,7 +204,11 @@ export abstract class AiAgent<T> {
205204
// eslint-disable-next-line @typescript-eslint/naming-convention
206205
chat_history: this.#history.size ? this.#historyEntry : undefined,
207206
client: Host.AidaClient.CLIENT_NAME,
208-
options: this.options,
207+
options: {
208+
temperature: AiAgent.validTemperature(this.options.temperature),
209+
// eslint-disable-next-line @typescript-eslint/naming-convention
210+
model_id: this.options.modelId,
211+
},
209212
metadata: {
210213
disable_user_content_logging: !(this.#serverSideLoggingEnabled ?? false),
211214
string_session_id: this.#sessionId,

front_end/panels/freestyler/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ ts_library("unittests") {
7777
testonly = true
7878

7979
sources = [
80+
"AiAgent.test.ts",
8081
"ChangeManager.test.ts",
8182
"DrJonesFileAgent.test.ts",
8283
"DrJonesNetworkAgent.test.ts",

front_end/panels/freestyler/DrJonesFileAgent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ export class DrJonesFileAgent extends AiAgent<Workspace.UISourceCode.UISourceCod
7676
}
7777
get options(): AidaRequestOptions {
7878
const config = Common.Settings.Settings.instance().getHostConfig();
79-
const temperature = AiAgent.validTemperature(config.devToolsAiAssistanceFileAgentDogfood?.temperature);
79+
const temperature = config.devToolsAiAssistanceFileAgentDogfood?.temperature;
8080
const modelId = config.devToolsAiAssistanceFileAgentDogfood?.modelId;
8181

8282
return {
8383
temperature,
84-
model_id: modelId,
84+
modelId,
8585
};
8686
}
8787

front_end/panels/freestyler/DrJonesNetworkAgent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ export class DrJonesNetworkAgent extends AiAgent<SDK.NetworkRequest.NetworkReque
109109
}
110110
get options(): AidaRequestOptions {
111111
const config = Common.Settings.Settings.instance().getHostConfig();
112-
const temperature = AiAgent.validTemperature(config.devToolsExplainThisResourceDogfood?.temperature);
112+
const temperature = config.devToolsExplainThisResourceDogfood?.temperature;
113113
const modelId = config.devToolsExplainThisResourceDogfood?.modelId;
114114

115115
return {
116116
temperature,
117-
model_id: modelId,
117+
modelId,
118118
};
119119
}
120120

front_end/panels/freestyler/DrJonesPerformanceAgent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ export class DrJonesPerformanceAgent extends AiAgent<Trace.Helpers.TreeHelpers.A
8080
}
8181
get options(): AidaRequestOptions {
8282
const config = Common.Settings.Settings.instance().getHostConfig();
83-
const temperature = AiAgent.validTemperature(config.devToolsAiAssistancePerformanceAgentDogfood?.temperature);
83+
const temperature = config.devToolsAiAssistancePerformanceAgentDogfood?.temperature;
8484
const modelId = config.devToolsAiAssistancePerformanceAgentDogfood?.modelId;
8585

8686
return {
8787
temperature,
88-
model_id: modelId,
88+
modelId,
8989
};
9090
}
9191

front_end/panels/freestyler/FreestylerAgent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ export class FreestylerAgent extends AiAgent<SDK.DOMModel.DOMNode> {
208208

209209
get options(): AidaRequestOptions {
210210
const config = Common.Settings.Settings.instance().getHostConfig();
211-
const temperature = AiAgent.validTemperature(config.devToolsFreestyler?.temperature);
211+
const temperature = config.devToolsFreestyler?.temperature;
212212
const modelId = config.devToolsFreestyler?.modelId;
213213

214214
return {
215215
temperature,
216-
model_id: modelId,
216+
modelId,
217217
};
218218
}
219219

0 commit comments

Comments
 (0)