@@ -8,6 +8,10 @@ import { Message } from './models/message';
88import { AnswersResponse } from './models/answersResponse' ;
99import { Citation , SpecialistAIResponse } from '../models/specialistAIResponse' ;
1010import EventSourceStream from '@server-sent-stream/web' ;
11+ import * as fs from 'node:fs' ;
12+ import { join } from 'path' ;
13+
14+ const promptFilePath : string = './resources/pathway_prompt.md' ;
1115
1216@Injectable ( )
1317export class PathwayService {
@@ -229,22 +233,14 @@ export class PathwayService {
229233 ) : AnswersRequest {
230234 const request : AnswersRequest = new AnswersRequest ( [ ] , shouldStream ) ;
231235
232- let combinedMessage =
233- 'Clinical question: ' +
234- clinicalQuestion +
235- '\n Clinical notes: ' +
236- clinicalNotes +
237- '\n Additional information: ' ;
238-
239- for ( const filledTemplateField of filledTemplate ) {
240- combinedMessage +=
241- filledTemplateField [ 'field' ] +
242- ': ' +
243- filledTemplateField [ 'value' ] +
244- '\n' ;
245- }
236+ const promptTemplate : string = fs
237+ . readFileSync ( join ( process . cwd ( ) , promptFilePath ) )
238+ . toString ( )
239+ . replace ( '{{question}}' , clinicalQuestion )
240+ // TODO originally, this should be populated template, but since we're still not generating correct populated template, use clinical notes for now
241+ . replace ( '{{notes}}' , clinicalNotes ) ;
246242
247- request . messages . push ( new Message ( 'user' , combinedMessage ) ) ;
243+ request . messages . push ( new Message ( 'user' , promptTemplate ) ) ;
248244
249245 this . logger . debug ( 'Pathway API request: ' , request ) ;
250246 return request ;
0 commit comments