Israelalcaide commited on
Commit
7b8a67e
·
verified ·
1 Parent(s): a24a7da

add app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ chatbot = pipeline(
5
+ "text-generation",
6
+ model="mistralai/Mistral-7B-Instruct-v0.1",
7
+ max_new_tokens=200,
8
+ temperature=0.7,
9
+ do_sample=True
10
+ )
11
+
12
+ def responder(pregunta, enfermedad):
13
+ prompt = f"<s>[INST] Responde con empatía como si fueras un asistente experto en la enfermedad {enfermedad}.\n\n{pregunta} [/INST]"
14
+ respuesta = chatbot(prompt)[0]["generated_text"]
15
+ return respuesta.split("[/INST]")[-1].strip()
16
+
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("# 🤖 IA de apoyo a enfermedades raras")
19
+ gr.Markdown("Haz preguntas como familiar de alguien afectado. Esta IA responderá con empatía y conocimientos médicos.")
20
+
21
+ enfermedad = gr.Dropdown(["Ehlers-Danlos", "Síndrome de Rett", "Fibrosis Quística"], label="Selecciona la enfermedad")
22
+ chat = gr.ChatInterface(fn=lambda msg: responder(msg, enfermedad.value))
23
+
24
+ demo.launch()