Muhammadidrees commited on
Commit
0a59616
·
verified ·
1 Parent(s): 389e8a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -70,8 +70,9 @@ def respond(albumin, creatinine, glucose, crp, mcv, rdw, alp, wbc, lymphocytes,
70
  f"- Plasma Viscosity (PV): {pv} mPa·s"
71
  )
72
 
73
- # ----- Call Groq API -----
74
- completion = client.chat.completions.create(
 
75
  model=MODEL_ID,
76
  messages=[
77
  {"role": "system", "content": system_message},
@@ -81,10 +82,21 @@ def respond(albumin, creatinine, glucose, crp, mcv, rdw, alp, wbc, lymphocytes,
81
  max_tokens=2500,
82
  top_p=0.9,
83
  stream=False
84
- )
 
 
 
 
 
 
 
 
 
 
85
 
86
- return completion.choices[0].message.content
87
 
 
88
 
89
  # --- Gradio Interface ---
90
  with gr.Blocks(title="🧬 Biomarker Medical Insight Chatbot") as demo:
 
70
  f"- Plasma Viscosity (PV): {pv} mPa·s"
71
  )
72
 
73
+ try:
74
+ # --- Query model ---
75
+ response = client.chat.completions.create(
76
  model=MODEL_ID,
77
  messages=[
78
  {"role": "system", "content": system_message},
 
82
  max_tokens=2500,
83
  top_p=0.9,
84
  stream=False
85
+ )
86
+
87
+ # --- Get model reply and convert Markdown → HTML ---
88
+ reply = response.choices[0].message.content
89
+ html_output = markdown.markdown(
90
+ reply,
91
+ extensions=["tables", "fenced_code", "nl2br"]
92
+ )
93
+
94
+ except Exception as e:
95
+ html_output = f"<p style='color:red;'>⚠️ Error: {str(e)}</p>"
96
 
97
+ return html_output
98
 
99
+
100
 
101
  # --- Gradio Interface ---
102
  with gr.Blocks(title="🧬 Biomarker Medical Insight Chatbot") as demo: