Skip to content

Commit d8bbc38

Browse files
committed
fix: Enhance system prompt clarity and user prompt constraints in explainMedicalText method
1 parent 403ae6e commit d8bbc38

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

backend/src/services/perplexity.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,18 @@ export class PerplexityService {
154154
*/
155155
async explainMedicalText(medicalText: string): Promise<string> {
156156
const systemPrompt =
157-
'You are an AI assistant that specializes in explaining complex medical information in simple terms. ' +
158-
'Your goal is to help patients understand their medical reports by translating medical jargon into plain language. ' +
159-
'Be accurate, comprehensive, but easy to understand. Use everyday analogies when helpful.';
157+
'You are an AI assistant that specializes in explaining complex medical information in simple terms.\n' +
158+
'Your goal is to help patients understand their medical reports by translating medical jargon into plain language.\n' +
159+
'You must be accurate, concise, comprehensive, and easy to understand. Use everyday analogies when helpful.\n';
160160

161-
const userPrompt = `Please explain the following medical text in simple terms:\n\n${medicalText}`;
161+
const userPrompt = `Please explain the following medical text in simple terms, in a single paragraph that's between 100 to 500 characters:\n\n${medicalText}`;
162162

163163
const messages: PerplexityMessage[] = [
164164
{ role: 'system', content: systemPrompt },
165165
{ role: 'user', content: userPrompt },
166166
];
167167

168168
const response = await this.createChatCompletion(messages);
169-
return response.choices[0].message.content;
169+
return response.choices[0].message.content.trim();
170170
}
171171
}

0 commit comments

Comments
 (0)