CoolFace
Apppublic

SpawnedShoyo/0_0

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py22 linesDownload Raw Back to root
1import gradio as gr2from transformers import BlenderbotForConditionalGeneration, BlenderbotTokenizer3 4# Load the pre-trained Blenderbot model and tokenizer5model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")6tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")7 8# Define the chatbot function9def chatbot(input_text):10    input_ids = tokenizer.encode(input_text, return_tensors="pt")11    bot_input_ids = input_ids12    chatbot_response = model.generate(bot_input_ids, max_length=1000, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id)13    response_text = tokenizer.decode(chatbot_response[0], skip_special_tokens=True)14    return response_text15 16# Create the Gradio interface17iface = gr.Interface(fn=chatbot, 18                     inputs="text",19                     outputs="text",20                     title="Chatbot using Hugging Face Transformers",21                     description="Ask me anything!")22iface.launch(share=True)