@ -44,6 +44,7 @@ export interface AiRailRow {
pinned : boolean ;
pinnedTime? : number ;
prompt? : string ;
prompts? : string [ ] ;
chat? : ChatInfo ;
solution? : SolutionInfo ;
}
@ -104,7 +105,7 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
rows = computed < AiRailRow [ ] > ( ( ) = > [
. . . this . aiChats . chats ( ) . map ( chat = > ( {
id : chat.id , title : chat.title , createdTime : chat.createdTime , pinned : ! ! chat . pinned , pinnedTime : chat.pinnedTime , prompt : chat.prompt , chat
id : chat.id , title : chat.title , createdTime : chat.createdTime , pinned : ! ! chat . pinned , pinnedTime : chat.pinnedTime , prompt : chat.prompt , prompts : chat.prompts , chat
} ) ) ,
. . . this . aiSolutions . solutions ( ) . map ( solution = > ( {
id : solution.id , title : this.aiSolutions.titleOf ( solution ) , createdTime : solution.createdTime ? ? 0 , pinned : ! ! solution . pinned , solution
@ -115,7 +116,7 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
const query = this . query ( ) . trim ( ) . toLowerCase ( ) ;
const chats = this . rows ( ) ;
if ( query ) {
const found = chats . filter ( chat = > ( chat . title ? ? '' ) . toLowerCase ( ) . includes ( query ) || ( chat . prompt ? ? '' ) . toLowerCase ( ) . includes ( query ) ) ;
const found = chats . filter ( chat = > ( chat . title ? ? '' ) . toLowerCase ( ) . includes ( query ) || ! ! this . promptWith ( chat , query ) ) ;
return found . length
? [ { label : this.translate.instant ( 'ai-assistant.chats-found' , { count : found.length } ) , chats : found } ]
: [ ] ;
@ -365,8 +366,8 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
snippetOf ( row : AiRailRow ) : { text : string ; hit : boolean } [ ] | null {
const query = this . query ( ) . trim ( ) . toLowerCase ( ) ;
const prompt = row . prompt ? ? '' ;
const at = query ? prompt . toLowerCase ( ) . indexOf ( query ) : - 1 ;
const prompt = query ? this . promptWith ( row , query ) ? ? '' : '' ;
const at = prompt . toLowerCase ( ) . indexOf ( query ) ;
if ( ! query || ( row . title ? ? '' ) . toLowerCase ( ) . includes ( query ) || at < 0 ) {
return null ;
}
@ -382,6 +383,11 @@ export class AiAssistantComponent implements OnInit, OnDestroy {
] . filter ( part = > part . text ) ;
}
private promptWith ( row : AiRailRow , query : string ) : string | undefined {
const prompts = row . prompts ? . length ? row.prompts : row.prompt ? [ row . prompt ] : [ ] ;
return prompts . find ( prompt = > prompt . toLowerCase ( ) . includes ( query ) ) ;
}
runAgain ( chat : ChatInfo ) : void {
const start = ( prompt : string | undefined ) = > {
if ( ! prompt ? . trim ( ) ) {