gpt / app.py
karyappa's picture
Update app.py
97eb0ad verified
raw
history blame contribute delete
513 Bytes
import gradio as gr
from transformers import pipeline
# Load a pre-trained LLM for conversational tasks (e.g., GPT-like models)
model = pipeline('text-generation', model="gpt2")
# Define the chatbot response function
def chatbot(input_text):
response = model(input_text, max_length=100, num_return_sequences=1)
return response[0]['generated_text']
# Create Gradio interface
iface = gr.Interface(fn=chatbot, inputs="text", outputs="text", title="Simple Chatbot")
# Launch the Gradio app
iface.launch()