Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ 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,34 +58,13 @@ def generate(text):
|
|
59 |
except Exception as e:
|
60 |
return str(e)
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
alert('Failed to copy text: ', err);
|
70 |
-
});
|
71 |
-
}
|
72 |
-
"""
|
73 |
-
|
74 |
-
# Gradio interface
|
75 |
-
with gr.Blocks() as iface:
|
76 |
-
input_text = gr.Textbox(lines=2, placeholder="Enter text here...")
|
77 |
-
output_text = gr.Textbox(lines=5, interactive=False)
|
78 |
-
copy_button = gr.Button("Copy Output Text")
|
79 |
-
|
80 |
-
def copy_to_clipboard():
|
81 |
-
return gr.update(_js="copyText()")
|
82 |
-
|
83 |
-
input_text.change(generate, inputs=input_text, outputs=output_text)
|
84 |
-
copy_button.click(copy_to_clipboard)
|
85 |
-
|
86 |
-
gr.Markdown(f"<script>{copy_js}</script>")
|
87 |
-
|
88 |
-
gr.Markdown("<h1>Chuunibyou Text Generator V1.02</h1>")
|
89 |
-
gr.Markdown("Transform text into an elaborate and formal style with a nobleman tone.")
|
90 |
|
91 |
if __name__ == "__main__":
|
92 |
-
iface.launch()
|
|
|
4 |
from vertexai.generative_models import GenerativeModel
|
5 |
import vertexai.preview.generative_models as generative_models
|
6 |
import gradio as gr
|
|
|
7 |
# Read the service account key JSON file path from environment variable
|
8 |
SERVICE_ACCOUNT_KEY_PATH = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
9 |
|
|
|
58 |
except Exception as e:
|
59 |
return str(e)
|
60 |
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=generate,
|
63 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
64 |
+
outputs="text",
|
65 |
+
title="Chuunibyou Text Generator",
|
66 |
+
description="Transform text into an elaborate and formal style with a nobleman tone."
|
67 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
+
iface.launch()
|