File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
front_end/panels/ai_assistance/agents Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff 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 ( ) {
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments