Spaces:
Runtime error
Runtime error
File size: 713 Bytes
e5f185f ab5fcdf 6c66f70 ab5fcdf 6c66f70 ab5fcdf 6c66f70 ab5fcdf 6c66f70 ab5fcdf 6c66f70 ab5fcdf 6c66f70 ab5fcdf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline, set_seed
# Load GPT-2 model
generator = pipeline("text-generation", model="gpt2")
set_seed(42)
# Define chatbot response function
def chat_with_bot(message):
prompt = f"User: {message}\nBot:"
response = generator(prompt, max_length=100, do_sample=True, temperature=0.7)
reply = response[0]["generated_text"][len(prompt):] # extract only the new response
return reply.strip()
# Create Gradio interface
gr.Interface(
fn=chat_with_bot,
inputs=gr.Textbox(lines=2, placeholder="Ask me anything..."),
outputs="text",
title="Jayalakshmi's AI Chatbot",
description="A simple chatbot powered by GPT-2. Ask anything!"
).launch() |