Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import time
|
3 |
|
4 |
+
# Load the model
|
5 |
+
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
|
6 |
+
|
7 |
+
# Define additional inputs and outputs, if applicable
|
8 |
+
additional_input = gr.inputs.Textbox(label="Input Text", placeholder="Enter your story here...")
|
9 |
+
additional_output = gr.outputs.Textbox(label="Generated Story")
|
10 |
+
|
11 |
+
# Function to simulate typing effect
|
12 |
+
def typing_effect(text):
|
13 |
+
for char in text:
|
14 |
+
print(char, end='', flush=True) # Print character without newline
|
15 |
+
time.sleep(0.05) # Add a small delay between characters
|
16 |
+
print() # Print newline after the text is complete
|
17 |
+
|
18 |
+
# Launch the interface with added options and descriptions
|
19 |
+
model.launch(inputs=additional_input, outputs=additional_output, title="Tiny Stories Generator",
|
20 |
+
description="This model generates creative stories based on the input text provided.",
|
21 |
+
examples=[["Once upon a time..."]],
|
22 |
+
live=False, # Disable live updates to control the typing effect
|
23 |
+
fn=typing_effect) # Use the typing_effect function to display output
|