Spaces:
Sleeping
Sleeping
Commit
Β·
038c199
1
Parent(s):
61a4214
add tags prediction
Browse files
app.py
CHANGED
@@ -43,18 +43,12 @@ def chat_with_groq(message):
|
|
43 |
{
|
44 |
"role": "system",
|
45 |
"content": """Anda adalah asisten medis yang membantu dokter dalam menyusun catatan SOAP berdasarkan percakapan dokter dan pasien.
|
46 |
-
Ringkaskan dalam bentuk paragraf tanpa adanya bullet point dan gunakan bahasa Indonesia.
|
47 |
-
Harap buat ringkasan dalam format berikut:
|
48 |
-
|
49 |
-
Subjective:
|
50 |
-
Objective:
|
51 |
-
Assessment:
|
52 |
-
Plan:""",
|
53 |
},
|
54 |
{"role": "user", "content": message},
|
55 |
],
|
56 |
temperature=0.0,
|
57 |
-
max_tokens=
|
58 |
)
|
59 |
return response.choices[0].message.content # Extract response text
|
60 |
|
@@ -78,15 +72,21 @@ def transcribe_audio(audio_path):
|
|
78 |
|
79 |
def generate_soap_summary(transcription_text, selected_model):
|
80 |
"""Membuat ringkasan SOAP dari teks transkripsi menggunakan model yang dipilih."""
|
81 |
-
template = """
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
### Percakapan:
|
83 |
{dialogue}
|
84 |
|
85 |
### Catatan SOAP:
|
86 |
"""
|
87 |
-
messages = [
|
88 |
-
|
89 |
-
]
|
90 |
# response = huggingface_client.chat.completions.create(
|
91 |
# model=selected_model, messages=messages, max_tokens=1000, stream=False
|
92 |
# )
|
@@ -98,22 +98,23 @@ def generate_soap_summary(transcription_text, selected_model):
|
|
98 |
def detect_medical_tags(transcription_text, selected_model):
|
99 |
"""Mendeteksi tags Diagnosis, Obat, Hasil Lab, dan Radiologi menggunakan model yang dipilih."""
|
100 |
template = """
|
101 |
-
Identifikasi dan berikan
|
102 |
-
|
103 |
Obat:
|
104 |
-
|
105 |
Radiologi:
|
106 |
|
107 |
### Percakapan:
|
108 |
{dialogue}
|
109 |
"""
|
110 |
-
messages = [
|
111 |
-
|
112 |
-
]
|
113 |
-
response = huggingface_client.chat.completions.create(
|
114 |
-
|
115 |
-
)
|
116 |
-
tags = response.choices[0].message.content.strip()
|
|
|
117 |
return tags, save_to_file(tags, "medical_tags.txt")
|
118 |
|
119 |
|
@@ -141,12 +142,12 @@ with gr.Blocks(
|
|
141 |
)
|
142 |
update_transcription_button = gr.Button("πΎ Simpan Hasil Edit")
|
143 |
soap_button = gr.Button("π Buat SOAP")
|
144 |
-
tags_button = gr.Button("π·οΈ Deteksi Tags")
|
145 |
|
146 |
with gr.Column():
|
147 |
soap_output = gr.Textbox(label="π Hasil SOAP", lines=10, interactive=False)
|
148 |
tags_output = gr.Textbox(
|
149 |
-
label="π·οΈ Hasil Tags
|
150 |
lines=10,
|
151 |
interactive=False,
|
152 |
)
|
|
|
43 |
{
|
44 |
"role": "system",
|
45 |
"content": """Anda adalah asisten medis yang membantu dokter dalam menyusun catatan SOAP berdasarkan percakapan dokter dan pasien.
|
46 |
+
Ringkaskan dalam bentuk paragraf tanpa adanya bullet point dan gunakan bahasa Indonesia.""",
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
},
|
48 |
{"role": "user", "content": message},
|
49 |
],
|
50 |
temperature=0.0,
|
51 |
+
max_tokens=248,
|
52 |
)
|
53 |
return response.choices[0].message.content # Extract response text
|
54 |
|
|
|
72 |
|
73 |
def generate_soap_summary(transcription_text, selected_model):
|
74 |
"""Membuat ringkasan SOAP dari teks transkripsi menggunakan model yang dipilih."""
|
75 |
+
template = """Harap buat ringkasan dalam format berikut:
|
76 |
+
|
77 |
+
Subjective:
|
78 |
+
ICD10:
|
79 |
+
Objective:
|
80 |
+
Assessment:
|
81 |
+
Plan:
|
82 |
### Percakapan:
|
83 |
{dialogue}
|
84 |
|
85 |
### Catatan SOAP:
|
86 |
"""
|
87 |
+
# messages = [
|
88 |
+
# {"role": "user", "content": template.format(dialogue=transcription_text)}
|
89 |
+
# ]
|
90 |
# response = huggingface_client.chat.completions.create(
|
91 |
# model=selected_model, messages=messages, max_tokens=1000, stream=False
|
92 |
# )
|
|
|
98 |
def detect_medical_tags(transcription_text, selected_model):
|
99 |
"""Mendeteksi tags Diagnosis, Obat, Hasil Lab, dan Radiologi menggunakan model yang dipilih."""
|
100 |
template = """
|
101 |
+
Identifikasi dan berikan saran dalam bahasa Indonesia tindakan logis selanjutnya dalam format:
|
102 |
+
ICD10:
|
103 |
Obat:
|
104 |
+
Laboratorium:
|
105 |
Radiologi:
|
106 |
|
107 |
### Percakapan:
|
108 |
{dialogue}
|
109 |
"""
|
110 |
+
# messages = [
|
111 |
+
# {"role": "user", "content": template.format(dialogue=transcription_text)}
|
112 |
+
# ]
|
113 |
+
# response = huggingface_client.chat.completions.create(
|
114 |
+
# model=selected_model, messages=messages, max_tokens=500, stream=False
|
115 |
+
# )
|
116 |
+
# tags = response.choices[0].message.content.strip()
|
117 |
+
tags = chat_with_groq(template.format(dialogue=transcription_text))
|
118 |
return tags, save_to_file(tags, "medical_tags.txt")
|
119 |
|
120 |
|
|
|
142 |
)
|
143 |
update_transcription_button = gr.Button("πΎ Simpan Hasil Edit")
|
144 |
soap_button = gr.Button("π Buat SOAP")
|
145 |
+
tags_button = gr.Button("π·οΈ Deteksi Saran Tags")
|
146 |
|
147 |
with gr.Column():
|
148 |
soap_output = gr.Textbox(label="π Hasil SOAP", lines=10, interactive=False)
|
149 |
tags_output = gr.Textbox(
|
150 |
+
label="π·οΈ Hasil Saran Tags ICD 10, Obat, Laboratorium, Radiologi",
|
151 |
lines=10,
|
152 |
interactive=False,
|
153 |
)
|