Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
import os
|
2 |
import json
|
3 |
-
import gradio as gr
|
4 |
-
import pyperclip
|
5 |
import vertexai
|
6 |
from vertexai.generative_models import GenerativeModel
|
7 |
import vertexai.preview.generative_models as generative_models
|
@@ -60,28 +58,5 @@ def generate(text):
|
|
60 |
except Exception as e:
|
61 |
return f"Error: {str(e)}"
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
pyperclip.copy(text)
|
66 |
-
return "Text copied to clipboard!"
|
67 |
-
except Exception as e:
|
68 |
-
return f"Failed to copy text: {str(e)}"
|
69 |
-
|
70 |
-
with gr.Blocks() as demo:
|
71 |
-
gr.Markdown("""
|
72 |
-
# Chuunibyou Text Generator
|
73 |
-
Transform text into an elaborate and formal style with a Chuunibyou tone.
|
74 |
-
""")
|
75 |
-
|
76 |
-
with gr.Row():
|
77 |
-
with gr.Column(scale=2):
|
78 |
-
input_text = gr.Textbox(lines=2, placeholder="Enter text here...")
|
79 |
-
output_text = gr.Textbox(lines=4, interactive=False)
|
80 |
-
generate_button = gr.Button("Submit")
|
81 |
-
copy_button = gr.Button("Copy to Clipboard")
|
82 |
-
hidden_state = gr.State()
|
83 |
-
|
84 |
-
generate_button.click(fn=generate, inputs=input_text, outputs=[output_text, hidden_state])
|
85 |
-
copy_button.click(fn=copy_to_clipboard, inputs=hidden_state, outputs=gr.Textbox(interactive=False, label="Notification"))
|
86 |
-
|
87 |
-
demo.launch()
|
|
|
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
|
|
|
58 |
except Exception as e:
|
59 |
return f"Error: {str(e)}"
|
60 |
|
61 |
+
# Test the function
|
62 |
+
print(generate("Hello, I am Elien"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|