Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1007,16 +1007,101 @@ with gr.Blocks(css="""
|
|
1007 |
send_to_model_btn = gr.Button("π Send to Model", variant="primary")
|
1008 |
|
1009 |
with gr.Row():
|
1010 |
-
|
1011 |
"""
|
1012 |
<div style="text-align: center; margin: 10px;">
|
1013 |
-
<
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1020 |
</div>
|
1021 |
"""
|
1022 |
)
|
|
|
1007 |
send_to_model_btn = gr.Button("π Send to Model", variant="primary")
|
1008 |
|
1009 |
with gr.Row():
|
1010 |
+
chatgpt_button = gr.HTML(
|
1011 |
"""
|
1012 |
<div style="text-align: center; margin: 10px;">
|
1013 |
+
<button
|
1014 |
+
onclick="
|
1015 |
+
const promptArea = document.getElementById('generated_prompt');
|
1016 |
+
if (promptArea) {
|
1017 |
+
// Try modern clipboard API first
|
1018 |
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
1019 |
+
navigator.clipboard.writeText(promptArea.value)
|
1020 |
+
.then(() => {
|
1021 |
+
this.innerHTML = 'β
Copied! Opening ChatGPT...';
|
1022 |
+
setTimeout(() => {
|
1023 |
+
const chatGPTUrl = 'https://chat.openai.com/';
|
1024 |
+
const link = document.createElement('a');
|
1025 |
+
link.href = chatGPTUrl;
|
1026 |
+
link.target = '_blank';
|
1027 |
+
link.rel = 'noopener noreferrer';
|
1028 |
+
link.click();
|
1029 |
+
|
1030 |
+
// Reset button text after a delay
|
1031 |
+
setTimeout(() => {
|
1032 |
+
this.innerHTML = 'π Copy Prompt & Open ChatGPT';
|
1033 |
+
}, 2000);
|
1034 |
+
}, 500);
|
1035 |
+
})
|
1036 |
+
.catch(() => {
|
1037 |
+
// Fallback to older method
|
1038 |
+
promptArea.select();
|
1039 |
+
try {
|
1040 |
+
document.execCommand('copy');
|
1041 |
+
this.innerHTML = 'β
Copied! Opening ChatGPT...';
|
1042 |
+
setTimeout(() => {
|
1043 |
+
const chatGPTUrl = 'https://chat.openai.com/';
|
1044 |
+
const link = document.createElement('a');
|
1045 |
+
link.href = chatGPTUrl;
|
1046 |
+
link.target = '_blank';
|
1047 |
+
link.rel = 'noopener noreferrer';
|
1048 |
+
link.click();
|
1049 |
+
|
1050 |
+
// Reset button text after a delay
|
1051 |
+
setTimeout(() => {
|
1052 |
+
this.innerHTML = 'π Copy Prompt & Open ChatGPT';
|
1053 |
+
}, 2000);
|
1054 |
+
}, 500);
|
1055 |
+
} catch (err) {
|
1056 |
+
this.innerHTML = 'β Copy failed. Please try again.';
|
1057 |
+
setTimeout(() => {
|
1058 |
+
this.innerHTML = 'π Copy Prompt & Open ChatGPT';
|
1059 |
+
}, 2000);
|
1060 |
+
}
|
1061 |
+
});
|
1062 |
+
} else {
|
1063 |
+
// Use older method directly if Clipboard API not available
|
1064 |
+
promptArea.select();
|
1065 |
+
try {
|
1066 |
+
document.execCommand('copy');
|
1067 |
+
this.innerHTML = 'β
Copied! Opening ChatGPT...';
|
1068 |
+
setTimeout(() => {
|
1069 |
+
const chatGPTUrl = 'https://chat.openai.com/';
|
1070 |
+
const link = document.createElement('a');
|
1071 |
+
link.href = chatGPTUrl;
|
1072 |
+
link.target = '_blank';
|
1073 |
+
link.rel = 'noopener noreferrer';
|
1074 |
+
link.click();
|
1075 |
+
|
1076 |
+
// Reset button text after a delay
|
1077 |
+
setTimeout(() => {
|
1078 |
+
this.innerHTML = 'π Copy Prompt & Open ChatGPT';
|
1079 |
+
}, 2000);
|
1080 |
+
}, 500);
|
1081 |
+
} catch (err) {
|
1082 |
+
this.innerHTML = 'β Copy failed. Please try again.';
|
1083 |
+
setTimeout(() => {
|
1084 |
+
this.innerHTML = 'π Copy Prompt & Open ChatGPT';
|
1085 |
+
}, 2000);
|
1086 |
+
}
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
"
|
1090 |
+
style="
|
1091 |
+
padding: 10px 20px;
|
1092 |
+
background-color: #2C3E50;
|
1093 |
+
color: white;
|
1094 |
+
border: none;
|
1095 |
+
border-radius: 5px;
|
1096 |
+
font-weight: bold;
|
1097 |
+
cursor: pointer;
|
1098 |
+
transition: background-color 0.3s ease;
|
1099 |
+
"
|
1100 |
+
onmouseover="this.style.backgroundColor='#34495E'"
|
1101 |
+
onmouseout="this.style.backgroundColor='#2C3E50'"
|
1102 |
+
>
|
1103 |
+
π Copy Prompt & Open ChatGPT
|
1104 |
+
</button>
|
1105 |
</div>
|
1106 |
"""
|
1107 |
)
|