Update app.py
Browse files
app.py
CHANGED
@@ -3,45 +3,14 @@ import gradio as gr
|
|
3 |
# Load the model
|
4 |
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
var inputText = document.getElementById("input-text").value;
|
15 |
-
gr.Interface.static.predict(inputText).then(function(outputText) {
|
16 |
-
document.getElementById("output-text").innerHTML = "";
|
17 |
-
typeText(inputText + " ");
|
18 |
-
typeText(outputText);
|
19 |
-
});
|
20 |
-
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
var typingSpeed = 50; // Adjust the speed of typing
|
25 |
-
var timer = setInterval(function() {
|
26 |
-
if (index < text.length) {
|
27 |
-
document.getElementById("output-text").innerHTML += text.charAt(index);
|
28 |
-
index++;
|
29 |
-
} else {
|
30 |
-
clearInterval(timer);
|
31 |
-
}
|
32 |
-
}, typingSpeed);
|
33 |
-
}
|
34 |
-
</script>
|
35 |
-
</head>
|
36 |
-
<body>
|
37 |
-
<div style="padding: 20px;">
|
38 |
-
<textarea id="input-text" placeholder="Enter your story here..." style="width: 100%; height: 200px;"></textarea>
|
39 |
-
<button onclick="generateStory()">Generate Story</button>
|
40 |
-
<div id="output-text" style="margin-top: 20px;"></div>
|
41 |
-
</div>
|
42 |
-
</body>
|
43 |
-
</html>
|
44 |
-
"""
|
45 |
-
|
46 |
-
# Launch the interface using the custom HTML code
|
47 |
-
gr.Interface(fn=lambda inputs: inputs, inputs=gr.inputs.Textbox(), outputs=gr.outputs.HTML(html_code)).launch()
|
|
|
3 |
# Load the model
|
4 |
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
|
5 |
|
6 |
+
# Create the interface
|
7 |
+
interface = gr.Interface(
|
8 |
+
fn=model.predict,
|
9 |
+
inputs=gr.Textbox(prompt="Type a prompt here..."),
|
10 |
+
outputs=gr.Textbox(),
|
11 |
+
live=True,
|
12 |
+
capture_session=True
|
13 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# Launch the interface
|
16 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|