Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,13 +53,12 @@ def generate_text(input_text):
|
|
| 53 |
output = model.generate(input_ids, max_new_tokens=1, do_sample=True, temperature=1.0, top_p=0.3, top_k=0)
|
| 54 |
new_word = tokenizer.decode(output[0][-1:], skip_special_tokens=True)
|
| 55 |
|
| 56 |
-
print(new_word, end="", flush=True)
|
| 57 |
generated_text += new_word
|
| 58 |
|
| 59 |
-
|
| 60 |
input_ids = output
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
# Create the Gradio interface
|
| 65 |
iface = gr.Interface(
|
|
@@ -74,7 +73,7 @@ iface = gr.Interface(
|
|
| 74 |
|
| 75 |
# For local testing:
|
| 76 |
iface.launch(share=True)
|
| 77 |
-
deploy()
|
| 78 |
|
| 79 |
|
| 80 |
# Hugging Face Spaces will automatically launch the interface.
|
|
|
|
| 53 |
output = model.generate(input_ids, max_new_tokens=1, do_sample=True, temperature=1.0, top_p=0.3, top_k=0)
|
| 54 |
new_word = tokenizer.decode(output[0][-1:], skip_special_tokens=True)
|
| 55 |
|
| 56 |
+
print(new_word, end="", flush=True) # Print to console for monitoring
|
| 57 |
generated_text += new_word
|
| 58 |
|
|
|
|
| 59 |
input_ids = output
|
| 60 |
|
| 61 |
+
yield generated_text # Yield the updated text after each word
|
| 62 |
|
| 63 |
# Create the Gradio interface
|
| 64 |
iface = gr.Interface(
|
|
|
|
| 73 |
|
| 74 |
# For local testing:
|
| 75 |
iface.launch(share=True)
|
| 76 |
+
# deploy()
|
| 77 |
|
| 78 |
|
| 79 |
# Hugging Face Spaces will automatically launch the interface.
|