File size: 814 Bytes
7861198
f2c670c
7861198
f2c670c
 
 
 
7861198
 
f2c670c
7861198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2c670c
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
import gradio as gr
import os
import time
!pip install sentencepiece
import sentencepiece
from transformers import pipeline


# Création du pipeline pour le modèle de Hugging Face
pipe = pipeline(task='text-generation', model='Mohammed-Altaf/Medical-ChatBot')

# Création de l'interface Gradio
with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])

    def respond(message, chat_history):
        # Utilisation du modèle de Hugging Face pour générer une réponse
        bot_message = pipe(message, max_length=50)[0]['generated_text']
        chat_history.append((message, bot_message))
        time.sleep(2)
        return "", chat_history

    msg.submit(respond, [msg, chatbot], [msg, chatbot])

if __name__ == "__main__":
    demo.launch()