mkoot007 commited on
Commit
8dbce5c
1 Parent(s): f04691c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -4,15 +4,15 @@ from transformers import pipeline
4
  # Create a text generation pipeline with the "gpt2" model
5
  pipe = pipeline("text-generation", model="gpt2")
6
 
7
- st.title("Poem Generator")
8
  user_word = st.text_input("Enter a word:")
9
 
10
  if st.button("Generate Poem"):
11
  if user_word:
12
- # Prompt the model with a structured poem request
13
- poem_prompt = f"Write a poem about '{user_word}'.\n"
14
- poem = pipe(poem_prompt, max_length=100, do_sample=True, num_return_sequences=1)[0]["generated_text"]
15
- st.markdown("**Poem:**")
16
- st.markdown(poem)
17
  else:
18
  st.warning("Please enter a word.")
 
4
  # Create a text generation pipeline with the "gpt2" model
5
  pipe = pipeline("text-generation", model="gpt2")
6
 
7
+ st.title("Paraphrase Generator")
8
  user_word = st.text_input("Enter a word:")
9
 
10
  if st.button("Generate Poem"):
11
  if user_word:
12
+ # Prompt the model with a structured paraphrase request
13
+ paraphrase_prompt= f"Write a Paraphrase about '{user_word}'.\n"
14
+ paraphrase = pipe(paraphrase_prompt, max_length=200, do_sample=True, num_return_sequences=1)[0]["generated_text"]
15
+ st.markdown("**Paraphrase:**")
16
+ st.markdown(paraphrase)
17
  else:
18
  st.warning("Please enter a word.")