File size: 1,087 Bytes
40fb01d
b748808
40fb01d
b748808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import time

# Load the model
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")

# Define additional inputs and outputs, if applicable
additional_input = gr.inputs.Textbox(label="Input Text", placeholder="Enter your story here...")
additional_output = gr.outputs.Textbox(label="Generated Story")

# Function to simulate typing effect
def typing_effect(text):
    for char in text:
        print(char, end='', flush=True)  # Print character without newline
        time.sleep(0.05)  # Add a small delay between characters
    print()  # Print newline after the text is complete

# Launch the interface with added options and descriptions
model.launch(inputs=additional_input, outputs=additional_output, title="Tiny Stories Generator", 
             description="This model generates creative stories based on the input text provided.",
             examples=[["Once upon a time..."]],
             live=False,  # Disable live updates to control the typing effect
             fn=typing_effect)  # Use the typing_effect function to display output