File size: 1,033 Bytes
d922512
34e2abf
 
d922512
34e2abf
 
d922512
 
34e2abf
d922512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
import gradio as gr
from transformers import pipeline

# Initialize Hugging Face's DialoGPT model for conversational AI
generator = pipeline("conversational", model="microsoft/DialoGPT-medium")

# Function that interacts with the Hugging Face model
def chatbot_response(user_input):
    response = generator(user_input)
    return response[0]['generated_text']

# Gradio interface setup
def create_gradio_interface():
    # Create a Gradio interface with input and output components
    interface = gr.Interface(
        fn=chatbot_response,
        inputs=gr.Textbox(label="Your Message", placeholder="Ask about food customization..."),
        outputs=gr.Textbox(label="Bot Response"),
        title="Food Customization Assistant",
        description="Talk to the bot and customize your food preferences. Ask about recipes, categories, or ingredients.",
        theme="compact"  # You can customize the theme
    )

    return interface

if __name__ == "__main__":
    interface = create_gradio_interface()
    interface.launch()