Spaces:
Sleeping
Sleeping
prabinpanta0
commited on
Commit
•
8684892
1
Parent(s):
73cd638
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,11 @@
|
|
|
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import vertexai
|
4 |
from vertexai.generative_models import GenerativeModel
|
5 |
import vertexai.preview.generative_models as generative_models
|
6 |
import gradio as gr
|
7 |
-
|
8 |
# Read the service account key JSON file path from environment variable
|
9 |
SERVICE_ACCOUNT_KEY_PATH = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
10 |
|
@@ -59,33 +60,13 @@ def generate(text):
|
|
59 |
except Exception as e:
|
60 |
return str(e)
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
});
|
70 |
-
}
|
71 |
-
"""
|
72 |
-
|
73 |
-
def copy_to_clipboard(output_text):
|
74 |
-
return gr.update(_js=f"copyText('{output_text}')")
|
75 |
-
|
76 |
-
# Gradio interface
|
77 |
-
with gr.Blocks() as iface:
|
78 |
-
input_text = gr.Textbox(lines=2, placeholder="Enter text here...")
|
79 |
-
output_text = gr.Textbox(lines=5, interactive=True)
|
80 |
-
copy_button = gr.Button("Copy Output Text")
|
81 |
-
|
82 |
-
input_text.change(generate, inputs=input_text, outputs=output_text)
|
83 |
-
copy_button.click(copy_to_clipboard, inputs=output_text, outputs=None)
|
84 |
-
|
85 |
-
gr.Markdown(copy_js)
|
86 |
-
|
87 |
-
gr.Markdown("<h1>Chuunibyou Text Generator</h1>")
|
88 |
-
gr.Markdown("Transform text into an elaborate and formal style with a nobleman tone.")
|
89 |
|
90 |
if __name__ == "__main__":
|
91 |
-
iface.launch()
|
|
|
1 |
+
add a copy output text button below the output field:
|
2 |
+
|
3 |
import os
|
4 |
import json
|
5 |
import vertexai
|
6 |
from vertexai.generative_models import GenerativeModel
|
7 |
import vertexai.preview.generative_models as generative_models
|
8 |
import gradio as gr
|
|
|
9 |
# Read the service account key JSON file path from environment variable
|
10 |
SERVICE_ACCOUNT_KEY_PATH = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
11 |
|
|
|
60 |
except Exception as e:
|
61 |
return str(e)
|
62 |
|
63 |
+
iface = gr.Interface(
|
64 |
+
fn=generate,
|
65 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
66 |
+
outputs="text",
|
67 |
+
title="Chuunibyou Text Generator",
|
68 |
+
description="Transform text into an elaborate and formal style with a nobleman tone."
|
69 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
if __name__ == "__main__":
|
72 |
+
iface.launch()
|