Spaces:
Sleeping
Sleeping
fullstuckdev
commited on
Commit
·
4522b38
1
Parent(s):
190e47b
change desc
Browse files
src/app/api/recommend/route.ts
CHANGED
|
@@ -6,23 +6,39 @@ export async function POST(request: Request) {
|
|
| 6 |
try {
|
| 7 |
const { symptoms, medicalHistory } = await request.json()
|
| 8 |
|
| 9 |
-
const prompt = `
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
const response = await hf.textGeneration({
|
| 16 |
model: "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
| 17 |
inputs: prompt,
|
| 18 |
parameters: {
|
| 19 |
-
max_new_tokens:
|
| 20 |
-
temperature: 0.7
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
})
|
| 23 |
|
| 24 |
-
return Response.json({
|
|
|
|
|
|
|
| 25 |
} catch (error) {
|
| 26 |
-
return Response.json({
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
}
|
|
|
|
| 6 |
try {
|
| 7 |
const { symptoms, medicalHistory } = await request.json()
|
| 8 |
|
| 9 |
+
const prompt = `Berikan rekomendasi obat dan perawatan dalam Bahasa Indonesia berdasarkan informasi pasien berikut:
|
| 10 |
+
|
| 11 |
+
Gejala: ${symptoms}
|
| 12 |
+
Riwayat Medis: ${medicalHistory}
|
| 13 |
+
|
| 14 |
+
Harap berikan rekomendasi yang mencakup:
|
| 15 |
+
1. Analisis gejala
|
| 16 |
+
2. Rekomendasi obat-obatan yang sesuai
|
| 17 |
+
3. Pertimbangan interaksi obat
|
| 18 |
+
4. Saran perawatan tambahan
|
| 19 |
+
5. Tindakan pencegahan
|
| 20 |
+
|
| 21 |
+
Catatan: Berikan semua informasi dalam Bahasa Indonesia dan gunakan istilah medis yang umum digunakan di Indonesia.`
|
| 22 |
|
| 23 |
const response = await hf.textGeneration({
|
| 24 |
model: "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
| 25 |
inputs: prompt,
|
| 26 |
parameters: {
|
| 27 |
+
max_new_tokens: 1000,
|
| 28 |
+
temperature: 0.7,
|
| 29 |
+
top_p: 0.95,
|
| 30 |
+
repetition_penalty: 1.15
|
| 31 |
}
|
| 32 |
})
|
| 33 |
|
| 34 |
+
return Response.json({
|
| 35 |
+
recommendation: response.generated_text
|
| 36 |
+
})
|
| 37 |
} catch (error) {
|
| 38 |
+
return Response.json({
|
| 39 |
+
error: 'Gagal menghasilkan rekomendasi'
|
| 40 |
+
}, {
|
| 41 |
+
status: 500
|
| 42 |
+
})
|
| 43 |
}
|
| 44 |
}
|