Spaces:
Runtime error
Runtime error
prabinpanta0
commited on
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 |
-
import streamlit as st
|
8 |
|
9 |
# Read the service account key JSON file path from environment variable
|
10 |
SERVICE_ACCOUNT_KEY_PATH = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
|
@@ -60,29 +59,34 @@ def generate(text):
|
|
60 |
except Exception as e:
|
61 |
return str(e)
|
62 |
|
63 |
-
# Custom JavaScript for "Copy to Clipboard" functionality
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
document.execCommand("copy");
|
70 |
}
|
71 |
-
|
72 |
"""
|
73 |
|
74 |
iface = gr.Interface(
|
75 |
fn=generate,
|
76 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
77 |
-
outputs=
|
78 |
title="Chuunibyou Text Generator",
|
79 |
description="Transform text into an elaborate and formal style with a nobleman tone.",
|
80 |
live=True
|
81 |
)
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
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")
|
|
|
59 |
except Exception as e:
|
60 |
return str(e)
|
61 |
|
62 |
+
# Custom HTML and JavaScript for "Copy to Clipboard" functionality
|
63 |
+
custom_html = """
|
64 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
65 |
+
<textarea id="output-textbox" rows="6" style="width: 100%;"></textarea>
|
66 |
+
<button onclick="copyToClipboard()">Copy to Clipboard</button>
|
67 |
+
</div>
|
68 |
+
<script>
|
69 |
+
function copyToClipboard() {
|
70 |
+
var copyText = document.getElementById("output-textbox");
|
71 |
+
copyText.select();
|
72 |
document.execCommand("copy");
|
73 |
}
|
74 |
+
</script>
|
75 |
"""
|
76 |
|
77 |
iface = gr.Interface(
|
78 |
fn=generate,
|
79 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
80 |
+
outputs="html",
|
81 |
title="Chuunibyou Text Generator",
|
82 |
description="Transform text into an elaborate and formal style with a nobleman tone.",
|
83 |
live=True
|
84 |
)
|
85 |
|
86 |
+
def launch_custom_interface():
|
87 |
+
iface.launch()
|
88 |
+
with gr.TabbedInterface(fn=generate, inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), outputs=gr.HTML(label="Output")) as ti:
|
89 |
+
ti.add(custom_html)
|
90 |
+
|
91 |
+
if __name__ == "__main__":
|
92 |
+
launch_custom_interface()
|