benjamin5607 commited on
Commit
7299771
ยท
verified ยท
1 Parent(s): 357ec59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -14
app.py CHANGED
@@ -81,7 +81,7 @@ db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
81
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
82
 
83
  # ==========================================
84
- # ๐Ÿ–ฅ๏ธ 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (์—ฌ๊ถŒ ์ •๋ ฌ ๋กœ์ง ์ˆ˜์ •)
85
  # ==========================================
86
  html_template = """
87
  <!DOCTYPE html>
@@ -131,7 +131,7 @@ html_template = """
131
  .review-content-box { flex: 1; overflow-y: auto; padding: 20px; }
132
  .review-header { text-align: center; margin-bottom: 20px; border-bottom: 1px solid #333; padding-bottom: 15px; }
133
  .review-title { font-size: 24px; font-weight: bold; color: var(--gold); margin-bottom: 5px; }
134
- .review-body { font-size: 16px; line-height: 1.8; color: #e0e0e0; font-family: 'Georgia', serif; font-style: italic; text-align: justify; }
135
  .review-signature { text-align: right; margin-top: 20px; color: var(--gold); font-weight: bold; }
136
  .detail-actions { display: flex; gap: 10px; margin-top: 20px; }
137
  .detail-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; font-weight: bold; cursor: pointer; font-size: 14px; text-transform: uppercase; }
@@ -412,14 +412,12 @@ html_template = """
412
  } else { alert("You already visited here!"); }
413
  }
414
 
415
- // [ํ•ต์‹ฌ] ์—ฌ๊ถŒ ์ •๋ ฌ: 1. ๋ฐฉ๋ฌธํ•œ ๊ณณ(์ตœ์‹ ์ˆœ) -> 2. ์•ˆ ๋ฐฉ๋ฌธํ•œ ๊ณณ(๋‚˜๋จธ์ง€)
416
  function openPassport() {
417
  document.getElementById('passport-page').style.transform = 'translateX(0%)';
418
  visitedPlaces = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
419
  const grid = document.getElementById('stamp-grid');
420
  grid.innerHTML = "";
421
 
422
- // 1. ๋ฐฉ๋ฌธํ•œ ๊ณณ ๋จผ์ € (๊ฑฐ๊พธ๋กœ = ์ตœ์‹ ์ˆœ)
423
  const reversedVp = [...visitedPlaces].reverse();
424
  reversedVp.forEach(name => {
425
  const div = document.createElement('div');
@@ -428,7 +426,6 @@ html_template = """
428
  grid.appendChild(div);
429
  });
430
 
431
- // 2. ๋‚˜๋จธ์ง€ ์•ˆ ๊ฐ€๋ณธ ๊ณณ
432
  for(let c in PLACE_DB) {
433
  PLACE_DB[c].forEach(p => {
434
  if(!visitedPlaces.includes(p.name)) {
@@ -511,7 +508,34 @@ html_template = """
511
  document.getElementById('btn-detail-stamp').onclick = function() { markVisited(n); };
512
 
513
  const contextDesc = placeData ? (placeData['desc_'+currentLang.toLowerCase()] || placeData.desc_ko) : "";
514
- const reviewPrompt = `Act as Emily, a charming bartender. Write a short review (max 3 sentences) for "${n}" in "${c}". [CONTEXT] ${contextDesc}. [LANG] ${TRANSLATIONS[currentLang].ai}.`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
 
516
  const res = await callGroq([{role:"system",content: reviewPrompt}]);
517
  document.getElementById('repo-content').innerHTML = res + "<div class='review-signature'>- Yours, Emily ๐Ÿ’‹</div>";
@@ -520,11 +544,4 @@ html_template = """
520
  function closeDetail() { document.getElementById('detail-page').style.transform = 'translateX(100%)'; }
521
  </script>
522
  </body>
523
- </html>
524
- """
525
-
526
- html_code = html_template.replace("IMAGE_DATA", f"data:image/jpeg;base64,{emily_base64}")
527
- html_code = html_code.replace("DB_DATA_BASE64", db_base64)
528
- html_code = html_code.replace("GROQ_KEY_INJECTED", GROQ_API_KEY)
529
-
530
- components.html(html_code, height=1000, scrolling=True)
 
81
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
82
 
83
  # ==========================================
84
+ # ๐Ÿ–ฅ๏ธ 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (๋ฆฌ๋ทฐ ํ”„๋กฌํ”„ํŠธ ๋Œ€ํญ ๊ฐ•ํ™”)
85
  # ==========================================
86
  html_template = """
87
  <!DOCTYPE html>
 
131
  .review-content-box { flex: 1; overflow-y: auto; padding: 20px; }
132
  .review-header { text-align: center; margin-bottom: 20px; border-bottom: 1px solid #333; padding-bottom: 15px; }
133
  .review-title { font-size: 24px; font-weight: bold; color: var(--gold); margin-bottom: 5px; }
134
+ .review-body { font-size: 15px; line-height: 1.8; color: #e0e0e0; font-family: 'Segoe UI', sans-serif; text-align: left; }
135
  .review-signature { text-align: right; margin-top: 20px; color: var(--gold); font-weight: bold; }
136
  .detail-actions { display: flex; gap: 10px; margin-top: 20px; }
137
  .detail-btn { flex: 1; padding: 12px; border-radius: 10px; border: none; font-weight: bold; cursor: pointer; font-size: 14px; text-transform: uppercase; }
 
412
  } else { alert("You already visited here!"); }
413
  }
414
 
 
415
  function openPassport() {
416
  document.getElementById('passport-page').style.transform = 'translateX(0%)';
417
  visitedPlaces = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
418
  const grid = document.getElementById('stamp-grid');
419
  grid.innerHTML = "";
420
 
 
421
  const reversedVp = [...visitedPlaces].reverse();
422
  reversedVp.forEach(name => {
423
  const div = document.createElement('div');
 
426
  grid.appendChild(div);
427
  });
428
 
 
429
  for(let c in PLACE_DB) {
430
  PLACE_DB[c].forEach(p => {
431
  if(!visitedPlaces.includes(p.name)) {
 
508
  document.getElementById('btn-detail-stamp').onclick = function() { markVisited(n); };
509
 
510
  const contextDesc = placeData ? (placeData['desc_'+currentLang.toLowerCase()] || placeData.desc_ko) : "";
511
+ const addressInfo = placeData.address || "Address not available";
512
+
513
+ // --- [NEW LOGIC] Dual Strategy: Korea (Internal) vs World (External Simulation) ---
514
+ let searchStrategy = "";
515
+ if (c.includes("Korea") || c.includes("ํ•œ๊ตญ")) {
516
+ searchStrategy = "SOURCE: Strictly base your review on the provided [CONTEXT] and your general knowledge of Korean geography. Do not hallucinate.";
517
+ } else {
518
+ searchStrategy = "SOURCE: Use your internal knowledge base (simulating online reviews, blogs, news) to enrich the details. The [CONTEXT] is just a starting point.";
519
+ }
520
+
521
+ const reviewPrompt = `
522
+ ROLE: You are Emily, a professional and charming bartender.
523
+ TASK: Write a detailed review for the bar "${n}" located in "${c}".
524
+ ${searchStrategy}
525
+ [CONTEXT]: ${contextDesc}
526
+ [ADDRESS]: ${addressInfo}
527
+
528
+ REQUIRED SECTIONS (Translate headers to target language):
529
+ 1. ๐Ÿ“ Address & Access (How to get there easily)
530
+ 2. ๐Ÿ“– Story & Atmosphere (Vibe check)
531
+ 3. ๐Ÿ‘ฅ Who goes there? (Demographics, age, style)
532
+ 4. ๐Ÿฅƒ Recommended Menu (Signature drinks)
533
+ 5. ๐Ÿคซ Secret Tip (Best seat, best time, etc.)
534
+ 6. ๐Ÿ Bartender's Note (Final Verdict)
535
+
536
+ LANGUAGE: Respond STRICTLY in ${TRANSLATIONS[currentLang].ai}.
537
+ TONE: Insightful, witty, and warm. Like giving advice to a close friend.
538
+ `;
539
 
540
  const res = await callGroq([{role:"system",content: reviewPrompt}]);
541
  document.getElementById('repo-content').innerHTML = res + "<div class='review-signature'>- Yours, Emily ๐Ÿ’‹</div>";
 
544
  function closeDetail() { document.getElementById('detail-page').style.transform = 'translateX(100%)'; }
545
  </script>
546
  </body>
547
+ </html>