fullstuckdev commited on
Commit
4522b38
1 Parent(s): 190e47b

change desc

Browse files
Files changed (1) hide show
  1. src/app/api/recommend/route.ts +25 -9
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 = `Given the following patient information:
10
- Symptoms: ${symptoms}
11
- Medical History: ${medicalHistory}
12
-
13
- Please recommend appropriate medications and treatments. Consider potential drug interactions and contraindications.`
 
 
 
 
 
 
 
 
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: 32000,
20
- temperature: 0.7
 
 
21
  }
22
  })
23
 
24
- return Response.json({ recommendation: response.generated_text })
 
 
25
  } catch (error) {
26
- return Response.json({ error: 'Failed to generate recommendation' }, { status: 500 })
 
 
 
 
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
  }