ranamhamoud commited on
Commit
f6ff388
โ€ข
1 Parent(s): 01c9b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -99,10 +99,16 @@ def generate(
99
  t.start()
100
 
101
  outputs = []
 
102
  for text in streamer:
103
  processed_text = process_text(text)
104
  outputs.append(processed_text)
105
- yield "".join(outputs)
 
 
 
 
 
106
  final_story = "".join(outputs)
107
  try:
108
  saved_story = Story(message=message, content=final_story).save()
 
99
  t.start()
100
 
101
  outputs = []
102
+ end_phrase = "the end."
103
  for text in streamer:
104
  processed_text = process_text(text)
105
  outputs.append(processed_text)
106
+ current_output = "".join(outputs)
107
+ yield current_output
108
+ # Check if 'the end.' is in the current output, case-insensitive
109
+ if end_phrase in current_output.lower():
110
+ break # Stop generating further if 'the end.' is found
111
+
112
  final_story = "".join(outputs)
113
  try:
114
  saved_story = Story(message=message, content=final_story).save()