NursingCare / app.py
ngocnhi3411's picture
Update app.py
53c71b5 verified
raw
history blame contribute delete
840 Bytes
# app.py
from transformers import pipeline
import gradio as gr
# Tạo chatbot AI với mô hình hội thoại y khoa
chatbot = pipeline(
"text-generation",
model="microsoft/BioGPT-Large", # Mô hình hiểu ngôn ngữ y học
max_length=200,
temperature=0.7
)
# Hàm phản hồi chatbot
def chat_with_ai(message):
response = chatbot(message)[0]['generated_text']
return response
# Tạo giao diện Gradio
demo = gr.Interface(
fn=chat_with_ai,
inputs=gr.Textbox(label="Nhập câu hỏi y khoa của bạn"),
outputs=gr.Textbox(label="Phản hồi từ BioGPT"),
title="Chatbot Y khoa với BioGPT",
description="Chatbot được huấn luyện từ mô hình BioGPT của Microsoft để trả lời các câu hỏi y học."
)
# Chạy app
if __name__ == "__main__":
demo.launch()