codebyam commited on
Commit
e672b08
·
verified ·
1 Parent(s): 0d63d27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +106 -1
app.py CHANGED
@@ -183,6 +183,75 @@ async def read_items():
183
  .copy-btn:hover {
184
  background-color: #3e8e41;
185
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  .loading-dots span {
187
  animation: blink 1.4s infinite both;
188
  }
@@ -205,6 +274,15 @@ async def read_items():
205
  const clearBtn = document.getElementById("clearBtn");
206
  const API_ENDPOINT = "optimize";
207
  const STORAGE_KEY = "prompt_optimizer_chat_history";
 
 
 
 
 
 
 
 
 
208
  function formatTextWithLineBreaks(text) {
209
  const escaped = text
210
  .replace(/&/g, "&")
@@ -332,7 +410,10 @@ async def read_items():
332
  <div class="chat-wrapper">
333
  <div class="header">
334
  <div>Prompt Optimizer</div>
335
- <button id="clearBtn">🧹 Clear</button>
 
 
 
336
  </div>
337
  <div id="chatWindow" class="chat-window">
338
  <div class="invite bot-message">
@@ -346,6 +427,30 @@ async def read_items():
346
  <textarea id="userInput" placeholder="Type or paste your prompt here..." rows="2"></textarea>
347
  <button id="sendButton" aria-label="Send message">➤</button>
348
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  </div>
350
  </body>
351
  </html>
 
183
  .copy-btn:hover {
184
  background-color: #3e8e41;
185
  }
186
+
187
+ .button {
188
+ background-color: #007bff;
189
+ color: white;
190
+ border: none;
191
+ padding: 12px 24px;
192
+ font-size: 16px;
193
+ border-radius: 6px;
194
+ cursor: pointer;
195
+ margin-right: 14px;
196
+ }
197
+
198
+ .button:hover {
199
+ background-color: #0056b3;
200
+ }
201
+
202
+ .modal {
203
+ display: none;
204
+ position: fixed;
205
+ z-index: 1000;
206
+ left: 0;
207
+ top: 0;
208
+ width: 100%;
209
+ height: 100%;
210
+ overflow: auto;
211
+ background-color: rgba(0,0,0,0.6);
212
+ }
213
+
214
+ .modal-content {
215
+ background-color: #fff;
216
+ margin: 10% auto;
217
+ padding: 20px 30px;
218
+ border-radius: 8px;
219
+ width: 80%;
220
+ max-width: 800px;
221
+ text-align: left;
222
+ box-shadow: 0 5px 15px rgba(0,0,0,0.3);
223
+ }
224
+
225
+ .close {
226
+ color: #aaa;
227
+ float: right;
228
+ font-size: 24px;
229
+ font-weight: bold;
230
+ cursor: pointer;
231
+ }
232
+
233
+ .close:hover {
234
+ color: #000;
235
+ }
236
+
237
+ h2 {
238
+ border-bottom: 2px solid #ddd;
239
+ padding-bottom: 8px;
240
+ margin-top: 20px;
241
+ }
242
+
243
+ pre {
244
+ background-color: #f0f0f0;
245
+ border-radius: 5px;
246
+ padding: 15px;
247
+ overflow-x: auto;
248
+ }
249
+
250
+ code {
251
+ font-family: Consolas, "Courier New", monospace;
252
+ color: #333;
253
+ display: block;
254
+ }
255
  .loading-dots span {
256
  animation: blink 1.4s infinite both;
257
  }
 
274
  const clearBtn = document.getElementById("clearBtn");
275
  const API_ENDPOINT = "optimize";
276
  const STORAGE_KEY = "prompt_optimizer_chat_history";
277
+ const modal = document.getElementById("apiModal");
278
+ const btn = document.getElementById("apiKeyBtn");
279
+ const close = document.getElementById("closeModal");
280
+
281
+ btn.onclick = () => modal.style.display = "block";
282
+ close.onclick = () => modal.style.display = "none";
283
+ window.onclick = (event) => {
284
+ if (event.target == modal) modal.style.display = "none";
285
+ };
286
  function formatTextWithLineBreaks(text) {
287
  const escaped = text
288
  .replace(/&/g, "&amp;")
 
410
  <div class="chat-wrapper">
411
  <div class="header">
412
  <div>Prompt Optimizer</div>
413
+ <div style="display: inline-flex;">
414
+ <div class="button">Get API</div>
415
+ <button id="clearBtn">🧹 Clear</button>
416
+ </div>
417
  </div>
418
  <div id="chatWindow" class="chat-window">
419
  <div class="invite bot-message">
 
427
  <textarea id="userInput" placeholder="Type or paste your prompt here..." rows="2"></textarea>
428
  <button id="sendButton" aria-label="Send message">➤</button>
429
  </div>
430
+ <div id="apiModal" class="modal">
431
+ <div class="modal-content">
432
+ <span class="close" id="closeModal">&times;</span>
433
+ <h1>API Example Model</h1>
434
+
435
+ <h2>Python Code Snippet</h2>
436
+ <pre><code>
437
+ import requests
438
+ url = "http://getresp.com/optimize"
439
+ data = {"input_prompt": "This is my sample prompt."}
440
+ response = requests.post(url, json=data)
441
+ print(response.json())
442
+ </code></pre>
443
+
444
+ <h2>JavaScript Code Snippet</h2>
445
+ <pre><code>
446
+ const response = await fetch(API_ENDPOINT, {
447
+ method: "POST",
448
+ headers: { "Content-Type": "application/json" },
449
+ body: JSON.stringify({ input_prompt: prompt }),
450
+ })
451
+ </code></pre>
452
+ </div>
453
+ </div>
454
  </div>
455
  </body>
456
  </html>