Spaces:
Runtime error
Runtime error
simultaneous streams
Browse files
app.py
CHANGED
|
@@ -93,7 +93,28 @@ def generate(
|
|
| 93 |
yield output
|
| 94 |
return output
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
examples = [
|
| 98 |
"X_train, y_train, X_test, y_test = train_test_split(X, y, test_size=0.1)\n\n# Train a logistic regression model, predict the labels on the test set and compute the accuracy score",
|
| 99 |
"// Returns every other value in the array as a new array.\nfunction everyOther(arr) {",
|
|
@@ -142,7 +163,8 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:
|
|
| 142 |
elem_id="q-input",
|
| 143 |
)
|
| 144 |
submit = gr.Button("Generate", variant="primary")
|
| 145 |
-
|
|
|
|
| 146 |
with gr.Row():
|
| 147 |
with gr.Column():
|
| 148 |
with gr.Accordion("Advanced settings", open=False):
|
|
@@ -192,12 +214,12 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:
|
|
| 192 |
inputs=[instruction],
|
| 193 |
cache_examples=False,
|
| 194 |
fn=process_example,
|
| 195 |
-
outputs=[
|
| 196 |
)
|
| 197 |
|
| 198 |
submit.click(
|
| 199 |
-
|
| 200 |
inputs=[instruction, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 201 |
-
outputs=[
|
| 202 |
)
|
| 203 |
demo.queue(concurrency_count=16).launch(debug=True)
|
|
|
|
| 93 |
yield output
|
| 94 |
return output
|
| 95 |
|
| 96 |
+
def generate_both(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0):
|
| 97 |
+
generator_1, generator_2 = generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0), generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0)
|
| 98 |
+
output_1, output_2 = "", ""
|
| 99 |
+
output_1_end, output_2_end = False, False
|
| 100 |
|
| 101 |
+
while True:
|
| 102 |
+
try:
|
| 103 |
+
output_1 = next(generator_1)
|
| 104 |
+
except StopIteration:
|
| 105 |
+
output_1_end = True
|
| 106 |
+
|
| 107 |
+
try:
|
| 108 |
+
output_2 = next(generator_2)
|
| 109 |
+
except StopIteration:
|
| 110 |
+
output_2_end = True
|
| 111 |
+
|
| 112 |
+
if output_1_end and output_2_end:
|
| 113 |
+
yield output_1, output_2
|
| 114 |
+
return output_1, output_2
|
| 115 |
+
|
| 116 |
+
yield output_1, output_2
|
| 117 |
+
|
| 118 |
examples = [
|
| 119 |
"X_train, y_train, X_test, y_test = train_test_split(X, y, test_size=0.1)\n\n# Train a logistic regression model, predict the labels on the test set and compute the accuracy score",
|
| 120 |
"// Returns every other value in the array as a new array.\nfunction everyOther(arr) {",
|
|
|
|
| 163 |
elem_id="q-input",
|
| 164 |
)
|
| 165 |
submit = gr.Button("Generate", variant="primary")
|
| 166 |
+
output_1 = gr.Code(elem_id="q-output", lines=30, label="Output")
|
| 167 |
+
output_2 = gr.Code(elem_id="q-output", lines=30, label="Output")
|
| 168 |
with gr.Row():
|
| 169 |
with gr.Column():
|
| 170 |
with gr.Accordion("Advanced settings", open=False):
|
|
|
|
| 214 |
inputs=[instruction],
|
| 215 |
cache_examples=False,
|
| 216 |
fn=process_example,
|
| 217 |
+
outputs=[output_1],
|
| 218 |
)
|
| 219 |
|
| 220 |
submit.click(
|
| 221 |
+
generate_both,
|
| 222 |
inputs=[instruction, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 223 |
+
outputs=[output_1, output_2],
|
| 224 |
)
|
| 225 |
demo.queue(concurrency_count=16).launch(debug=True)
|