Update app.py
Browse files
app.py
CHANGED
@@ -398,36 +398,40 @@ def update_session_list():
|
|
398 |
return gr.update(choices=[])
|
399 |
|
400 |
def load_json_data():
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
|
|
|
|
|
|
|
|
425 |
|
426 |
def load_session_history(selected_session=None):
|
427 |
try:
|
428 |
print("Loading session history...")
|
429 |
json_data = load_json_data()
|
430 |
-
print(f"Loaded {len(json_data)} items
|
431 |
|
432 |
html_content = """
|
433 |
<style>
|
@@ -451,17 +455,12 @@ def load_session_history(selected_session=None):
|
|
451 |
transform: translateY(-2px);
|
452 |
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
453 |
}
|
454 |
-
.card-image
|
455 |
width: 100%;
|
456 |
height: 200px;
|
457 |
-
|
458 |
-
display: flex;
|
459 |
-
align-items: center;
|
460 |
-
justify-content: center;
|
461 |
border-radius: 4px;
|
462 |
margin-bottom: 10px;
|
463 |
-
color: #999;
|
464 |
-
font-size: 14px;
|
465 |
}
|
466 |
.card-name {
|
467 |
font-weight: bold;
|
@@ -482,13 +481,12 @@ def load_session_history(selected_session=None):
|
|
482 |
|
483 |
for item in json_data:
|
484 |
name = html.escape(item.get('name', ''))
|
485 |
-
|
486 |
prompt = html.escape(item.get('prompt', ''))
|
487 |
|
488 |
-
# ์ด๋ฏธ์ง ๋์ ํ๋ ์ด์คํ๋ ์ฌ์ฉ
|
489 |
html_content += f"""
|
490 |
<div class="prompt-card" data-prompt="{prompt}" onclick="handleCardClick(this)">
|
491 |
-
<
|
492 |
<div class="card-name">{name}</div>
|
493 |
<div class="card-prompt">{prompt}</div>
|
494 |
</div>
|
@@ -523,7 +521,6 @@ def load_session_history(selected_session=None):
|
|
523 |
</script>
|
524 |
"""
|
525 |
|
526 |
-
print("Generated HTML content length:", len(html_content))
|
527 |
return gr.HTML(value=html_content)
|
528 |
|
529 |
except Exception as e:
|
|
|
398 |
return gr.update(choices=[])
|
399 |
|
400 |
def load_json_data():
|
401 |
+
# ํ๋์ฝ๋ฉ๋ ๋ฐ์ดํฐ ๋ฐํ
|
402 |
+
return [
|
403 |
+
{
|
404 |
+
"name": "MBTI ์ง๋จ ์๋น์ค",
|
405 |
+
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
406 |
+
"prompt": "MBTI ์ง๋จ์ ์ํด 15๊ฐ์ ์ง๋ฌธ๊ณผ ๊ฐ๊ด์ ๋ต๋ณ์ ํตํด MBTI ์ง๋จ ๊ฒฐ๊ณผ ๋ฐ ํด๋น ์ฑ๊ฒฉ์ ๋ํ ์์ธํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ผ"
|
407 |
+
},
|
408 |
+
{
|
409 |
+
"name": "ํฌ์ ํฌํธํด๋ฆฌ์ค ๋์๋ณด๋",
|
410 |
+
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
411 |
+
"prompt": "Create an interactive dashboard with Chart.js showing different types of charts (line, bar, pie) with smooth animations. Include buttons to switch between different data views.ํฌ์ ํฌํธํด๋ฆฌ์ค๋ฅผ ๋ถ์ํ์ฌ ์ํ๋, ์์ต๋ฅ , ์์ฐ ๋ฐฐ๋ถ์ ์๊ฐํํ๋ ํฌ์ ๊ด๋ฆฌ ๋๊ตฌ๋ฅผ ๋ง๋์ธ์."
|
412 |
+
},
|
413 |
+
{
|
414 |
+
"name": "์ฒด์ค ๊ฒ์",
|
415 |
+
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
416 |
+
"prompt": "์ฒด์ค ๊ฒ์: ์ฒด์ค ๊ฒ์์ ๋ฃฐ์ ์ ํํ๊ฒ ์๋ณํ๊ณ ์ ์ฉํ๋ผ, ์๋๋ฐฉ์ auto๋ก ๊ฒ์์ ์งํํ๋ผ"
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"name": "ํ๋ก์นด๋ ์ด์ธ",
|
420 |
+
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
421 |
+
"prompt": "ํ๋ก์นด๋ ์ด์ธ๋ฅผ ์ ์น๋๊ฒ์ ์์ฑํ๋ผ. ์์ฃผ ์์ธํ๊ณ ์ ๋ฌธ์ ์ด๋ฉด์ ์ฝ๊ณ ๊ธธ๊ฒ ๋ต๋ณํ๋ผ. ๋ชจ๋ ๋ต๋ณ๊ณผ ์ค๋ช
์ ํ๊ธ๋ก ํ๋ผ"
|
422 |
+
},
|
423 |
+
{
|
424 |
+
"name": "๋ฒฝ๋๊นจ๊ธฐ ๊ฒ์",
|
425 |
+
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
426 |
+
"prompt": "๋ฒฝ๋๊นจ๊ธฐ ๊ฒ์"
|
427 |
+
}
|
428 |
+
]
|
429 |
|
430 |
def load_session_history(selected_session=None):
|
431 |
try:
|
432 |
print("Loading session history...")
|
433 |
json_data = load_json_data()
|
434 |
+
print(f"Loaded {len(json_data)} items")
|
435 |
|
436 |
html_content = """
|
437 |
<style>
|
|
|
455 |
transform: translateY(-2px);
|
456 |
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
457 |
}
|
458 |
+
.card-image {
|
459 |
width: 100%;
|
460 |
height: 200px;
|
461 |
+
object-fit: cover;
|
|
|
|
|
|
|
462 |
border-radius: 4px;
|
463 |
margin-bottom: 10px;
|
|
|
|
|
464 |
}
|
465 |
.card-name {
|
466 |
font-weight: bold;
|
|
|
481 |
|
482 |
for item in json_data:
|
483 |
name = html.escape(item.get('name', ''))
|
484 |
+
image_url = item.get('image_url', '') # ์ด๋ฏธ base64 ์ธ์ฝ๋ฉ๋ ์ด๋ฏธ์ง URL
|
485 |
prompt = html.escape(item.get('prompt', ''))
|
486 |
|
|
|
487 |
html_content += f"""
|
488 |
<div class="prompt-card" data-prompt="{prompt}" onclick="handleCardClick(this)">
|
489 |
+
<img src="{image_url}" class="card-image" alt="{name}">
|
490 |
<div class="card-name">{name}</div>
|
491 |
<div class="card-prompt">{prompt}</div>
|
492 |
</div>
|
|
|
521 |
</script>
|
522 |
"""
|
523 |
|
|
|
524 |
return gr.HTML(value=html_content)
|
525 |
|
526 |
except Exception as e:
|