Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,9 +96,32 @@ css="""
|
|
| 96 |
"""
|
| 97 |
|
| 98 |
js="""
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
"""
|
| 103 |
|
| 104 |
if torch.cuda.is_available():
|
|
@@ -106,9 +129,6 @@ if torch.cuda.is_available():
|
|
| 106 |
else:
|
| 107 |
power_device = "CPU"
|
| 108 |
|
| 109 |
-
def limiter(txt):
|
| 110 |
-
return txt[:38]
|
| 111 |
-
|
| 112 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
| 113 |
with gr.Column(elem_id="col-container"):
|
| 114 |
gr.Markdown(f"""
|
|
|
|
| 96 |
"""
|
| 97 |
|
| 98 |
js="""
|
| 99 |
+
function custom(){
|
| 100 |
+
window.Wait = function (Test, Success, Fail = function () { }, timeout = Number.MAX_SAFE_INTEGER) {
|
| 101 |
+
let seconds = 0;
|
| 102 |
+
function Internal() {
|
| 103 |
+
if (!Test()) {
|
| 104 |
+
if (seconds >= timeout) {
|
| 105 |
+
Fail();
|
| 106 |
+
return;
|
| 107 |
+
}
|
| 108 |
+
setTimeout(function () {
|
| 109 |
+
seconds += 0.01;
|
| 110 |
+
Internal(...arguments);
|
| 111 |
+
}, 300);
|
| 112 |
+
return;
|
| 113 |
+
}
|
| 114 |
+
Success();
|
| 115 |
+
}
|
| 116 |
+
Internal();
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
Wait(function(){
|
| 120 |
+
return document.querySelector("div#prompt input")
|
| 121 |
+
},function(){
|
| 122 |
+
document.querySelector("div#prompt input").setAttribute(maxlength,"38");
|
| 123 |
+
},function(){});
|
| 124 |
+
}
|
| 125 |
"""
|
| 126 |
|
| 127 |
if torch.cuda.is_available():
|
|
|
|
| 129 |
else:
|
| 130 |
power_device = "CPU"
|
| 131 |
|
|
|
|
|
|
|
|
|
|
| 132 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
| 133 |
with gr.Column(elem_id="col-container"):
|
| 134 |
gr.Markdown(f"""
|