skylersterling commited on
Commit
ebf873e
·
verified ·
1 Parent(s): f288112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -41,7 +41,14 @@ def generate_text(prompt, temperature, top_p):
41
  generated_text += decoded_token # Append the new token to the generated text
42
  if decoded_token == "<": # Stop if the end of sequence token is generated
43
  break
44
- yield generated_text[prompt_length:] # Yield the generated text excluding the initial prompt plus "EOS"
 
 
 
 
 
 
 
45
 
46
  # Create a Gradio interface with a text input, sliders for temperature and top_p, and a text output
47
  interface = gr.Interface(
@@ -56,4 +63,4 @@ interface = gr.Interface(
56
  description="SentimentGPT processes the sequence and returns a reasonably accurate guess of whether the sentiment behind the input is positive or negative."
57
  )
58
 
59
- interface.launch()
 
41
  generated_text += decoded_token # Append the new token to the generated text
42
  if decoded_token == "<": # Stop if the end of sequence token is generated
43
  break
44
+
45
+ # Check if the generated text contains "0" or "1" and return the appropriate sentiment message
46
+ if "1" in generated_text:
47
+ return "The sentiment is positive."
48
+ elif "0" in generated_text:
49
+ return "The sentiment is negative."
50
+ else:
51
+ return "Invalid"
52
 
53
  # Create a Gradio interface with a text input, sliders for temperature and top_p, and a text output
54
  interface = gr.Interface(
 
63
  description="SentimentGPT processes the sequence and returns a reasonably accurate guess of whether the sentiment behind the input is positive or negative."
64
  )
65
 
66
+ interface.launch()