CTP_CONTEST / app.py
HassanDataSci's picture
Update app.py
f159a3c verified
raw
history blame
854 Bytes
import streamlit as st
from transformers import pipeline
# Load the Hugging Face model
generator = pipeline("text-generation", model="gpt-2")
# Streamlit app setup
st.title("Donald Trump Style Text Generator")
st.write("Enter a prompt, and the model will respond in a manner inspired by Donald Trump.")
# User input
user_input = st.text_input("Enter your prompt:")
if user_input:
# Prefix the prompt for stylistic guidance
trump_prompt = f"In the style of Donald Trump: {user_input}"
# Generate response with conversational tuning
response = generator(
trump_prompt,
max_length=100,
num_return_sequences=1,
do_sample=True,
temperature=0.8,
top_p=0.9
)
# Display the response
generated_text = response[0]["generated_text"]
st.write("Response:", generated_text)