syafiqq02 commited on
Commit
af3018b
·
1 Parent(s): 49b7092
Files changed (2) hide show
  1. app/__pycache__/main.cpython-39.pyc +0 -0
  2. app/main.py +6 -26
app/__pycache__/main.cpython-39.pyc CHANGED
Binary files a/app/__pycache__/main.cpython-39.pyc and b/app/__pycache__/main.cpython-39.pyc differ
 
app/main.py CHANGED
@@ -8,12 +8,6 @@ from groq import Groq
8
  GROQ_API_KEY = "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"
9
  groq_client = Groq(api_key=GROQ_API_KEY)
10
 
11
- def save_to_file(content: str, filename: str) -> str:
12
- filepath = f"/tmp/{filename}"
13
- with open(filepath, 'w', encoding='utf-8') as file:
14
- file.write(content)
15
- return filepath
16
-
17
  def transcribe_audio(audio_path: str):
18
  with open(audio_path, "rb") as audio_file:
19
  response = groq_client.audio.transcriptions.create(
@@ -42,11 +36,6 @@ def summarize_soap(dialogue: str):
42
  )
43
  return response_soap.choices[0].message.content
44
 
45
- def generate_soap(transcription: str):
46
- soap_content = summarize_soap(transcription)
47
- soap_file = save_to_file(soap_content, "soap_summary.txt")
48
- return soap_content, soap_file
49
-
50
  def detect_medical_tags(dialogue: str):
51
  prompt_tags = f"""
52
  Identifikasi dan berikan luaran dalam bahasa Indonesia tags berikut dari percakapan dengan format:
@@ -64,11 +53,6 @@ def detect_medical_tags(dialogue: str):
64
  )
65
  return response_tags.choices[0].message.content
66
 
67
- def generate_tags(transcription: str):
68
- tags_content = detect_medical_tags(transcription)
69
- tags_file = save_to_file(tags_content, "medical_tags.txt")
70
- return tags_content, tags_file
71
-
72
  app = FastAPI(title="Medical Transcription Pipeline (Groq API)")
73
 
74
  @app.get("/")
@@ -87,17 +71,15 @@ async def full_process(audio: UploadFile = File(...)):
87
 
88
  transcription = transcribe_audio(temp_audio_path)
89
 
90
- soap_content, soap_file = generate_soap(transcription)
91
- tags_content, tags_file = generate_tags(transcription)
92
 
93
  os.remove(temp_audio_path)
94
 
95
  return {
96
  "transcription": transcription,
97
  "soap_content": soap_content,
98
- "soap_file": soap_file,
99
- "tags_content": tags_content,
100
- "tags_file": tags_file
101
  }
102
  except Exception as e:
103
  return {"error": str(e)}
@@ -109,14 +91,12 @@ class TranscriptionInput(BaseModel):
109
  async def soap_tags(data: TranscriptionInput):
110
  transcript_text = data.dialogue
111
 
112
- soap_content, soap_file = generate_soap(transcript_text)
113
- tags_content, tags_file = generate_tags(transcript_text)
114
 
115
  return {
116
  "soap_content": soap_content,
117
- "soap_file": soap_file,
118
- "tags_content": tags_content,
119
- "tags_file": tags_file
120
  }
121
 
122
  if __name__ == "__main__":
 
8
  GROQ_API_KEY = "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"
9
  groq_client = Groq(api_key=GROQ_API_KEY)
10
 
 
 
 
 
 
 
11
  def transcribe_audio(audio_path: str):
12
  with open(audio_path, "rb") as audio_file:
13
  response = groq_client.audio.transcriptions.create(
 
36
  )
37
  return response_soap.choices[0].message.content
38
 
 
 
 
 
 
39
  def detect_medical_tags(dialogue: str):
40
  prompt_tags = f"""
41
  Identifikasi dan berikan luaran dalam bahasa Indonesia tags berikut dari percakapan dengan format:
 
53
  )
54
  return response_tags.choices[0].message.content
55
 
 
 
 
 
 
56
  app = FastAPI(title="Medical Transcription Pipeline (Groq API)")
57
 
58
  @app.get("/")
 
71
 
72
  transcription = transcribe_audio(temp_audio_path)
73
 
74
+ soap_content = summarize_soap(transcription)
75
+ tags_content = detect_medical_tags(transcription)
76
 
77
  os.remove(temp_audio_path)
78
 
79
  return {
80
  "transcription": transcription,
81
  "soap_content": soap_content,
82
+ "tags_content": tags_content
 
 
83
  }
84
  except Exception as e:
85
  return {"error": str(e)}
 
91
  async def soap_tags(data: TranscriptionInput):
92
  transcript_text = data.dialogue
93
 
94
+ soap_content = summarize_soap(transcript_text)
95
+ tags_content = detect_medical_tags(transcript_text)
96
 
97
  return {
98
  "soap_content": soap_content,
99
+ "tags_content": tags_content
 
 
100
  }
101
 
102
  if __name__ == "__main__":