CHATBOT1 / app.py
yougandar's picture
Update app.py
e21f5f0 verified
import gradio as gr
from transformers import pipeline
# Load a pre-trained conversational model from Hugging Face
chatbot_model = pipeline("text-generation", model="microsoft/DialoGPT-medium")
# Function to handle user input and return chatbot response
def chat_with_zomato(user_input):
# Get the response from the chatbot model
response = chatbot_model(user_input, max_length=100, num_return_sequences=1)[0]["generated_text"]
return response[len(user_input):].strip() # Remove the user input part from the response
# Gradio Interface for the chatbot
def launch_zomato_chatbot():
# Define the Gradio interface
chatbot_interface = gr.Interface(
fn=chat_with_zomato,
inputs=gr.Textbox(lines=2, placeholder="Ask Zomato..."), # User input field
outputs="text", # Text output
title="Zomato Chatbot",
description="Ask Zomato anything about restaurants, food orders, or cuisine recommendations."
)
# Launch the interface
chatbot_interface.launch()
# Call the function to launch the chatbot
if __name__ == "__main__":
launch_zomato_chatbot()