MalikShehram commited on
Commit
d2bfab4
·
verified ·
1 Parent(s): c5ca8bb

Update backend.py

Browse files
Files changed (1) hide show
  1. backend.py +6 -5
backend.py CHANGED
@@ -42,10 +42,10 @@ def get_spectrogram_base64(audio_path):
42
 
43
  def generate_medical_advice_from_vision(base64_img):
44
  """
45
- Uses Llama 3.2 Vision (via Groq) to look at the Spectrogram and diagnose it.
46
  """
47
  if not base64_img:
48
- return "Error: Could not process the audio into a visual spectrogram."
49
 
50
  prompt = """
51
  You are an AI medical assistant specializing in cardiology. Look closely at this Mel-Spectrogram of a patient's Phonocardiogram (heart sound).
@@ -61,7 +61,8 @@ def generate_medical_advice_from_vision(base64_img):
61
 
62
  try:
63
  response = client.chat.completions.create(
64
- model="llama-3.2-90b-vision-preview", # Upgraded to the larger, more stable vision model
 
65
  messages=[
66
  {
67
  "role": "user",
@@ -81,10 +82,10 @@ def generate_medical_advice_from_vision(base64_img):
81
  )
82
  return response.choices[0].message.content
83
  except Exception as e:
84
- # Instead of a generic message, we now capture the exact error from Groq
85
  actual_error = str(e)
86
  print(f"Groq Vision API Error: {actual_error}")
87
- return f"API Error: {actual_error}\n\n(If you see a 404 or Model Not Found error, Groq might have temporarily rotated their vision models.)"
 
88
 
89
  def text_to_speech(text):
90
  """
 
42
 
43
  def generate_medical_advice_from_vision(base64_img):
44
  """
45
+ Uses Llama 4 Scout Vision (via Groq) to look at the Spectrogram and diagnose it.
46
  """
47
  if not base64_img:
48
+ return "Error: Could not process the audio into a visual spectrogram for the AI."
49
 
50
  prompt = """
51
  You are an AI medical assistant specializing in cardiology. Look closely at this Mel-Spectrogram of a patient's Phonocardiogram (heart sound).
 
61
 
62
  try:
63
  response = client.chat.completions.create(
64
+ # UPDATED: Pointing to Groq's current active vision model
65
+ model="meta-llama/llama-4-scout-17b-16e-instruct",
66
  messages=[
67
  {
68
  "role": "user",
 
82
  )
83
  return response.choices[0].message.content
84
  except Exception as e:
 
85
  actual_error = str(e)
86
  print(f"Groq Vision API Error: {actual_error}")
87
+ return f"Groq API Error: {actual_error}"
88
+
89
 
90
  def text_to_speech(text):
91
  """