Spaces:
Running on Zero
Running on Zero
Merge branch #boroll2347/Medical_AI_Assistant' into 'boroll2347/Medical_AI_Assistant_temp_copy'
Browse files
app.py
CHANGED
|
@@ -77,7 +77,10 @@ def extend(text, max_new_tokens, progress=gr.Progress()):
|
|
| 77 |
progress(0.9, desc="Decoding...")
|
| 78 |
try:
|
| 79 |
(output,) = outputs
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
except Exception as e:
|
| 82 |
raw_output = ""
|
| 83 |
try:
|
|
@@ -93,11 +96,12 @@ with gr.Blocks() as demo:
|
|
| 93 |
interactive=True,
|
| 94 |
wrap_lines=True,
|
| 95 |
)
|
| 96 |
-
gr.
|
|
|
|
| 97 |
fn=extend,
|
| 98 |
inputs=[
|
| 99 |
document,
|
| 100 |
-
|
| 101 |
],
|
| 102 |
outputs=[
|
| 103 |
document,
|
|
|
|
| 77 |
progress(0.9, desc="Decoding...")
|
| 78 |
try:
|
| 79 |
(output,) = outputs
|
| 80 |
+
new_text = tokenizer.decode(output).removeprefix(PREFIX)
|
| 81 |
+
if not new_text.startswith(text):
|
| 82 |
+
return text, "New text somehow deleted existing text!\n\n" + new_text
|
| 83 |
+
return new_text, "Success"
|
| 84 |
except Exception as e:
|
| 85 |
raw_output = ""
|
| 86 |
try:
|
|
|
|
| 96 |
interactive=True,
|
| 97 |
wrap_lines=True,
|
| 98 |
)
|
| 99 |
+
max_new_tokens = gr.Slider(label="Max New Tokens", minimum=10, maximum=8192, step=10, value=128)
|
| 100 |
+
gr.Button("Generate").click(
|
| 101 |
fn=extend,
|
| 102 |
inputs=[
|
| 103 |
document,
|
| 104 |
+
max_new_tokens,
|
| 105 |
],
|
| 106 |
outputs=[
|
| 107 |
document,
|