Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,9 @@ pipeline = transformers.pipeline(
|
|
13 |
|
14 |
# Define the function to generate text
|
15 |
def generate_text(input_text, max_new_tokens, temperature, top_p, split_output):
|
|
|
|
|
|
|
16 |
output = pipeline(
|
17 |
input_text,
|
18 |
max_new_tokens=max_new_tokens,
|
@@ -26,25 +29,6 @@ def generate_text(input_text, max_new_tokens, temperature, top_p, split_output):
|
|
26 |
return sentences[0] + '.'
|
27 |
return generated_text
|
28 |
|
29 |
-
# JavaScript to dynamically enable/disable sliders based on the checkbox state
|
30 |
-
js_code = """
|
31 |
-
() => {
|
32 |
-
const checkbox = document.querySelector('input[type="checkbox"]');
|
33 |
-
const sliders = document.querySelectorAll('input[type="range"]');
|
34 |
-
checkbox.addEventListener('change', () => {
|
35 |
-
sliders.forEach(slider => {
|
36 |
-
slider.disabled = checkbox.checked;
|
37 |
-
});
|
38 |
-
});
|
39 |
-
if (checkbox.checked) {
|
40 |
-
sliders.forEach(slider => {
|
41 |
-
slider.disabled = true;
|
42 |
-
});
|
43 |
-
}
|
44 |
-
}
|
45 |
-
"""
|
46 |
-
|
47 |
-
|
48 |
# Create the Gradio interface
|
49 |
input_text = gr.Textbox(lines=2, placeholder="Enter your text here...", label="Input Text")
|
50 |
|
@@ -67,9 +51,6 @@ with gr.Blocks() as iface:
|
|
67 |
btn = gr.Button("Generate")
|
68 |
btn.click(generate_text, [input_text, max_new_tokens, temperature, top_p, split_output], output)
|
69 |
|
70 |
-
# Add custom JavaScript
|
71 |
-
iface.load(js_code)
|
72 |
-
|
73 |
# Launch the interface
|
74 |
if __name__ == "__main__":
|
75 |
iface.launch()
|
|
|
13 |
|
14 |
# Define the function to generate text
|
15 |
def generate_text(input_text, max_new_tokens, temperature, top_p, split_output):
|
16 |
+
if split_output:
|
17 |
+
max_new_tokens=30
|
18 |
+
top_p=0.95
|
19 |
output = pipeline(
|
20 |
input_text,
|
21 |
max_new_tokens=max_new_tokens,
|
|
|
29 |
return sentences[0] + '.'
|
30 |
return generated_text
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Create the Gradio interface
|
33 |
input_text = gr.Textbox(lines=2, placeholder="Enter your text here...", label="Input Text")
|
34 |
|
|
|
51 |
btn = gr.Button("Generate")
|
52 |
btn.click(generate_text, [input_text, max_new_tokens, temperature, top_p, split_output], output)
|
53 |
|
|
|
|
|
|
|
54 |
# Launch the interface
|
55 |
if __name__ == "__main__":
|
56 |
iface.launch()
|