datdevsteve commited on
Commit
bec4468
·
verified ·
1 Parent(s): 5bb2d83

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -77
app.py DELETED
@@ -1,77 +0,0 @@
1
- import gradio as gr
2
- from llama_cpp import Llama
3
- import os
4
-
5
- # Initialize the model
6
- model_path = "medgemma-4b-it-q4_k_m.gguf"
7
- llm = Llama(
8
- model_path=model_path,
9
- n_ctx=2048, # Context window
10
- n_threads=2, # Use 2 threads for free CPU
11
- n_gpu_layers=0 # CPU only
12
- )
13
-
14
- def medical_orchestrator(user_input, symptoms, history):
15
- """
16
- Main orchestration function for Nivra
17
- Takes user symptoms and coordinates between ClinicalBERT results
18
- """
19
- prompt = f"""
20
- You are Nivra, an Indian AI healthcare assistant. You are a helpful medical advisor.
21
- Though unlicensed and uncertified, you possess the medical knowledge required to assist people with clinical advice
22
-
23
- Based on the following symptoms and clinical analysis, provide a clear,
24
- empathetic response in simple language understandable to Indian patients.
25
-
26
- Symptoms: {symptoms}
27
- User Question: {user_input}
28
-
29
- Provide:
30
- 1. A brief explanation of possible conditions
31
- 2. Severity assessment
32
- 3. Immediate actions to take
33
- 4. When to seek medical attention
34
-
35
- Response:"""
36
-
37
- response = llm(
38
- prompt,
39
- max_tokens=512,
40
- temperature=0.3, # Lower for medical accuracy
41
- top_p=0.9,
42
- stop=["User:", "Symptoms:"]
43
- )
44
-
45
- return response['choices'][0]['text']
46
-
47
- # Gradio Interface
48
- with gr.Blocks() as demo:
49
- gr.Markdown("# Nivra Medical AI Orchestrator")
50
-
51
- with gr.Row():
52
- with gr.Column():
53
- symptoms_input = gr.Textbox(
54
- label="Symptoms (from ClinicalBERT)",
55
- placeholder="Enter detected symptoms...",
56
- lines=3
57
- )
58
- user_query = gr.Textbox(
59
- label="User Question",
60
- placeholder="Ask about your symptoms...",
61
- lines=2
62
- )
63
- submit_btn = gr.Button("Get Medical Guidance")
64
-
65
- with gr.Column():
66
- output = gr.Textbox(
67
- label="Nivra's Response",
68
- lines=10
69
- )
70
-
71
- submit_btn.click(
72
- fn=medical_orchestrator,
73
- inputs=[user_query, symptoms_input, gr.State([])],
74
- outputs=output
75
- )
76
-
77
- demo.launch()