Skip to content

Commit 3956426

Browse files
authored
Merge pull request #96 from ModusCreateOrg/ADE-66
[ADE-66] Enhance system prompt clarity and user prompt constraints in explainMedicalText method
2 parents f17f5a4 + d8bbc38 commit 3956426

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
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
}

frontend/src/common/components/AIAssistant/AIAssistantModal.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
--box-shadow: 0 -0.25rem 1rem rgba(0, 0, 0, 0.1);
66
--backdrop-opacity: 0.3;
77
align-items: flex-end;
8-
transition: --height 0.3s ease-out, --max-height 0.3s ease-out;
8+
transition:
9+
--height 0.3s ease-out,
10+
--max-height 0.3s ease-out;
911

1012
&.expanded {
1113
--height: 85vh;

frontend/src/common/hooks/useFileUpload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const useFileUpload = ({
9999
setError(
100100
validation.errorKey
101101
? t(validation.errorKey, validation.params)
102-
: validation.error ?? t('upload.error.unknown'),
102+
: (validation.error ?? t('upload.error.unknown')),
103103
);
104104
return;
105105
}

frontend/src/pages/Chat/__tests__/ChatPage.test.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ interface MockComponentProps {
3434
vi.mock('@ionic/react', () => {
3535
const createMockComponent =
3636
(name: string) =>
37-
({ className, children, ...props }: MockComponentProps) =>
38-
(
39-
<div data-testid={`mock-${name}`} className={className} {...props}>
40-
{children}
41-
</div>
42-
);
37+
({ className, children, ...props }: MockComponentProps) => (
38+
<div data-testid={`mock-${name}`} className={className} {...props}>
39+
{children}
40+
</div>
41+
);
4342

4443
return {
4544
IonPage: createMockComponent('ion-page'),

frontend/src/pages/Processing/ProcessingPage.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
height: 180px;
6565
border-radius: 50%;
6666
background: radial-gradient(circle at 30% 30%, #4f7dff 10%, #c97eff 40%, #ff8afc 80%);
67-
box-shadow: 0 0 40px rgba(201, 126, 255, 0.5), 0 0 80px rgba(201, 126, 255, 0.3);
67+
box-shadow:
68+
0 0 40px rgba(201, 126, 255, 0.5),
69+
0 0 80px rgba(201, 126, 255, 0.3);
6870
position: relative;
6971
overflow: hidden;
7072
animation: pulse 3s infinite ease-in-out;
@@ -155,7 +157,9 @@
155157
font-weight: 500;
156158
font-size: 1rem;
157159
cursor: pointer;
158-
transition: background-color 0.2s, color 0.2s;
160+
transition:
161+
background-color 0.2s,
162+
color 0.2s;
159163

160164
&:hover {
161165
background-color: var(--ion-color-primary-tint);

frontend/src/pages/Upload/__tests__/UploadPage.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ vi.mock('common/components/Upload/UploadModal', () => {
5757
labValues: [],
5858
summary: 'Test report summary',
5959
filePath: '/reports/test-report.pdf',
60+
originalFilename: 'test-report.pdf',
61+
fileSize: 1024,
62+
confidence: 0.95,
6063
updatedAt: '2023-01-01',
6164
};
6265

0 commit comments

Comments
 (0)