Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
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()
|