Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,630 Bytes
dc563b1 197883c dc563b1 197883c dc563b1 197883c 0a7637c 197883c 0a7637c 197883c 0a7637c 197883c 0a7637c 197883c 0a7637c 197883c 0a7637c dc563b1 0a7637c 197883c 0a7637c ba661e1 0a7637c dc563b1 0a7637c dc563b1 0a7637c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import gradio as gr
from knowledge_base import PNAKnowledgeBase
from pna_client import PNAAssistantClient
# --- Constants ---
GUIDE_FILENAME = "Professional nurse advocate A-EQUIP model Guide.md"
# --- Initialize Components ---
kb = PNAKnowledgeBase(GUIDE_FILENAME)
client = PNAAssistantClient()
def chat_response(message, history):
"""Generate response using RAG + fine-tuned model."""
# Search Knowledge Base for relevant context
context = kb.search(message)
# Generate Response using fine-tuned MedGemma
response = client.generate_response(message, context=context, history=history)
return response
# --- Premium CSS ---
CUSTOM_CSS = """
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@600;700&display=swap');
.gradio-container {
max-width: 800px !important;
margin: 0 auto !important;
font-family: 'Inter', sans-serif !important;
}
.contain { background: linear-gradient(135deg, #4f46e5 0%, #0d9488 100%) !important; }
footer { display: none !important; }
"""
HEADER_HTML = """
<div style="text-align: center; padding: 1.5rem; background: linear-gradient(135deg, #4f46e5 0%, #0d9488 100%); border-radius: 12px; margin-bottom: 1rem;">
<h1 style="color: white; font-family: 'Outfit', sans-serif; margin: 0; font-size: 1.5rem;">
Professional Nurse Advocate Assistant
</h1>
<p style="color: rgba(255,255,255,0.9); margin: 0.5rem 0 0 0; font-size: 0.9rem;">
Guiding you through the A-EQUIP model and Restorative Supervision
</p>
<div style="font-size: 1.25rem; margin-top: 0.5rem; letter-spacing: 0.2rem;">
π¨πΎββοΈ π©π½ββοΈ π¨πΏββοΈ π©π»ββοΈ π©ββοΈ
</div>
</div>
"""
DISCLAIMER_HTML = """
<div style="text-align: center; font-size: 0.75rem; color: #64748b; margin-top: 1rem; padding: 0.75rem; background: rgba(148, 163, 184, 0.1); border-radius: 8px;">
β οΈ This tool is for educational purposes only. It does not provide clinical advice.
</div>
"""
# --- Simple ChatInterface ---
with gr.Blocks(css=CUSTOM_CSS, title="PNA Assistant") as demo:
gr.HTML(HEADER_HTML)
gr.ChatInterface(
fn=chat_response,
type="messages",
examples=[
"What is the A-EQUIP model?",
"Explain the four functions of clinical supervision",
"How can I support a colleague through restorative supervision?",
"What does a Professional Nurse Advocate do?"
],
title="",
)
gr.HTML(DISCLAIMER_HTML)
if __name__ == "__main__":
demo.launch()
|