skylersterling commited on
Commit
9b45f2c
·
verified ·
1 Parent(s): 2894a34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -14,9 +14,10 @@ model.to('cpu')
14
 
15
  # Define the function that generates text from a prompt
16
  def generate_text(prompt, temperature):
 
 
 
17
 
18
- print(prompt)
19
-
20
  prompt_with_eos = "#CONTEXT# " + prompt + " #TOPIC# " # Add the string "EOS" to the end of the prompt
21
  input_tokens = tokenizer.encode(prompt_with_eos, return_tensors='pt')
22
 
@@ -51,4 +52,4 @@ interface = gr.Interface(
51
  description="TopicGPT processes the input and returns a reasonably accurate guess of the topic/theme of a given conversation."
52
  )
53
 
54
- interface.launch()
 
14
 
15
  # Define the function that generates text from a prompt
16
  def generate_text(prompt, temperature):
17
+ word_count = len(prompt.split())
18
+ if word_count < 5:
19
+ return "Please provide at least 5 words in the prompt."
20
 
 
 
21
  prompt_with_eos = "#CONTEXT# " + prompt + " #TOPIC# " # Add the string "EOS" to the end of the prompt
22
  input_tokens = tokenizer.encode(prompt_with_eos, return_tensors='pt')
23
 
 
52
  description="TopicGPT processes the input and returns a reasonably accurate guess of the topic/theme of a given conversation."
53
  )
54
 
55
+ interface.launch()