Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| import random | |
| import time | |
| # Création du pipeline pour le modèle de Hugging Face | |
| pipe = pipeline(task='text-generation', model='meta-llama/Llama-2-7b-chat-hf') | |
| # 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() | |