Skip to content

Commit 778b195

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[AI Assistance] Allow preamble to be undefined
Bug: 393267670 Change-Id: I4ff9e5209617b3dfd81b5d0c6cd7238ced52c6bb Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6233935 Commit-Queue: Nikolay Vitkov <[email protected]> Commit-Queue: Alex Rudenko <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]> Auto-Submit: Alex Rudenko <[email protected]>
1 parent fd1e8f5 commit 778b195

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ describeWithEnvironment('AiAgent', () => {
147147
assert.isUndefined(request.historical_contexts);
148148
});
149149

150+
it('builds a request without preamble', async () => {
151+
class AiAgentMockWithoutPreamble extends AiAgent<unknown> {
152+
type = AiAssistance.AgentType.STYLING;
153+
override preamble = undefined;
154+
// eslint-disable-next-line require-yield
155+
override async * handleContextDetails(): AsyncGenerator<AiAssistance.ContextResponse, void, void> {
156+
return;
157+
}
158+
clientFeature: Host.AidaClient.ClientFeature = 0;
159+
userTier: undefined;
160+
options: AiAssistance.RequestOptions = {
161+
temperature: 1,
162+
modelId: 'test model',
163+
};
164+
}
165+
166+
const agent = new AiAgentMockWithoutPreamble({
167+
aidaClient: {} as Host.AidaClient.AidaClient,
168+
});
169+
const request = agent.buildRequest({text: 'test input'}, Host.AidaClient.Role.USER);
170+
assert.deepEqual(request.current_message?.parts[0], {text: 'test input'});
171+
assert.isUndefined(request.preamble);
172+
assert.isUndefined(request.historical_contexts);
173+
});
174+
150175
it('builds a request with chat history', async () => {
151176
let count = 0;
152177
async function* generateAndAnswer() {

front_end/panels/ai_assistance/agents/AiAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export abstract class AiAgent<T> {
219219
readonly #sessionId: string = crypto.randomUUID();
220220
#aidaClient: Host.AidaClient.AidaClient;
221221
#serverSideLoggingEnabled: boolean;
222-
abstract readonly preamble: string;
222+
abstract readonly preamble: string|undefined;
223223
abstract readonly options: RequestOptions;
224224
abstract readonly clientFeature: Host.AidaClient.ClientFeature;
225225
abstract readonly userTier: string|undefined;

0 commit comments

Comments
 (0)