File size: 619 Bytes
04c228d
e68852a
165c6d6
e68852a
 
04c228d
e68852a
 
 
 
04c228d
e68852a
 
 
 
 
 
04c228d
e68852a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

# Load the text-generation pipeline
generator = pipeline("text-generation", model="King-8/community-gpt2")

# Define the chatbot response function
def chat(prompt):
    response = generator(prompt, max_length=100, do_sample=True, temperature=0.7)
    return response[0]["generated_text"]

# Set up the Gradio interface
iface = gr.Interface(fn=chat, 
                     inputs="text", 
                     outputs="text",
                     title="Community GPT-2 Chatbot",
                     description="Ask me anything!")

# Launch the app
iface.launch()