ibrahim313 commited on
Commit
f85b832
·
verified ·
1 Parent(s): dcdbbad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py CHANGED
@@ -79,6 +79,9 @@ def get_groq_response_with_few_shot(post_type, user_input):
79
  # Streamlit UI
80
  st.title("Social Media Post Maker for Data Science")
81
 
 
 
 
82
  # User input
83
  post_type = st.selectbox("Select the type of post:", [
84
  "Template-Based Post",
@@ -142,3 +145,47 @@ if response:
142
  """
143
 
144
  html(copy_button_code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  # Streamlit UI
80
  st.title("Social Media Post Maker for Data Science")
81
 
82
+ # Initialize response
83
+ response = None
84
+
85
  # User input
86
  post_type = st.selectbox("Select the type of post:", [
87
  "Template-Based Post",
 
145
  """
146
 
147
  html(copy_button_code)
148
+
149
+ # Example Button
150
+ if st.button("Get Example Post"):
151
+ example_post_type = "Data Science Tip"
152
+ example_user_input = "importance of data preprocessing"
153
+ example_response = get_groq_response_with_few_shot(example_post_type, example_user_input)
154
+ st.code(example_response)
155
+
156
+ # Add a Copy to Clipboard button for the example post
157
+ copy_example_button_code = f"""
158
+ <button class="copy-btn" onclick="copyToClipboard()">Copy Example Post</button>
159
+ <script>
160
+ function copyToClipboard() {{
161
+ var text = `{example_response}`;
162
+ var tempInput = document.createElement("textarea");
163
+ document.body.appendChild(tempInput);
164
+ tempInput.value = text;
165
+ tempInput.select();
166
+ document.execCommand("copy");
167
+ document.body.removeChild(tempInput);
168
+ alert("Copied to clipboard!");
169
+ }}
170
+ </script>
171
+ <style>
172
+ .copy-btn {{
173
+ background-color: #007bff;
174
+ color: white;
175
+ border: none;
176
+ padding: 10px 20px;
177
+ text-align: center;
178
+ text-decoration: none;
179
+ display: inline-block;
180
+ font-size: 16px;
181
+ margin: 4px 2px;
182
+ cursor: pointer;
183
+ border-radius: 4px;
184
+ }}
185
+ .copy-btn:hover {{
186
+ background-color: #0056b3;
187
+ }}
188
+ </style>
189
+ """
190
+
191
+ html(copy_example_button_code)