Spaces:
Sleeping
Sleeping
Last commit not found
import streamlit as st | |
from transformers import pipeline | |
def load_model(): | |
return pipeline("text-generation", model="PeterBrendan/pbjs_gpt2") | |
def main(): | |
st.title("Pbjs GPT2: Optimize your Prebid config") | |
st.write("Enter some text like **bidderTimeout** and get a generated Prebid config output.") | |
# Default prompts | |
default_prompts = ["{", "bidderTimeout", "bidderSequence", "Usebidcache", "customPriceBucket"] | |
# Create a select box for default prompts | |
default_prompt = st.selectbox("Choose a default prompt:", default_prompts) | |
# Create a text input field for a custom prompt | |
custom_prompt = st.text_input("Enter a custom prompt:", "") | |
# Check if a default prompt is selected | |
if default_prompt: | |
user_input = default_prompt | |
else: | |
user_input = custom_prompt | |
# Check if the user input is empty | |
if user_input: | |
# Load the Hugging Face model | |
generator = load_model() | |
# Generate text based on user input | |
generated_text = generator(user_input, max_length=500, num_return_sequences=1)[0]["generated_text"] | |
# Display the generated text | |
st.write("Generated Text:") | |
st.write(generated_text) | |
# Run the app | |
if __name__ == "__main__": | |
main() | |