Skip to content

Commit 60aee4b

Browse files
committed
Update of Pathway prompt as suggested by Pathway team.
1 parent a89d6d3 commit 60aee4b

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

resources/pathway_prompt.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# USER INPUT
2+
Clinical Question: {{question}}
3+
4+
Clinical Notes:
5+
{{notes}}
6+
7+
# RESPONSE FORMAT
8+
Answer with the 3 following sections:
9+
10+
* Assessment
11+
* List clinically relevant facts drawn *only* from the input.
12+
* State working diagnosis or differential
13+
14+
* Recommendations and Rationale
15+
* Bullet actionable recommendations, each on its own line:
16+
- `Recommendation`
17+
18+
* Contingency Plan
19+
* Explicit thresholds or red-flags that should trigger re-evaluation or escalation.
20+
* Include fallback options if initial plan fails.

src/pathway/pathway.service.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { Message } from './models/message';
88
import { AnswersResponse } from './models/answersResponse';
99
import { Citation, SpecialistAIResponse } from '../models/specialistAIResponse';
1010
import 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()
1317
export 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

Comments
 (0)