faruqaziz commited on
Commit
5490126
·
verified ·
1 Parent(s): 51179ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -34,19 +34,19 @@ if st.button("Diagnosa"):
34
  if gejala_id and usia and jenis_kelamin:
35
  # Terjemahkan gejala dari Indonesia ke Inggris
36
  terjemahan = translator(gejala_id, max_length=100)
37
- gejala_en = terjemahan <sup> </sup>["translation_text"]
38
 
39
- informasi_pasien = f"Saya berusia {usia} tahun, {jenis_kelamin}. Gejala yang saya alami adalah {gejala_en}"
40
 
41
  # Pesan untuk model
42
  pesan = [
43
- {"role": "system", "content": "Anda adalah seorang dokter yang perlu mendiagnosis penyakit pasien. Berikan satu diagnosis yang Anda yakini paling akurat."},
44
- {"role": "user", "content": f"Berdasarkan informasi ini, {informasi_pasien}, apa penyakit yang mungkin saya derita?"}
45
  ]
46
 
47
  # Fungsi untuk mendapatkan konten dari role 'assistant'
48
  def get_assistant_content(response):
49
- generated_text = response <sup> </sup>['generated_text']
50
  return generated_text
51
 
52
  # Dapatkan respon dari pipe1 (model TinyLlama)
@@ -58,7 +58,7 @@ if st.button("Diagnosa"):
58
  asisten_konten2 = get_assistant_content(response2)
59
 
60
  # Gabungkan hasil dari pipe1 dan pipe2 untuk pertanyaan akhir
61
- pertanyaan_akhir = [{'role': 'user', 'content': f"{asisten_konten1}. {asisten_konten2}. Berdasarkan dua kalimat ini, apa kesimpulan akhir Anda tentang gejala saya? Berikan jawaban singkat dengan satu diagnosis."}]
62
 
63
  # Dapatkan hasil akhir diagnosis
64
  hasil_diagnosis = pipe1(pertanyaan_akhir)
@@ -66,7 +66,7 @@ if st.button("Diagnosa"):
66
 
67
  # Terjemahkan hasil akhir ke bahasa Indonesia
68
  terjemahan_hasil = terjamah(asisten_konten3, max_length=100)
69
- diagnosa_terjemahan = terjemahan_hasil <sup> </sup>["translation_text"]
70
 
71
  # Tampilkan hasil ke Streamlit
72
  st.subheader("Hasil Diagnosis:")
 
34
  if gejala_id and usia and jenis_kelamin:
35
  # Terjemahkan gejala dari Indonesia ke Inggris
36
  terjemahan = translator(gejala_id, max_length=100)
37
+ gejala_en = terjemahan[0]["translation_text"]
38
 
39
+ informasi_pasien = f"I am {usia} years old, {jenis_kelamin}. And my current symptoms are {gejala_en}"
40
 
41
  # Pesan untuk model
42
  pesan = [
43
+ {"role": "system", "content": "You are a doctor who needs to diagnose a patient's illness. Provide one diagnosis that you believe is most confident."},
44
+ {"role": "user", "content": f"Based on your assessment, {gabungan}, what illness could it be?"}
45
  ]
46
 
47
  # Fungsi untuk mendapatkan konten dari role 'assistant'
48
  def get_assistant_content(response):
49
+ generated_text = response [0]['generated_text']
50
  return generated_text
51
 
52
  # Dapatkan respon dari pipe1 (model TinyLlama)
 
58
  asisten_konten2 = get_assistant_content(response2)
59
 
60
  # Gabungkan hasil dari pipe1 dan pipe2 untuk pertanyaan akhir
61
+ pertanyaan_akhir = [{'role': 'user', 'content': f"{asisten_konten1}. {asisten_konten2}. Based on these two sentences, what is your final conclusion of my current symptom? Please provide a brief answer with one diagnosis."}]
62
 
63
  # Dapatkan hasil akhir diagnosis
64
  hasil_diagnosis = pipe1(pertanyaan_akhir)
 
66
 
67
  # Terjemahkan hasil akhir ke bahasa Indonesia
68
  terjemahan_hasil = terjamah(asisten_konten3, max_length=100)
69
+ diagnosa_terjemahan = terjemahan_hasil[0]["translation_text"]
70
 
71
  # Tampilkan hasil ke Streamlit
72
  st.subheader("Hasil Diagnosis:")