openfree commited on
Commit
6d46d5d
ยท
verified ยท
1 Parent(s): fc57a25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +142 -1076
app.py CHANGED
@@ -144,18 +144,7 @@ BUILTIN_MODULES = {
144
  'pipes', 'resource', 'nis', 'syslog', 'optparse', 'imp', 'posix', '_thread',
145
  'builtins', 'traceback', 'gc', 'inspect', 'site', 'user', 'distutils', 'test',
146
  'unittest', 'venv', 'code', 'codeop', 'pdb', 'profile', 'pstats', 'timeit',
147
- 'trace', 'tracemalloc', 'sched', 'secrets', 'mimetypes', 'base64', 'binhex',
148
- 'binascii', 'quopri', 'uu', 'xdrlib', 'zipapp', 'importlib', 'pkgutil', 'modulefinder',
149
- 'runpy', 'parser', 'ast', 'symtable', 'symbol', 'token', 'keyword', 'tokenize',
150
- 'tabnanny', 'pyclbr', 'py_compile', 'compileall', 'dis', 'pickletools', 'formatter',
151
- 'types', 'abc', 'numbers', 'decimal', 'fractions', 'statistics', 'bisect', 'heapq',
152
- 'reprlib', 'pprint', 'cmd', 'shlex', 'glob', 'fnmatch', 'linecache', 'rlcompleter',
153
- 'configparser', 'netrc', 'xdrlib', 'plistlib', 'aifc', 'asynchat', 'asyncore',
154
- 'audioop', 'crypt', 'imghdr', 'sndhdr', 'sunau', 'fileinput', 'stat', 'filecmp',
155
- 'formatterclass', 'getpass', 'gettext', 'locale', 'macpath', 'mailcap', 'mailbox',
156
- 'msilib', 'nis', 'nntplib', 'ntpath', 'ossaudiodev', 'pipes', 'poplib', 'posixpath',
157
- 'pty', 'pwd', 'pyclbr', 'py_compile', 'sched', 'site', 'smtpd', 'spwd', 'sunau',
158
- 'telnetlib', 'this', 'wave', 'webbrowser', 'winreg', 'winsound', 'wsgiref', 'xdrlib'
159
  }
160
 
161
  # Import to Package Name Mapping Dictionary
@@ -172,108 +161,7 @@ IMPORT_TO_PACKAGE = {
172
  'MySQLdb': 'mysqlclient',
173
  'psycopg2': 'psycopg2-binary',
174
  'magic': 'python-magic',
175
- 'Image': 'pillow',
176
- 'skimage': 'scikit-image',
177
- 'matplotlib.pyplot': 'matplotlib',
178
- 'plt': 'matplotlib',
179
- 'np': 'numpy',
180
- 'pd': 'pandas',
181
- 'pytorch': 'torch',
182
- 'transformers': 'transformers',
183
- 'librosa': 'librosa',
184
- 'nltk': 'nltk',
185
- 'spacy': 'spacy',
186
- 'requests': 'requests',
187
- 'flask': 'flask',
188
- 'fastapi': 'fastapi',
189
- 'aiohttp': 'aiohttp',
190
- 'imageio': 'imageio',
191
- 'moviepy': 'moviepy',
192
- 'networkx': 'networkx',
193
- 'statsmodels': 'statsmodels',
194
- 'seaborn': 'seaborn',
195
- 'bokeh': 'bokeh',
196
- 'plotly': 'plotly',
197
- 'dash': 'dash',
198
- 'streamlit': 'streamlit',
199
- 'altair': 'altair',
200
- 'geopandas': 'geopandas',
201
- 'folium': 'folium',
202
- 'shapely': 'shapely',
203
- 'fiona': 'fiona',
204
- 'rasterio': 'rasterio',
205
- 'gdal': 'gdal',
206
- 'pyproj': 'pyproj',
207
- 'rtree': 'rtree',
208
- 'cartopy': 'cartopy',
209
- 'geoplot': 'geoplot',
210
- 'descartes': 'descartes',
211
- 'pysal': 'pysal',
212
- 'geopy': 'geopy',
213
- 'osmnx': 'osmnx',
214
- 'contextily': 'contextily',
215
- 'xarray': 'xarray',
216
- 'netCDF4': 'netCDF4',
217
- 'h5py': 'h5py',
218
- 'tables': 'pytables',
219
- 'zarr': 'zarr',
220
- 'dask': 'dask',
221
- 'numba': 'numba',
222
- 'sympy': 'sympy',
223
- 'scipy': 'scipy',
224
- 'scikit-image': 'scikit-image',
225
- 'scikit-learn': 'scikit-learn',
226
- 'keras': 'keras',
227
- 'theano': 'theano',
228
- 'caffe': 'caffe',
229
- 'mxnet': 'mxnet',
230
- 'chainer': 'chainer',
231
- 'pytorch': 'torch',
232
- 'tensorflow-gpu': 'tensorflow-gpu',
233
- 'cupy': 'cupy',
234
- 'pycuda': 'pycuda',
235
- 'pyopencl': 'pyopencl',
236
- 'pyvista': 'pyvista',
237
- 'mayavi': 'mayavi',
238
- 'vtk': 'vtk',
239
- 'trimesh': 'trimesh',
240
- 'open3d': 'open3d-python',
241
- 'pyqt5': 'PyQt5',
242
- 'pyside2': 'PySide2',
243
- 'tkinter': 'tk',
244
- 'kivy': 'kivy',
245
- 'pygame': 'pygame',
246
- 'arcade': 'arcade',
247
- 'pyglet': 'pyglet',
248
- 'panda3d': 'panda3d',
249
- 'ursina': 'ursina',
250
- 'moderngl': 'moderngl',
251
- 'glfw': 'glfw',
252
- 'pyopengl': 'PyOpenGL',
253
- 'pysdl2': 'PySDL2',
254
- 'pybullet': 'pybullet',
255
- 'box2d': 'box2d-py',
256
- 'pymunk': 'pymunk',
257
- 'pyode': 'pyode',
258
- 'pyrr': 'pyrr',
259
- 'noise': 'noise',
260
- 'wave': 'wave',
261
- 'sounddevice': 'sounddevice',
262
- 'pyaudio': 'PyAudio',
263
- 'simpleaudio': 'simpleaudio',
264
- 'pygame.mixer': 'pygame',
265
- 'pydub': 'pydub',
266
- 'aubio': 'aubio',
267
- 'music21': 'music21',
268
- 'pretty_midi': 'pretty_midi',
269
- 'mido': 'mido',
270
- 'fluidsynth': 'fluidsynth',
271
- 'mingus': 'mingus',
272
- 'pyfluidsynth': 'pyfluidsynth',
273
- 'python-rtmidi': 'python-rtmidi',
274
- 'pygame.midi': 'pygame',
275
- 'soundfile': 'soundfile',
276
- 'resampy': 'resampy'
277
  }
278
 
279
 
@@ -382,43 +270,6 @@ def analyze_code(code: str) -> str:
382
 
383
  return "\n".join(analysis)
384
 
385
-
386
- def get_function_description(func: str) -> str:
387
- """ํ•จ์ˆ˜์˜ ๋ชฉ์ ์„ ์„ค๋ช…ํ•˜๋Š” ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜"""
388
- if 'get_multiplication_table' in func:
389
- return "์ž…๋ ฅ๋ฐ›์€ ์ˆซ์ž์˜ ๊ตฌ๊ตฌ๋‹จ์„ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜"
390
- elif 'get_all_tables' in func:
391
- return "2๋‹จ๋ถ€ํ„ฐ 9๋‹จ๊นŒ์ง€ ์ „์ฒด ๊ตฌ๊ตฌ๋‹จ์„ ์ƒ์„ฑํ•˜์—ฌ ๋ฐ˜ํ™˜"
392
- # ๋‹ค๋ฅธ ํ•จ์ˆ˜๋“ค์— ๋Œ€ํ•œ ์„ค๋ช… ์ถ”๊ฐ€
393
- return "ํ•จ์ˆ˜์˜ ๊ธฐ๋Šฅ ์„ค๋ช…"
394
-
395
- def get_component_description(component: str) -> str:
396
- """UI ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ์„ค๋ช… ๋ฐ˜ํ™˜"""
397
- descriptions = {
398
- 'Number': '์ˆซ์ž ์ž…๋ ฅ ํ•„๋“œ',
399
- 'Button': 'ํด๋ฆญ ๊ฐ€๋Šฅํ•œ ๋ฒ„ํŠผ',
400
- 'Textbox': 'ํ…์ŠคํŠธ ์ถœ๋ ฅ ์˜์—ญ',
401
- 'Markdown': '๋งˆํฌ๋‹ค์šด ํ˜•์‹์˜ ํ…์ŠคํŠธ ํ‘œ์‹œ',
402
- 'Row': '์ˆ˜ํ‰ ๋ฐฉํ–ฅ ๋ ˆ์ด์•„์›ƒ',
403
- 'Column': '์ˆ˜์ง ๋ฐฉํ–ฅ ๋ ˆ์ด์•„์›ƒ',
404
- 'Blocks': '์ „์ฒด UI ์ปจํ…Œ์ด๋„ˆ',
405
- 'Image': '์ด๋ฏธ์ง€ ํ‘œ์‹œ ์ปดํฌ๋„ŒํŠธ',
406
- 'File': 'ํŒŒ์ผ ์—…๋กœ๋“œ ์ปดํฌ๋„ŒํŠธ',
407
- 'Slider': '์Šฌ๋ผ์ด๋” ์ž…๋ ฅ ์ปดํฌ๋„ŒํŠธ',
408
- 'Dropdown': '๋“œ๋กญ๋‹ค์šด ์„ ํƒ ์ปดํฌ๋„ŒํŠธ',
409
- 'Radio': '๋ผ๋””์˜ค ๋ฒ„ํŠผ ๊ทธ๋ฃน',
410
- 'Checkbox': '์ฒดํฌ๋ฐ•์Šค ์ปดํฌ๋„ŒํŠธ',
411
- 'Audio': '์˜ค๋””์˜ค ์žฌ์ƒ/๋…น์Œ ์ปดํฌ๋„ŒํŠธ',
412
- 'Video': '๋น„๋””์˜ค ์žฌ์ƒ ์ปดํฌ๋„ŒํŠธ',
413
- 'HTML': 'HTML ์ฝ˜ํ…์ธ  ํ‘œ์‹œ',
414
- 'JSON': 'JSON ๋ฐ์ดํ„ฐ ํ‘œ์‹œ',
415
- 'DataFrame': '๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„ ํ‘œ์‹œ',
416
- 'Plot': '๊ทธ๋ž˜ํ”„/์ฐจํŠธ ํ‘œ์‹œ',
417
- 'Label': '๋ ˆ์ด๋ธ” ํ…์ŠคํŠธ ํ‘œ์‹œ'
418
- }
419
- return descriptions.get(component, '์ปดํฌ๋„ŒํŠธ ์„ค๋ช…')
420
-
421
-
422
  async def try_claude_api(system_message, claude_messages, timeout=15):
423
  try:
424
  start_time = time.time()
@@ -465,71 +316,35 @@ async def try_openai_api(openai_messages):
465
  print(f"OpenAI API error: {str(e)}")
466
  raise e
467
 
468
- def deploy_to_vercel(code: str):
469
- try:
470
- token = "A8IFZmgW2cqA4yUNlLPnci0N" # Improvement: Do not hardcode tokens; use environment variables.
471
- if not token:
472
- return "Vercel ํ† ํฐ์ด ์„ค์ •๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
473
-
474
- project_name = ''.join(random.choice(string.ascii_lowercase) for i in range(6))
475
- deploy_url = "https://api.vercel.com/v13/deployments"
476
-
477
- headers = {
478
- "Authorization": f"Bearer {token}",
479
- "Content-Type": "application/json"
480
- }
481
-
482
- package_json = {
483
- "name": project_name,
484
- "version": "1.0.0",
485
- "private": True,
486
- "dependencies": {
487
- "vite": "^5.0.0"
488
- },
489
- "scripts": {
490
- "dev": "vite",
491
- "build": "echo 'No build needed' && mkdir -p dist && cp index.html dist/",
492
- "preview": "vite preview"
493
- }
494
- }
495
-
496
- files = [
497
- {
498
- "file": "index.html",
499
- "data": code
500
- },
501
- {
502
- "file": "package.json",
503
- "data": json.dumps(package_json, indent=2)
504
- }
505
- ]
506
-
507
- project_settings = {
508
- "buildCommand": "npm run build",
509
- "outputDirectory": "dist",
510
- "installCommand": "npm install",
511
- "framework": None
512
- }
513
-
514
- deploy_data = {
515
- "name": project_name,
516
- "files": files,
517
- "target": "production",
518
- "projectSettings": project_settings
519
- }
520
 
521
- deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
 
523
- if deploy_response.status_code != 200:
524
- return f"๋ฐฐํฌ ์‹คํŒจ: {deploy_response.text}"
525
-
526
- deployment_url = f"{project_name}.vercel.app"
527
- time.sleep(5)
528
-
529
- return f"""๋ฐฐํฌ ์™„๋ฃŒ! <a href="https://{deployment_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">https://{deployment_url}</a>"""
530
-
531
- except Exception as e:
532
- return f"๋ฐฐํฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
533
 
534
  def boost_prompt(prompt: str) -> str:
535
  if not prompt:
@@ -593,150 +408,86 @@ def handle_boost(prompt: str):
593
  print(f"Boost ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
594
  return prompt, gr.update(active_key="empty")
595
 
596
- def execute_code(query: str):
597
- if not query or query.strip() == '':
598
- return None, gr.update(active_key="empty")
599
-
 
 
 
600
  try:
601
- if '```html' in query and '```' in query:
602
- code = remove_code_block(query)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  else:
604
- code = query.strip()
605
 
606
- return send_to_sandbox(code), gr.update(active_key="render")
607
- except Exception as e:
608
- print(f"Error executing code: {str(e)}")
609
- return None, gr.update(active_key="empty")
610
-
611
- def remove_code_block(text):
612
- text = re.sub(r'```[python|html]?\n', '', text)
613
- text = re.sub(r'\n```', '', text)
614
-
615
- lines = text.split('\n')
616
- filtered_lines = []
617
- seen_imports = set()
618
-
619
- for line in lines:
620
- if not line.strip():
621
- continue
622
-
623
- if line.startswith('import ') or line.startswith('from '):
624
- import_key = line.split('#')[0].strip()
625
- if import_key in seen_imports:
626
- continue
627
- seen_imports.add(import_key)
628
-
629
- if 'if __name__ == "__main__":' in line:
630
- continue
631
- if 'demo.launch()' in line:
632
- continue
633
 
634
- filtered_lines.append(line)
 
 
 
 
 
 
 
 
 
 
 
635
 
636
- return '\n'.join(filtered_lines)
637
-
638
- def history_render(history: History):
639
- return gr.update(open=True), history
640
-
641
- def send_to_sandbox(code):
642
- encoded_html = base64.b64encode(code.encode('utf-8')).decode('utf-8')
643
- data_uri = f"data:text/html;charset=utf-8;base64,{encoded_html}"
644
- return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
645
-
646
- def load_json_data():
647
- # ํ…œํ”Œ๋ฆฟ ๋ฐ์ดํ„ฐ ๋ฐ˜ํ™˜
648
- return [
649
- # ... (์ด์ „์— ์ •์˜๋œ ํ…œํ”Œ๋ฆฟ ๋ฐ์ดํ„ฐ)
650
- ]
651
-
652
- def load_best_templates():
653
- json_data = load_json_data()[:12]
654
- return create_template_html("๐Ÿ† ๋ฒ ์ŠคํŠธ ํ…œํ”Œ๋ฆฟ", json_data)
655
-
656
- def load_trending_templates():
657
- json_data = load_json_data()[12:24]
658
- return create_template_html("๐Ÿ”ฅ ํŠธ๋ Œ๋”ฉ ํ…œํ”Œ๋ฆฟ", json_data)
659
-
660
- def load_new_templates():
661
- json_data = load_json_data()[24:44]
662
- return create_template_html("โœจ NEW ํ…œํ”Œ๋ฆฟ", json_data)
663
-
664
- def create_template_html(title, items):
665
- html_content = """
666
- <style>
667
- .prompt-grid {
668
- display: grid;
669
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
670
- gap: 20px;
671
- padding: 20px;
672
- }
673
- .prompt-card {
674
- background: white;
675
- border: 1px solid #eee;
676
- border-radius: 8px;
677
- padding: 15px;
678
- cursor: pointer;
679
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
680
- }
681
- .prompt-card:hover {
682
- transform: translateY(-2px);
683
- transition: transform 0.2s;
684
- }
685
- .card-image {
686
- width: 100%;
687
- height: 180px;
688
- object-fit: cover;
689
- border-radius: 4px;
690
- margin-bottom: 10px;
691
- }
692
- .card-name {
693
- font-weight: bold;
694
- margin-bottom: 8px;
695
- font-size: 16px;
696
- color: #333;
697
- }
698
- .card-prompt {
699
- font-size: 11px;
700
- line-height: 1.4;
701
- color: #666;
702
- display: -webkit-box;
703
- -webkit-line-clamp: 6;
704
- -webkit-box-orient: vertical;
705
- overflow: hidden;
706
- height: 90px;
707
- background-color: #f8f9fa;
708
- padding: 8px;
709
- border-radius: 4px;
710
- }
711
- </style>
712
- <div class="prompt-grid">
713
- """
714
-
715
- for item in items:
716
- html_content += f"""
717
- <div class="prompt-card" onclick="copyToInput(this)" data-prompt="{html.escape(item.get('prompt', ''))}">
718
- <img src="{item.get('image_url', '')}" class="card-image" loading="lazy" alt="{html.escape(item.get('name', ''))}">
719
- <div class="card-name">{html.escape(item.get('name', ''))}</div>
720
- <div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
721
- </div>
722
- """
723
-
724
- html_content += """
725
- <script>
726
- function copyToInput(card) {
727
- const prompt = card.dataset.prompt;
728
- const textarea = document.querySelector('.ant-input-textarea-large textarea');
729
- if (textarea) {
730
- textarea.value = prompt;
731
- textarea.dispatchEvent(new Event('input', { bubbles: true }));
732
- document.querySelector('.session-drawer .close-btn').click();
733
- }
734
- }
735
- </script>
736
- </div>
737
- """
738
- return gr.HTML(value=html_content)
739
-
740
  class Demo:
741
  def __init__(self):
742
  pass
@@ -769,7 +520,6 @@ class Demo:
769
  yield [
770
  "Generating code...",
771
  _history,
772
- None,
773
  gr.update(active_key="loading"),
774
  gr.update(open=True)
775
  ]
@@ -783,7 +533,6 @@ class Demo:
783
  yield [
784
  code,
785
  _history,
786
- analysis,
787
  gr.update(active_key="loading"),
788
  gr.update(open=True)
789
  ]
@@ -799,7 +548,6 @@ class Demo:
799
  yield [
800
  code,
801
  _history,
802
- analysis,
803
  gr.update(active_key="loading"),
804
  gr.update(open=True)
805
  ]
@@ -817,8 +565,7 @@ class Demo:
817
  yield [
818
  collected_content,
819
  _history,
820
- analyze_code(collected_content),
821
- gr.update(active_key="render"),
822
  gr.update(open=True)
823
  ]
824
  else:
@@ -835,653 +582,15 @@ class Demo:
835
  # theme = gr.themes.Soft()
836
  theme='earneleh/paris'
837
 
838
- def load_json_data():
839
- return [
840
- {
841
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๊ตฌ๊ตฌ๋‹จ ๊ณ„์‚ฐ๊ธฐ",
842
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
843
- "prompt": "๊ตฌ๊ตฌ๋‹จ์„ ๊ณ„์‚ฐํ•˜๊ณ  ์ถœ๋ ฅํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๋งŒ๋“œ์„ธ์š”. ์‚ฌ์šฉ์ž๊ฐ€ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ๋‹จ์˜ ๊ตฌ๊ตฌ๋‹จ์ด ์ถœ๋ ฅ๋˜๊ณ , '์ „์ฒด ๊ตฌ๊ตฌ๋‹จ ๋ณด๊ธฐ' ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด 2~9๋‹จ๊นŒ์ง€ ๋ชจ๋‘ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค."
844
- },
845
- {
846
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๋ณตํ•ฉ ์„ ํƒ ๋ฐ ๋ฌธ์žฅ ์ƒ์„ฑ ์ฒ˜๋ฆฌ",
847
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
848
- "prompt": "ํ•œ๊ตญ์–ด๋กœ ๋™์ž‘ํ•˜๋Š” ๋ฌธ์žฅ ์ƒ์„ฑ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์Šฌ๋ผ์ด๋”(์ˆ˜๋Ÿ‰ 2-20), ๋“œ๋กญ๋‹ค์šด(๋™๋ฌผ ์ข…๋ฅ˜), ์ฒดํฌ๋ฐ•์Šค(๊ตญ๊ฐ€ ์„ ํƒ), ๋ผ๋””์˜ค๋ฒ„ํŠผ(์žฅ์†Œ), ๋‹ค์ค‘์„ ํƒ ๋“œ๋กญ๋‹ค์šด(ํ™œ๋™), ์ฒดํฌ๋ฐ•์Šค(์•„์นจ/์ €๋…)๋ฅผ ํ†ตํ•ด ์ž…๋ ฅ๋ฐ›์€ ๊ฐ’๋“ค๋กœ '[๊ตญ๊ฐ€]์—์„œ ์˜จ [์ˆ˜๋Ÿ‰]๋งˆ๋ฆฌ์˜ [๋™๋ฌผ]์ด [์žฅ์†Œ]์—์„œ [ํ™œ๋™] ํ–ˆ์Šต๋‹ˆ๋‹ค. [์‹œ๊ฐ„]๊นŒ์ง€.' ํ˜•์‹์˜ ๋ฌธ์žฅ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
849
- },
850
- {
851
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๋ฐ์ดํ„ฐ ๋ ˆ์ฝ”๋“œ ์ฒ˜๋ฆฌ",
852
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
853
- "prompt": "๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์—์„œ ์„ฑ๋ณ„ ํ•„ํ„ฐ๋งํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„(์ด๋ฆ„, ๋‚˜์ด, ์„ฑ๋ณ„ ์ปฌ๋Ÿผ)๊ณผ ๋“œ๋กญ๋‹ค์šด(์„ฑ๋ณ„ ์„ ํƒ)์„ ํ†ตํ•ด ์„ ํƒ๋œ ์„ฑ๋ณ„์— ํ•ด๋‹นํ•˜๋Š” ๋ ˆ์ฝ”๋“œ๋งŒ ํ•„ํ„ฐ๋งํ•˜์—ฌ ๋ณด์—ฌ์ฃผ๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
854
- },
855
-
856
- {
857
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ์˜ค๋””์˜ค ์ƒ์„ฑ ๋ฐ ์ฒ˜๋ฆฌ",
858
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
859
- "prompt": "์Œ์•… ์Œ ์ƒ์„ฑ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ๋“œ๋กญ๋‹ค์šด(์Œ๊ณ„ C~B), ์Šฌ๋ผ์ด๋”(์˜ฅํƒ€๋ธŒ 4-6), ํ…์ŠคํŠธ๋ฐ•์Šค(์žฌ์ƒ์‹œ๊ฐ„)๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์„ ํƒํ•œ ์Œ์„ ์ƒ์„ฑํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. numpy๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์ธํŒŒ๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ƒ˜ํ”Œ๋ง ๋ ˆ์ดํŠธ๋Š” 48000Hz๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”."
860
- },
861
- {
862
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ํ–‰๋ ฌ ์ „์น˜ ์ฒ˜๋ฆฌ",
863
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
864
- "prompt": "ํ–‰๋ ฌ ์ „์น˜(transpose) ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์ˆซ์žํ˜• ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„(5x3)์„ ์ œ๊ณตํ•˜๊ณ , numpy๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ž…๋ ฅ๋œ ํ–‰๋ ฌ์„ ์ „์น˜ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์˜ˆ์ œ๋กœ ์˜ํ–‰๋ ฌ, ๋‹จ์œ„ํ–‰๋ ฌ, ๊ทธ๋ฆฌ๊ณ  3๊ฐœ์˜ ๋žœ๋ค ํ–‰๋ ฌ์„ ํฌํ•จํ•ด์ฃผ์„ธ์š”."
865
- },
866
- {
867
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ์ˆ˜ํ•™ ๊ณ„์‚ฐ ์ฒ˜๋ฆฌ",
868
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
869
- "prompt": "์„ธ๊ธˆ ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์ˆซ์žํ˜• ์ž…๋ ฅ(์—ฐ๊ฐ„ ์†Œ๋“), ๋ผ๋””์˜ค๋ฒ„ํŠผ(๊ฒฐํ˜ผ์ƒํƒœ: ๋ฏธํ˜ผ/๊ธฐํ˜ผ/์ดํ˜ผ), ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„(์ž์‚ฐ ํ•ญ๋ชฉ๊ณผ ๋น„์šฉ)์„ ์ž…๋ ฅ๋ฐ›์•„ ์„ธ๊ธˆ์„ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค. ์†Œ๋“๊ตฌ๊ฐ„๋ณ„ ์„ธ์œจ(10๋งŒ์› ์ดํ•˜ 0%, 25๋งŒ์› ์ดํ•˜ 8% ๋“ฑ)์„ ์ ์šฉํ•˜๊ณ , ๊ธฐํ˜ผ์ž๋Š” 25% ๊ฐ๋ฉด, ์ดํ˜ผ์ž๋Š” 20% ๊ฐ๋ฉด๋ฉ๋‹ˆ๋‹ค. ๊ตฌ๋งคํ•œ ์ž์‚ฐ์€ ์†Œ๋“๊ณต์ œ๋˜๋ฉฐ, ๋‘ ๊ฐœ์˜ ์˜ˆ์‹œ ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•ด์ฃผ์„ธ์š”."
870
- },
871
-
872
- {
873
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ์ฐจํŠธ ์ƒ์„ฑ ์ฒ˜๋ฆฌ",
874
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
875
- "prompt": "๊ธฐ์—… ์„ฑ์žฅ ์˜ˆ์ธก ๊ทธ๋ž˜ํ”„๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ๋ผ๋””์˜ค๋ฒ„ํŠผ(๋ชฉํ‘œ์—ฐ๋„ 2025-2040), ์ฒดํฌ๋ฐ•์Šค๊ทธ๋ฃน(๊ธฐ์—…์„ ํƒ), ์Šฌ๋ผ์ด๋”(๋…ธ์ด์ฆˆ 1-100), ์ฒดํฌ๋ฐ•์Šค(๋ฒ”๋ก€ํ‘œ์‹œ), ๋“œ๋กญ๋‹ค์šด(๊ทธ๋ž˜ํ”„์Šคํƒ€์ผ)์„ ์ž…๋ ฅ๋ฐ›์•„ matplotlib์œผ๋กœ ๊ฐ ๊ธฐ์—…์˜ ์„ฑ์žฅ๊ณก์„ ์„ ์‹œ๊ฐํ™”ํ•ฉ๋‹ˆ๋‹ค. 2020๋…„๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ ๊ธฐ์—…๋ณ„๋กœ 2์ฐจ ํ•จ์ˆ˜ ํ˜•ํƒœ์˜ ์„ฑ์žฅ๊ณก์„ ์„ ๊ทธ๋ฆฌ๋ฉฐ, ์„ ํƒ๋œ ๋…ธ์ด์ฆˆ๋ฅผ ์ ์šฉํ•ด์ฃผ์„ธ์š”."
876
- },
877
- {
878
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ์ŠคํŠธ๋ฆฌ๋ฐ ์ฑ—๋ด‡ ๊ตฌ์„ฑ ์ฒ˜๋ฆฌ",
879
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
880
- "prompt": "ํ•œ๊ธ€ ํƒ€์ดํ•‘ ํšจ๊ณผ๊ฐ€ ์žˆ๋Š” ์ฑ„ํŒ… ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์‚ฌ์šฉ์ž์˜ ์ž…๋ ฅ ๋ฉ”์‹œ์ง€๋ฅผ ํ•œ ๊ธ€์ž์”ฉ 0.05์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ์ถœ๋ ฅํ•˜๋ฉฐ, ๊ฐ ๋ฉ”์‹œ์ง€ ์•ž์— '๋‹น์‹ ์˜ ์ž…๋ ฅ์–ด:'๋ฅผ ๋ถ™์—ฌ์„œ ๋ณด์—ฌ์ฃผ๋Š” ์ฑ—๋ด‡์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
881
- },
882
- {
883
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๋ฉ€ํ‹ฐ ํƒญ ๊ตฌ์„ฑ ์ฒ˜๋ฆฌ",
884
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
885
- "prompt": "ํ…์ŠคํŠธ์™€ ์ด๋ฏธ์ง€๋ฅผ ์ขŒ์šฐ๋ฐ˜์ „ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ์ฒซ ๋ฒˆ์งธ ํƒญ์—์„œ๋Š” ํ…์ŠคํŠธ ์ž…๋ ฅ์ฐฝ๊ณผ ๋ฐ˜์ „ ๋ฒ„ํŠผ์œผ๋กœ ํ…์ŠคํŠธ๋ฅผ ๋ฐ˜์ „ํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ํƒญ์—์„œ๋Š” ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ์™€ ๋ฐ˜์ „ ๋ฒ„ํŠผ์œผ๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ขŒ์šฐ๋ฐ˜์ „ํ•ฉ๋‹ˆ๋‹ค. ์•„์ฝ”๋””์–ธ ๋ฉ”๋‰ด์—๋Š” 0๋ถ€ํ„ฐ 1๊นŒ์ง€ ์กฐ์ ˆ ๊ฐ€๋Šฅํ•œ ์Šฌ๋ผ์ด๋”๋ฅผ ํฌํ•จํ•ด์ฃผ์„ธ์š”."
886
- },
887
-
888
- {
889
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ํ…์ŠคํŠธ ๊ณ ๊ธ‰ ๋ถ„์„(๊ฐ์ •) ์ฒ˜๋ฆฌ",
890
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
891
- "prompt": "ํ…์ŠคํŠธ ๊ฐ์ • ๋ถ„์„๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. Hugging Face์˜ transformers.js๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ํ…์ŠคํŠธ์˜ ๊ฐ์ •์„ ๋ถ„์„ํ•˜๊ณ , ๊ฒฐ๊ณผ๋ฅผ JSON ํ˜•ํƒœ๋กœ ์ถœ๋ ฅํ•˜๋Š” ๊ฐ„๋‹จํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
892
- },
893
- {
894
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๊ฐ์ • ๋ถ„์„ ์‹œ์Šคํ…œ",
895
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
896
- "prompt": "ํ…์ŠคํŠธ ๊ฐ์ • ๋ถ„์„๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. Hugging Face์˜ transformers.js์˜ 'sentiment-analysis' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ์˜ ๊ฐ์ •์„ ๋ถ„์„ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
897
- },
898
- {
899
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ๋ฌธ์žฅ ์ฑ„์šฐ๊ธฐ ์‹œ์Šคํ…œ",
900
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
901
- "prompt": "๋ฌธ์žฅ ์™„์„ฑ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'fill-mask' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ [MASK] ํ† ํฐ์ด ํฌํ•จ๋œ ๋ฌธ์žฅ์„ ์™„์„ฑํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
902
- },
903
- {
904
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ํ…์ŠคํŠธ ์ƒ์„ฑ ์‹œ์Šคํ…œ",
905
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
906
- "prompt": "ํ…์ŠคํŠธ ์ƒ์„ฑ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'text-generation' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹œ์ž‘ ๋ฌธ๊ตฌ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
907
- },
908
- {
909
- "name": "[๊ธฐ๋ณธ/์ปดํฌ๋„ŒํŠธ] ์ œ๋กœ์ƒท ๋ถ„๋ฅ˜ ์‹œ์Šคํ…œ",
910
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
911
- "prompt": "ํ…์ŠคํŠธ ๋ถ„๋ฅ˜๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'zero-shot-classification' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ๋ฅผ ์ฃผ์–ด์ง„ ๋ ˆ์ด๋ธ”๋กœ ๋ถ„๋ฅ˜ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
912
- },
913
- {
914
- "name": "[๏ฟฝ๏ฟฝ๏ฟฝ์šฉ์šฉ] ํ† ํฐ ๋ถ„๋ฅ˜ ์‹œ์Šคํ…œ",
915
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
916
- "prompt": "ํ† ํฐ ๋ถ„๋ฅ˜๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'token-classification' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ์—์„œ ๊ฐœ์ฒด๋ช…์„ ์ธ์‹ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
917
- },
918
- {
919
- "name": "[์‘์šฉ] ์งˆ๋ฌธ ๋‹ต๋ณ€ ์‹œ์Šคํ…œ",
920
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
921
- "prompt": "QA ์‹œ์Šคํ…œ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'question-answering' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฃผ์–ด์ง„ ๋ฌธ๋งฅ์—์„œ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
922
- },
923
- {
924
- "name": "[์‘์šฉ] ๋ฌธ์žฅ ์œ ์‚ฌ๋„ ์‹œ์Šคํ…œ",
925
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
926
- "prompt": "๋ฌธ์žฅ ์œ ์‚ฌ๋„ ๋ถ„์„๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'feature-extraction' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‘ ๋ฌธ์žฅ ๊ฐ„์˜ ์œ ์‚ฌ๋„๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
927
- },
928
- {
929
- "name": "[์‘์šฉ] ๋ฌธ์„œ ์š”์•ฝ ์‹œ์Šคํ…œ",
930
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
931
- "prompt": "ํ…์ŠคํŠธ ์š”์•ฝ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'summarization' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธด ํ…์ŠคํŠธ๋ฅผ ์š”์•ฝํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
932
- },
933
- {
934
- "name": "[์‘์šฉ] ๋ฒˆ์—ญ ์‹œ์Šคํ…œ",
935
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
936
- "prompt": "๋ฒˆ์—ญ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'translation' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ๋ฅผ ๋‹ค๋ฅธ ์–ธ์–ด๋กœ ๋ฒˆ์—ญํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
937
- },
938
- {
939
- "name": "[์‘์šฉ] ํ…์ŠคํŠธ ๋ถ„๋ฅ˜ ์‹œ์Šคํ…œ",
940
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
941
- "prompt": "ํ…์ŠคํŠธ ๋ถ„๋ฅ˜๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. transformers.js์˜ 'text-classification' ํŒŒ์ดํ”„๋ผ์ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ๋ฅผ ๋ฏธ๋ฆฌ ์ •์˜๋œ ์นดํ…Œ๊ณ ๋ฆฌ๋กœ ๋ถ„๋ฅ˜ํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."
942
- }, #์ด์ƒ 19๊ฐœ, ์ดํ•˜ 26๊ฐœ
943
-
944
- {
945
- "name": "[์‘์šฉ] BMI ๊ณ„์‚ฐ๊ธฐ",
946
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
947
- "prompt": "ํ‚ค(cm)์™€ ๋ชธ๋ฌด๊ฒŒ(kg)๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ BMI๋ฅผ ๊ณ„์‚ฐํ•˜๊ณ , ๋น„๋งŒ๋„ ํŒ์ • ๊ฒฐ๊ณผ๋ฅผ ์‹œ๊ฐ์ ์œผ๋กœ ํ‘œ์‹œํ•˜๋Š” ์•ฑ์„ ๋งŒ๋“œ์„ธ์š”. ๊ฒฐ๊ณผ๋Š” ์ €์ฒด์ค‘/์ •์ƒ/๊ณผ์ฒด์ค‘/๋น„๋งŒ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค."
948
- },
949
- {
950
- "name": "[์‘์šฉ] ํ• ์ธ ๊ณ„์‚ฐ๊ธฐ",
951
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
952
- "prompt": "์ƒํ’ˆ์˜ ์›๊ฐ€์™€ ํ• ์ธ์œจ์„ ์ž…๋ ฅ๋ฐ›์•„ ํ• ์ธ๊ฐ€๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ์•ฑ์„ ๋งŒ๋“œ์„ธ์š”. ํ• ์ธ์œจ์€ ์Šฌ๋ผ์ด๋”๋กœ ์กฐ์ ˆ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ์ตœ์ข… ๊ฐ€๊ฒฉ๊ณผ ์ ˆ์•ฝ ๊ธˆ์•ก์„ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค."
953
- },
954
- {
955
- "name": "[์‘์šฉ] ๋‹จ์œ„ ๋ณ€ํ™˜๊ธฐ",
956
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
957
- "prompt": "๊ธธ์ด(m/cm/km), ๋ฌด๊ฒŒ(kg/g), ์˜จ๋„(์„ญ์”จ/ํ™”์”จ) ๋“ฑ ๊ธฐ๋ณธ์ ์ธ ๋‹จ์œ„ ๋ณ€ํ™˜๊ธฐ๋ฅผ ๋งŒ๋“œ์„ธ์š”. ๋“œ๋กญ๋‹ค์šด์œผ๋กœ ๋ณ€ํ™˜ ๋‹จ์œ„๋ฅผ ์„ ํƒํ•˜๊ณ  ์‹ค์‹œ๊ฐ„์œผ๋กœ ๊ฒฐ๊ณผ๊ฐ€ ์—…๋ฐ์ดํŠธ๋ฉ๋‹ˆ๋‹ค."
958
- },
959
- {
960
- "name": "[์‘์šฉ] ๋žœ๋ค ๋ฒˆํ˜ธ ์ƒ์„ฑ๊ธฐ",
961
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
962
- "prompt": "๋กœ๋˜ ๋ฒˆํ˜ธ๋‚˜ ๋žœ๋ค ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์•ฑ์„ ๋งŒ๋“œ์„ธ์š”. ์‚ฌ์šฉ์ž๊ฐ€ ๋ฒ”์œ„์™€ ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ƒ์„ฑ๋œ ๋ฒˆํ˜ธ๋Š” ์ •๋ ฌ๋˜์–ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค."
963
- },
964
-
965
- {
966
- "name": "[์‘์šฉ] ์ด๋ฏธ์ง€ ํŽธ์ง‘๊ธฐ",
967
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
968
- "prompt": "PIL๊ณผ numpy๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€ ํ•„ํ„ฐ(ํ‘๋ฐฑ, ์„ธํ”ผ์•„, ๋ธ”๋Ÿฌ ๋“ฑ), ํšŒ์ „, ๋ฆฌ์‚ฌ์ด์ฆˆ ๊ธฐ๋Šฅ์ด ์žˆ๋Š” ๊ธฐ๋ณธ์ ์ธ ์ด๋ฏธ์ง€ ํŽธ์ง‘๊ธฐ๋ฅผ ๋งŒ๋“œ์„ธ์š”."
969
- },
970
- {
971
- "name": "[์‘์šฉ] ์ผ๊ธฐ์˜ˆ๋ณด ๋Œ€์‹œ๋ณด๋“œ",
972
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
973
- "prompt": "OpenWeatherMap API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋„์‹œ๋ณ„ ๋‚ ์”จ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , ์˜จ๋„, ์Šต๋„, ํ’์† ๋“ฑ์„ ์‹œ๊ฐํ™”ํ•˜๋Š” ๋Œ€์‹œ๋ณด๋“œ๋ฅผ ๋งŒ๋“œ์„ธ์š”."
974
- },
975
-
976
-
977
- {
978
- "name": "[์‘์šฉ] ํ…์ŠคํŠธ ์š”์•ฝ๊ธฐ",
979
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
980
- "prompt": "ํ—ˆ๊น…ํŽ˜์ด์Šค์˜ text-summarization ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธด ํ…์ŠคํŠธ๋ฅผ ์ž๋™์œผ๋กœ ์š”์•ฝํ•˜๋Š” ์•ฑ์„ ๋งŒ๋“œ์„ธ์š”."
981
- },
982
-
983
-
984
- {
985
- "name": "[์‘์šฉ] MBTI ์ง„๋‹จ ์„œ๋น„์Šค",
986
- "image_url": "data:image/png;base64," + get_image_base64('mbti.png'),
987
- "prompt": "16๊ฐ€์ง€ ์„ฑ๊ฒฉ์œ ํ˜• ์ง„๋‹จ์„ ์œ„ํ•œ 15๊ฐœ์˜ ๏ฟฝ๏ฟฝ๊ด€์‹ ์งˆ๋ฌธ์„ ์ œ์‹œํ•˜๊ณ , ์‘๋‹ต ๊ฒฐ๊ณผ์— ๋”ฐ๋ฅธ MBTI ์œ ํ˜•๊ณผ ์„ฑ๊ฒฉ ํŠน์„ฑ์„ ๋ถ„์„ํ•˜์—ฌ ์ถœ๋ ฅํ•˜์„ธ์š”."
988
- },
989
- {
990
- "name": "[ํ™œ์šฉ] ๋‚˜์˜ ์‹ฌ๋ฆฌ์ƒํƒœ ํ€ด์ฆˆ",
991
- "image_url": "data:image/png;base64," + get_image_base64('simri.png'),
992
- "prompt": "10๊ฐœ์˜ ์‹ฌ๋ฆฌ์ง„๋‹จ ๊ฐ๊ด€์‹ ๋ฌธํ•ญ์„ ํ†ตํ•ด ํ˜„์žฌ ์‹ฌ๋ฆฌ์ƒํƒœ๋ฅผ ๋ถ„์„ํ•˜๊ณ , ์ŠคํŠธ๋ ˆ์Šค ์ˆ˜์ค€๊ณผ ๋Œ€์ฒ˜ ๋ฐฉ์•ˆ์„ ์ œ์‹œํ•˜์„ธ์š”."
993
- },
994
-
995
-
996
- #์—ฌ๊ธฐ๋ถ€ํ„ฐ ๊ฐ๊ฐ ์ „์ˆ˜๊ฒ€์‚ฌํ• ๊ฒƒ
997
- # AI/๋ถ„์„ ์นดํ…Œ๊ณ ๋ฆฌ
998
- {
999
- "name": "[ํ™œ์šฉ] ํˆฌ์ž ํฌํŠธํด๋ฆฌ์˜ค ๋ถ„์„",
1000
- "image_url": "data:image/png;base64," + get_image_base64('dash.png'),
1001
- "prompt": "์ฃผ์‹ ํฌํŠธํด๋ฆฌ์˜ค์˜ ๊ตฌ์„ฑ๋น„์œจ๊ณผ ํˆฌ์ž๊ธˆ์•ก์„ ์ž…๋ ฅ๋ฐ›์•„ ์œ„ํ—˜๋„, ์ˆ˜์ต๋ฅ ์„ ๋ถ„์„ํ•˜๊ณ  ์ฐจํŠธ๋กœ ์‹œ๊ฐํ™”ํ•˜์„ธ์š”."
1002
- },
1003
- {
1004
- "name": "[ํ™œ์šฉ] ํ…์ŠคํŠธ ์š”์•ฝ ๋„๊ตฌ",
1005
- "image_url": "data:image/png;base64," + get_image_base64('yout.png'),
1006
- "prompt": "๊ธด ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ํ•ต์‹ฌ ๋‚ด์šฉ์„ ์ถ”์ถœํ•˜๊ณ  ์š”์•ฝํ•˜์—ฌ ์ถœ๋ ฅํ•˜์„ธ์š”. ์š”์•ฝ ๊ธธ์ด๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค."
1007
- },
1008
- {
1009
- "name": "[ํ™œ์šฉ] ํ…์ŠคํŠธ ์Œ์„ฑ๋ณ€ํ™˜",
1010
- "image_url": "data:image/png;base64," + get_image_base64('tts.png'),
1011
- "prompt": "์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ์ž์—ฐ์Šค๋Ÿฌ์šด ์Œ์„ฑ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , ์Œ์„ฑ์˜ ์†๋„์™€ ํ†ค์„ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ตฌํ˜„ํ•˜์„ธ์š”."
1012
- },
1013
-
1014
- # ๋„๊ตฌ/์œ ํ‹ธ๋ฆฌํ‹ฐ ์นดํ…Œ๊ณ ๋ฆฌ
1015
- {
1016
- "name": "[ํ™œ์šฉ] ์„ค๋ฌธ์กฐ์‚ฌ ์ œ์ž‘",
1017
- "image_url": "data:image/png;base64," + get_image_base64('survay.png'),
1018
- "prompt": "์„ค๋ฌธ ์ œ๋ชฉ, ์งˆ๋ฌธ ์œ ํ˜•, ๋ณด๊ธฐ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์„ค๋ฌธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์‘๋‹ต์„ ์ˆ˜์ง‘/๋ถ„์„ํ•˜์—ฌ ๊ฒฐ๊ณผ๋ฅผ ์ฐจํŠธ๋กœ ํ‘œ์‹œํ•˜์„ธ์š”."
1019
- },
1020
- {
1021
- "name": "[ํ™œ์šฉ] ์ด๋ฏธ์ง€ ํŽธ์ง‘๊ธฐ",
1022
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1023
- "prompt": "์ด๋ฏธ์ง€ ์—…๋กœ๋“œ ํ›„ ํ•„ํ„ฐ์ ์šฉ, ์ž๋ฅด๊ธฐ, ํšŒ์ „ ๋“ฑ ๊ธฐ๋ณธ ํŽธ์ง‘ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ณ  ํŽธ์ง‘๋œ ์ด๋ฏธ์ง€๋ฅผ ์ €์žฅํ•˜์„ธ์š”."
1024
- },
1025
- {
1026
- "name": "[ํ™œ์šฉ] ๋ฐ์ดํ„ฐ ์ฐจํŠธ",
1027
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1028
- "prompt": "๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋ง‰๋Œ€, ์„ , ํŒŒ์ด ์ฐจํŠธ๋กœ ์‹œ๊ฐํ™”ํ•˜๊ณ , ์ฐจํŠธ ์œ ํ˜• ์ „ํ™˜๊ณผ ๋ฐ์ดํ„ฐ ๊ฐฑ์‹ ์„ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ฒ˜๋ฆฌํ•˜์„ธ์š”."
1029
- },
1030
-
1031
- # ์—”ํ„ฐํ…Œ์ธ๋จผํŠธ ์นดํ…Œ๊ณ ๋ฆฌ
1032
- {
1033
- "name": "[ํ™œ์šฉ] ํƒ€๋กœ์นด๋“œ ์šด์„ธ",
1034
- "image_url": "data:image/png;base64," + get_image_base64('tarot.png'),
1035
- "prompt": "์‚ฌ์šฉ์ž ์งˆ๋ฌธ์„ ์ž…๋ ฅ๋ฐ›๊ณ  1-5์žฅ์˜ ํƒ€๋กœ์นด๋“œ๋ฅผ ๋ฌด์ž‘์œ„๋กœ ์„ ํƒํ•˜์—ฌ ๊ฐ ์นด๋“œ์˜ ์˜๋ฏธ์™€ ํ•ด์„์„ ์ œ๊ณตํ•˜์„ธ์š”."
1036
- },
1037
- {
1038
- "name": "[ํ™œ์šฉ] AI ์š”๋ฆฌ์‚ฌ",
1039
- "image_url": "data:image/png;base64," + get_image_base64('cook.png'),
1040
- "prompt": "์„ ํƒํ•œ ์žฌ๋ฃŒ๋“ค๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ์š”๋ฆฌ๋ฅผ ์ถ”์ฒœํ•˜๊ณ  ์ƒ์„ธ ๋ ˆ์‹œํ”ผ์™€ ์กฐ๋ฆฌ๊ณผ์ •์„ ๋‹จ๊ณ„๋ณ„๋กœ ์•ˆ๋‚ดํ•˜์„ธ์š”."
1041
- },
1042
- {
1043
- "name": "[ํ™œ์šฉ] ํ–‰์šด์˜ ๋ฃฐ๋ ›",
1044
- "image_url": "data:image/png;base64," + get_image_base64('roolet.png'),
1045
- "prompt": "๋žœ๋ค ์ƒ๊ธˆ์ด ๋ฐฐ์น˜๋œ ๋ฃฐ๋ ›์„ ํšŒ์ „์‹œํ‚ค๊ณ  ๊ฒฐ๊ณผ๊ฐ’์„ ์• ๋‹ˆ๋ฉ”์ด์…˜๊ณผ ํ•จ๊ป˜ ํ‘œ์‹œํ•˜์„ธ์š”."
1046
- },
1047
-
1048
- # ์ด๋ฏธ์ง€/๋น„๋””์˜ค ์ฒ˜๋ฆฌ
1049
- {
1050
- "name": "[ํ™œ์šฉ] ์‹ค์‹œ๊ฐ„ ํ•„ํ„ฐ",
1051
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1052
- "prompt": "์›น์บ  ์˜์ƒ์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋‹ค์–‘ํ•œ ํ•„ํ„ฐํšจ๊ณผ๋ฅผ ์ ์šฉํ•˜๊ณ  ํ•„ํ„ฐ ๊ฐ•๋„๋ฅผ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ตฌํ˜„ํ•˜์„ธ์š”."
1053
- },
1054
-
1055
- # ๊ต์œก/ํ•™์Šต ๋„๊ตฌ
1056
- {
1057
- "name": "[ํ™œ์šฉ] ๋‹จ์–ด ์•”๊ธฐ ์นด๋“œ",
1058
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1059
- "prompt": "๋‹จ์–ด์žฅ์„ ์ž…๋ ฅ๋ฐ›์•„ ํ”Œ๋ž˜์‹œ์นด๋“œ ํ˜•ํƒœ๋กœ ํ•™์Šตํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ค๊ณ , ํ•™์Šต ์ง„ํ–‰๋„๋ฅผ ์ถ”์ ํ•˜์„ธ์š”."
1060
- },
1061
- {
1062
- "name": "[ํ™œ์šฉ] ์ˆ˜ํ•™ ๋ฌธ์ œ ์ƒ์„ฑ๊ธฐ",
1063
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1064
- "prompt": "์„ ํƒํ•œ ์ˆ˜ํ•™ ์ฃผ์ œ์™€ ๋‚œ์ด๋„์— ๋”ฐ๋ผ ๋ฌธ์ œ๋ฅผ ์ž๋™ ์ƒ์„ฑํ•˜๊ณ  ํ’€์ด ๊ณผ์ •์„ ๋‹จ๊ณ„๋ณ„๋กœ ์„ค๋ช…ํ•˜์„ธ์š”."
1065
- },
1066
-
1067
- # ๋ฐ์ดํ„ฐ ๋ถ„์„
1068
- {
1069
- "name": "[ํ™œ์šฉ] ๊ฐ์ • ๋ถ„์„๊ธฐ",
1070
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1071
- "prompt": "ํ…์ŠคํŠธ์˜ ๊ฐ์ •์„ ๋ถ„์„ํ•˜์—ฌ ๊ธ์ •/๋ถ€์ •/์ค‘๋ฆฝ์„ ํŒ๋‹จํ•˜๊ณ  ๊ฐ์ • ๊ฐ•๋„๋ฅผ ์ˆ˜์น˜ํ™”ํ•˜์—ฌ ์ฐจํŠธ๋กœ ํ‘œ์‹œํ•˜์„ธ์š”."
1072
- },
1073
- {
1074
- "name": "[ํ™œ์šฉ] ๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”",
1075
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1076
- "prompt": "CSV ๋ฐ์ดํ„ฐ๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด ์ž๋™์œผ๋กœ ๋ฐ์ด๏ฟฝ๏ฟฝ๏ฟฝ ์œ ํ˜•์„ ๋ถ„์„ํ•˜๊ณ  ์ ์ ˆํ•œ ์ฐจํŠธ๋กœ ์‹œ๊ฐํ™”ํ•˜์„ธ์š”."
1077
- },
1078
-
1079
- # ์˜ค๋””์˜ค ์ฒ˜๋ฆฌ
1080
- {
1081
- "name": "[ํ™œ์šฉ] ์Œ์„ฑ ์ธ์‹๊ธฐ",
1082
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1083
- "prompt": "์‹ค์‹œ๊ฐ„ ์Œ์„ฑ์„ ํ…์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ํ™”์ž์˜ ๊ฐ์ •๊ณผ ์–ด์กฐ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ํ‘œ์‹œํ•˜์„ธ์š”."
1084
- },
1085
- {
1086
- "name": "[ํ™œ์šฉ] ์Œ์•… ์žฅ๋ฅด ๋ถ„๋ฅ˜",
1087
- "image_url": "data:image/png;base64," + get_image_base64('mouse.png'),
1088
- "prompt": "์Œ์•… ํŒŒ์ผ์„ ๋ถ„์„ํ•˜์—ฌ ์žฅ๋ฅด๋ฅผ ๋ถ„๋ฅ˜ํ•˜๊ณ  ํ…œํฌ, ํ‚ค, ์•…๊ธฐ ๊ตฌ์„ฑ์„ ํŒŒ์•…ํ•˜์—ฌ ์ถœ๋ ฅํ•˜์„ธ์š”."
1089
- }
1090
- ]
1091
-
1092
- def load_best_templates():
1093
- json_data = load_json_data()[:14] # ๋ฒ ์ŠคํŠธ ํ…œํ”Œ๋ฆฟ
1094
- return create_template_html("๐Ÿ† ๊ธฐ๋ณธ ํ…œํ”Œ๋ฆฟ", json_data)
1095
-
1096
- def load_trending_templates():
1097
- json_data = load_json_data()[14:28] # ํŠธ๋ Œ๋”ฉ ํ…œํ”Œ๋ฆฟ
1098
- return create_template_html("๐Ÿ”ฅ ์‘์šฉ ํ…œํ”Œ๋ฆฟ", json_data)
1099
-
1100
- def load_new_templates():
1101
- json_data = load_json_data()[28:50] # NEW ํ…œํ”Œ๋ฆฟ
1102
- return create_template_html("โœจ ํ™œ์šฉ ํ…œํ”Œ๋ฆฟ", json_data)
1103
-
1104
- def create_template_html(title, items):
1105
- html_content = """
1106
- <style>
1107
- .prompt-grid {
1108
- display: grid;
1109
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
1110
- gap: 20px;
1111
- padding: 20px;
1112
- }
1113
- .prompt-card {
1114
- background: white;
1115
- border: 1px solid #eee;
1116
- border-radius: 8px;
1117
- padding: 15px;
1118
- cursor: pointer;
1119
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
1120
- }
1121
- .prompt-card:hover {
1122
- transform: translateY(-2px);
1123
- transition: transform 0.2s;
1124
- }
1125
- .card-image {
1126
- width: 100%;
1127
- height: 180px;
1128
- object-fit: cover;
1129
- border-radius: 4px;
1130
- margin-bottom: 10px;
1131
- }
1132
- .card-name {
1133
- font-weight: bold;
1134
- margin-bottom: 8px;
1135
- font-size: 16px;
1136
- color: #333;
1137
- }
1138
- .card-prompt {
1139
- font-size: 11px;
1140
- line-height: 1.4;
1141
- color: #666;
1142
- display: -webkit-box;
1143
- -webkit-line-clamp: 6;
1144
- -webkit-box-orient: vertical;
1145
- overflow: hidden;
1146
- height: 90px;
1147
- background-color: #f8f9fa;
1148
- padding: 8px;
1149
- border-radius: 4px;
1150
- }
1151
- .template-section {
1152
- display: none;
1153
- }
1154
- .template-section.active {
1155
- display: block;
1156
- }
1157
- </style>
1158
- <div class="template-nav">
1159
- <button class="template-btn" onclick="showTemplate('best')">๐Ÿ† ๋ฒ ์ŠคํŠธ</button>
1160
- <button class="template-btn" onclick="showTemplate('trending')">๐Ÿ”ฅ ํŠธ๋ Œ๋”ฉ</button>
1161
- <button class="template-btn" onclick="showTemplate('new')">โœจ NEW</button>
1162
- </div>
1163
- <script>
1164
- function copyToInput(card) {
1165
- const prompt = card.dataset.prompt;
1166
- const textarea = document.querySelector('.ant-input-textarea-large textarea');
1167
- if (textarea) {
1168
- textarea.value = prompt;
1169
- textarea.dispatchEvent(new Event('input', { bubbles: true }));
1170
- document.querySelector('.session-drawer .close-btn').click();
1171
- }
1172
- }
1173
-
1174
- function showTemplate(type) {
1175
- document.querySelectorAll('.template-section').forEach(section => {
1176
- section.style.display = 'none';
1177
- });
1178
- document.querySelectorAll('.template-btn').forEach(btn => {
1179
- btn.classList.remove('active');
1180
- });
1181
- document.getElementById(type + '-templates').style.display = 'block';
1182
- event.target.classList.add('active');
1183
- }
1184
- document.addEventListener('DOMContentLoaded', function() {
1185
- showTemplate('best');
1186
- document.querySelector('.template-btn').classList.add('active');
1187
- });
1188
- </script>
1189
- """
1190
-
1191
- # ํƒญ๋ณ„ ํ…œํ”Œ๋ฆฟ ๋ชฉ๋ก
1192
- html_content += f'<div id="best-templates" class="template-section">'
1193
- html_content += '<div class="prompt-grid">'
1194
- for item in items:
1195
- html_content += f"""
1196
- <div class="prompt-card" onclick="copyToInput(this)" data-prompt="{html.escape(item.get('prompt', ''))}">
1197
- <img src="{item.get('image_url', '')}" class="card-image" loading="lazy" alt="{html.escape(item.get('name', ''))}">
1198
- <div class="card-name">{html.escape(item.get('name', ''))}</div>
1199
- <div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
1200
- </div>
1201
- """
1202
- html_content += '</div></div>'
1203
- return gr.HTML(value=html_content)
1204
-
1205
- def load_session_history(template_type="best"):
1206
- global TEMPLATE_CACHE
1207
-
1208
- try:
1209
- json_data = load_json_data()
1210
-
1211
- # ๋ฐ์ดํ„ฐ๋ฅผ ์„ธ ์„น์…˜์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ
1212
- templates = {
1213
- "best": json_data[:12], # ๋ฒ ์ŠคํŠธ ํ…œํ”Œ๋ฆฟ
1214
- "trending": json_data[12:24], # ํŠธ๋ Œ๋”ฉ ํ…œํ”Œ๋ฆฟ
1215
- "new": json_data[24:44] # NEW ํ…œํ”Œ๋ฆฟ
1216
- }
1217
-
1218
- titles = {
1219
- "best": "๐Ÿ† ๊ธฐ๋ณธ ํ…œํ”Œ๋ฆฟ",
1220
- "trending": "๐Ÿ”ฅ ์‘์šฉ ํ…œํ”Œ๋ฆฟ",
1221
- "new": "โœจ ํ™œ์šฉ ํ…œํ”Œ๋ฆฟ"
1222
- }
1223
-
1224
- html_content = """
1225
- <style>
1226
- .template-nav {
1227
- display: flex;
1228
- gap: 10px;
1229
- margin: 20px;
1230
- position: sticky;
1231
- top: 0;
1232
- background: white;
1233
- z-index: 100;
1234
- padding: 10px 0;
1235
- border-bottom: 1px solid #eee;
1236
- }
1237
- .template-btn {
1238
- padding: 8px 16px;
1239
- border: 1px solid #1890ff;
1240
- border-radius: 4px;
1241
- cursor: pointer;
1242
- background: white;
1243
- color: #1890ff;
1244
- font-weight: bold;
1245
- transition: all 0.3s;
1246
- }
1247
- .template-btn:hover {
1248
- background: #1890ff;
1249
- color: white;
1250
- }
1251
- .template-btn.active {
1252
- background: #1890ff;
1253
- color: white;
1254
- }
1255
- .prompt-grid {
1256
- display: grid;
1257
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
1258
- gap: 20px;
1259
- padding: 20px;
1260
- }
1261
- .prompt-card {
1262
- background: white;
1263
- border: 1px solid #eee;
1264
- border-radius: 8px;
1265
- padding: 15px;
1266
- cursor: pointer;
1267
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
1268
- }
1269
- .prompt-card:hover {
1270
- transform: translateY(-2px);
1271
- transition: transform 0.2s;
1272
- }
1273
- .card-image {
1274
- width: 100%;
1275
- height: 180px;
1276
- object-fit: cover;
1277
- border-radius: 4px;
1278
- margin-bottom: 10px;
1279
- }
1280
- .card-name {
1281
- font-weight: bold;
1282
- margin-bottom: 8px;
1283
- font-size: 16px;
1284
- color: #333;
1285
- }
1286
- .card-prompt {
1287
- font-size: 11px;
1288
- line-height: 1.4;
1289
- color: #666;
1290
- display: -webkit-box;
1291
- -webkit-line-clamp: 6;
1292
- -webkit-box-orient: vertical;
1293
- overflow: hidden;
1294
- height: 90px;
1295
- background-color: #f8f9fa;
1296
- padding: 8px;
1297
- border-radius: 4px;
1298
- }
1299
- .template-section {
1300
- display: none;
1301
- }
1302
- .template-section.active {
1303
- display: block;
1304
- }
1305
- </style>
1306
- <div class="template-nav">
1307
- <button class="template-btn" onclick="showTemplate('best')">๐Ÿ† ๋ฒ ์ŠคํŠธ</button>
1308
- <button class="template-btn" onclick="showTemplate('trending')">๐Ÿ”ฅ ํŠธ๋ Œ๋”ฉ</button>
1309
- <button class="template-btn" onclick="showTemplate('new')">โœจ NEW</button>
1310
- </div>
1311
- """
1312
-
1313
- # ๊ฐ ์„น์…˜์˜ ํ…œํ”Œ๋ฆฟ ์ƒ์„ฑ
1314
- for section, items in templates.items():
1315
- html_content += f"""
1316
- <div class="template-section" id="{section}-templates">
1317
- <div class="prompt-grid">
1318
- """
1319
- for item in items:
1320
- html_content += f"""
1321
- <div class="prompt-card" onclick="copyToInput(this)" data-prompt="{html.escape(item.get('prompt', ''))}">
1322
- <img src="{item.get('image_url', '')}" class="card-image" loading="lazy" alt="{html.escape(item.get('name', ''))}">
1323
- <div class="card-name">{html.escape(item.get('name', ''))}</div>
1324
- <div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
1325
- </div>
1326
- """
1327
- html_content += "</div></div>"
1328
-
1329
- html_content += """
1330
- <script>
1331
- function copyToInput(card) {
1332
- const prompt = card.dataset.prompt;
1333
- const textarea = document.querySelector('.ant-input-textarea-large textarea');
1334
- if (textarea) {
1335
- textarea.value = prompt;
1336
- textarea.dispatchEvent(new Event('input', { bubbles: true }));
1337
- document.querySelector('.session-drawer .close-btn').click();
1338
- }
1339
- }
1340
-
1341
- function showTemplate(type) {
1342
- // ๋ชจ๋“  ์„น์…˜ ์ˆจ๊ธฐ๊ธฐ
1343
- document.querySelectorAll('.template-section').forEach(section => {
1344
- section.style.display = 'none';
1345
- });
1346
- // ๋ชจ๋“  ๋ฒ„ํŠผ ๋น„ํ™œ์„ฑํ™”
1347
- document.querySelectorAll('.template-btn').forEach(btn => {
1348
- btn.classList.remove('active');
1349
- });
1350
-
1351
- // ์„ ํƒ๋œ ์„น์…˜ ๋ณด์ด๊ธฐ
1352
- document.getElementById(type + '-templates').style.display = 'block';
1353
- // ์„ ํƒ๋œ ๋ฒ„ํŠผ ํ™œ์„ฑํ™”
1354
- event.target.classList.add('active');
1355
- }
1356
-
1357
- // ์ดˆ๊ธฐ ๋กœ๋“œ์‹œ ๋ฒ ์ŠคํŠธ ํ…œํ”Œ๋ฆฟ ํ‘œ์‹œ
1358
- document.addEventListener('DOMContentLoaded', function() {
1359
- showTemplate('best');
1360
- document.querySelector('.template-btn').classList.add('active');
1361
- });
1362
- </script>
1363
- """
1364
-
1365
- return gr.HTML(value=html_content)
1366
-
1367
- except Exception as e:
1368
- print(f"Error in load_session_history: {str(e)}")
1369
- return gr.HTML("Error loading templates")
1370
-
1371
- # ๋ฐฐํฌ ๊ด€๋ จ ํ•จ์ˆ˜ ์ถ”๊ฐ€
1372
- def generate_space_name():
1373
- """6์ž๋ฆฌ ๋žœ๋ค ์˜๋ฌธ ์ด๋ฆ„ ์ƒ์„ฑ"""
1374
- letters = string.ascii_lowercase
1375
- return ''.join(random.choice(letters) for i in range(6))
1376
 
1377
- def deploy_to_huggingface(code: str):
1378
- try:
1379
- # 1) ๊ธฐ๋ณธ ๊ฒ€์ฆ
1380
- token = os.getenv("HF_TOKEN")
1381
- if not token:
1382
- return "HuggingFace ํ† ํฐ์ด ์„ค์ •๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
1383
-
1384
- # 2) Space ์ƒ์„ฑ ์ค€๋น„
1385
- api = HfApi(token=token)
1386
- space_name = generate_space_name()
1387
- username = api.whoami()['name']
1388
- repo_id = f"{username}/{space_name}"
1389
-
1390
- # 3) Space ์ƒ์„ฑ (private๋กœ ์„ค์ •)
1391
- try:
1392
- create_repo(
1393
- repo_id,
1394
- repo_type="space",
1395
- space_sdk="gradio",
1396
- token=token,
1397
- private=True
1398
- )
1399
- except Exception as e:
1400
- raise e
1401
-
1402
- # 4) ์ฝ”๋“œ ์ •๋ฆฌ
1403
- code = code.replace("```python", "").replace("```", "").strip()
1404
-
1405
- # 5) ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฝ”๋“œ ์ƒ์„ฑ
1406
- if "demo.launch()" not in code:
1407
- full_app_code = code + "\n\nif __name__ == '__main__':\n demo.launch()"
1408
- else:
1409
- full_app_code = code
1410
-
1411
- # 6) ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์—…๋กœ๋“œ
1412
- with open("app.py", "w", encoding="utf-8") as f:
1413
- f.write(full_app_code)
1414
-
1415
- api.upload_file(
1416
- path_or_fileobj="app.py",
1417
- path_in_repo="app.py",
1418
- repo_id=repo_id,
1419
- repo_type="space"
1420
- )
1421
-
1422
- # 7) requirements.txt ์ƒ์„ฑ ๋ฐ ์—…๋กœ๋“œ
1423
- analysis_result = analyze_code(code)
1424
- requirements = ""
1425
- # HTML์—์„œ requirements.txt ์„น์…˜ ์ฐพ๊ธฐ
1426
- if "<h3>๐Ÿ“‹ Requirements.txt</h3>" in analysis_result:
1427
- start_idx = analysis_result.find("<pre>") + 5
1428
- end_idx = analysis_result.find("</pre>")
1429
- if start_idx > 4 and end_idx > 0:
1430
- requirements = analysis_result[start_idx:end_idx].strip()
1431
-
1432
- # ๊ธฐ๋ณธ requirements ์„ค์ •
1433
- default_requirements = [
1434
- 'gradio==5.6.0',
1435
- 'huggingface_hub',
1436
- 'transformers',
1437
- 'torch',
1438
- 'torchvision',
1439
- 'diffusers',
1440
- 'accelerate',
1441
- 'safetensors',
1442
- 'scipy',
1443
- 'pillow',
1444
- 'numpy'
1445
- ]
1446
-
1447
- # ๊ธฐ์กด requirements๊ฐ€ ์žˆ์œผ๋ฉด ํŒŒ์‹ฑํ•˜์—ฌ ์ค‘๋ณต ์ œ๊ฑฐ
1448
- existing_requirements = set()
1449
- if requirements:
1450
- existing_requirements = {line.split('==')[0] if '==' in line else line
1451
- for line in requirements.split('\n') if line.strip()}
1452
-
1453
- # ์ตœ์ข… requirements ์ƒ์„ฑ
1454
- final_requirements = set()
1455
-
1456
- # ๊ธฐ์กด requirements ์ถ”๊ฐ€ (๋ฒ„์ „ ์ •๋ณด ์œ ์ง€)
1457
- if requirements:
1458
- for req in requirements.split('\n'):
1459
- if req.strip():
1460
- final_requirements.add(req.strip())
1461
-
1462
- # ๊ธฐ๋ณธ requirements ์ถ”๊ฐ€ (์—†๋Š” ๊ฒƒ๋งŒ)
1463
- for req in default_requirements:
1464
- pkg_name = req.split('==')[0] if '==' in req else req
1465
- if pkg_name not in {r.split('==')[0] if '==' in r else r for r in final_requirements}:
1466
- final_requirements.add(req)
1467
-
1468
- # requirements.txt ์ž‘์„ฑ
1469
- with open("requirements.txt", "w") as f:
1470
- f.write('\n'.join(sorted(final_requirements)))
1471
-
1472
- api.upload_file(
1473
- path_or_fileobj="requirements.txt",
1474
- path_in_repo="requirements.txt",
1475
- repo_id=repo_id,
1476
- repo_type="space"
1477
- )
1478
-
1479
- # 8) ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
1480
- space_url = f"https://huggingface.co/spaces/{username}/{space_name}"
1481
- return f'๋ฐฐํฌ ์™„๋ฃŒ! Private Space๋กœ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. <a href="{space_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์—ฌ๊ธฐ๋ฅผ ํด๋ฆญํ•˜์—ฌ Space ์—ด๊ธฐ</a>'
1482
- except Exception as e:
1483
- return f"๋ฐฐํฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
1484
-
1485
  # Demo ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
1486
  demo_instance = Demo()
1487
 
@@ -1500,60 +609,42 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
1500
  with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
1501
  history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
1502
 
1503
- with antd.Drawer(
1504
- open=False,
1505
- title="Templates",
1506
- placement="right",
1507
- width="900px",
1508
- elem_classes="session-drawer"
1509
- ) as session_drawer:
1510
- with antd.Flex(vertical=True, gap="middle"):
1511
- gr.Markdown("### Available Templates")
1512
- session_history = gr.HTML(
1513
- elem_classes="session-history"
1514
- )
1515
- close_btn = antd.Button(
1516
- "Close",
1517
- type="default",
1518
- elem_classes="close-btn"
1519
- )
1520
-
1521
  # ๋ฉ”์ธ ์ปจํ…์ธ ๋ฅผ ์œ„ํ•œ Row
1522
  with antd.Row(gutter=[32, 12]) as layout:
1523
  # ์ขŒ์ธก ํŒจ๋„
1524
- with antd.Col(span=24, md=8):
1525
  with antd.Flex(vertical=True, gap="middle", wrap=True):
1526
  header = gr.HTML(f"""
1527
  <div class="left_header">
1528
  <img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
1529
  <h1 style="font-size: 18px;">๊ณ ์–‘์ด๋„ ๋ฐœ๋กœ ์ฝ”๋”ฉํ•˜๋Š” 'MOUSE-II'</h2>
1530
- <h1 style="font-size: 10px;">ํ…œํ”Œ๋ฆฟ์˜ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋ณต์‚ฌํ•˜๊ฑฐ๋‚˜ ์›ํ•˜๋Š” ๋‚ด์šฉ์„ ํ”„๋กฌํ”„ํŠธ์— ์ž…๋ ฅํ•˜๊ณ  Boost ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ํ”„๋กฌํ”„ํŠธ ์ฆ๊ฐ•์ด ๋จ. -> ๋ฐฐํฌํ•˜๊ธฐ ํด๋ฆญํ•˜๋ฉด ํ—ˆ๊น…ํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์›น์„œ๋น„์Šค๊ฐ€ ๋ฐฐํฌ๋ฉ๋‹ˆ๋‹ค. ๋ฌธ์˜: [email protected] </h2>
1531
  </div>
1532
  """)
1533
 
1534
  input = antd.InputTextarea(
1535
  size="large",
1536
  allow_clear=True,
1537
- placeholder=random.choice(DEMO_LIST)['description']
 
 
 
 
 
 
1538
  )
1539
 
1540
  with antd.Flex(gap="small", justify="space-between"):
1541
  btn = antd.Button("Send", type="primary", size="large")
1542
  boost_btn = antd.Button("Boost", type="default", size="large")
1543
- execute_btn = antd.Button("Code์‹คํ–‰", type="default", size="large")
1544
- deploy_btn = antd.Button("๋ฐฐํฌ", type="default", size="large")
1545
  clear_btn = antd.Button("ํด๋ฆฌ์–ด", type="default", size="large")
1546
 
1547
- deploy_result = gr.HTML(label="๋ฐฐํฌ ๊ฒฐ๊ณผ")
1548
-
1549
- with antd.Col(span=24, md=16):
1550
  with ms.Div(elem_classes="right_panel"):
1551
  with antd.Flex(gap="small", elem_classes="setting-buttons"):
1552
  codeBtn = antd.Button("๐Ÿง‘โ€๐Ÿ’ป ์ฝ”๋“œ ๋ณด๊ธฐ", type="default")
1553
  historyBtn = antd.Button("๐Ÿ“œ ํžˆ์Šคํ† ๋ฆฌ", type="default")
1554
- best_btn = antd.Button("๐Ÿ† ๋ฒ ์ŠคํŠธ ํ…œํ”Œ๋ฆฟ", type="default")
1555
- trending_btn = antd.Button("๐Ÿ”ฅ ํŠธ๋ Œ๋”ฉ ํ…œํ”Œ๋ฆฟ", type="default")
1556
- new_btn = antd.Button("โœจ NEW ํ…œํ”Œ๋ฆฟ", type="default")
1557
 
1558
  gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
1559
 
@@ -1562,14 +653,23 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
1562
  empty = antd.Empty(description="empty input", elem_classes="right_content")
1563
  with antd.Tabs.Item(key="loading"):
1564
  loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
1565
- with antd.Tabs.Item(key="render"):
1566
- sandbox = gr.HTML(elem_classes="html_content")
 
 
 
 
 
1567
 
1568
  # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์—ฐ๊ฒฐ
1569
- execute_btn.click(
1570
- fn=execute_code,
1571
- inputs=[input],
1572
- outputs=[sandbox, state_tab]
 
 
 
 
1573
  )
1574
 
1575
  boost_btn.click(
@@ -1578,12 +678,6 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
1578
  outputs=[input, state_tab]
1579
  )
1580
 
1581
- btn.click(
1582
- demo_instance.generation_code,
1583
- inputs=[input, setting, history],
1584
- outputs=[code_output, history, sandbox, state_tab, code_drawer]
1585
- )
1586
-
1587
  clear_btn.click(
1588
  demo_instance.clear_history,
1589
  inputs=[],
@@ -1591,8 +685,8 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
1591
  )
1592
 
1593
  deploy_btn.click(
1594
- fn=lambda code: deploy_to_huggingface(remove_code_block(code)) if code else "์ฝ”๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",
1595
- inputs=[code_output],
1596
  outputs=[deploy_result]
1597
  )
1598
 
@@ -1620,38 +714,10 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
1620
  outputs=[history_drawer]
1621
  )
1622
 
1623
- best_btn.click(
1624
- fn=lambda: (gr.update(open=True), load_best_templates()),
1625
- outputs=[session_drawer, session_history],
1626
- queue=False
1627
- )
1628
-
1629
- trending_btn.click(
1630
- fn=lambda: (gr.update(open=True), load_trending_templates()),
1631
- outputs=[session_drawer, session_history],
1632
- queue=False
1633
- )
1634
-
1635
- new_btn.click(
1636
- fn=lambda: (gr.update(open=True), load_new_templates()),
1637
- outputs=[session_drawer, session_history],
1638
- queue=False
1639
- )
1640
-
1641
- session_drawer.close(
1642
- lambda: (gr.update(open=False), gr.HTML("")),
1643
- outputs=[session_drawer, session_history]
1644
- )
1645
-
1646
- close_btn.click(
1647
- lambda: (gr.update(open=False), gr.HTML("")),
1648
- outputs=[session_drawer, session_history]
1649
- )
1650
-
1651
  if __name__ == "__main__":
1652
  try:
1653
  demo_instance = Demo()
1654
  demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
1655
  except Exception as e:
1656
  print(f"Initialization error: {e}")
1657
- raise
 
144
  'pipes', 'resource', 'nis', 'syslog', 'optparse', 'imp', 'posix', '_thread',
145
  'builtins', 'traceback', 'gc', 'inspect', 'site', 'user', 'distutils', 'test',
146
  'unittest', 'venv', 'code', 'codeop', 'pdb', 'profile', 'pstats', 'timeit',
147
+ 'trace', 'tracemalloc', 'sched', 'secrets', 'mimetypes'
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
 
150
  # Import to Package Name Mapping Dictionary
 
161
  'MySQLdb': 'mysqlclient',
162
  'psycopg2': 'psycopg2-binary',
163
  'magic': 'python-magic',
164
+ 'Image': 'pillow'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
 
167
 
 
270
 
271
  return "\n".join(analysis)
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  async def try_claude_api(system_message, claude_messages, timeout=15):
274
  try:
275
  start_time = time.time()
 
316
  print(f"OpenAI API error: {str(e)}")
317
  raise e
318
 
319
+ def history_render(history: History):
320
+ return gr.update(open=True), history
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
+ def remove_code_block(text):
323
+ text = re.sub(r'```[python|html]?\n', '', text)
324
+ text = re.sub(r'\n```', '', text)
325
+
326
+ lines = text.split('\n')
327
+ filtered_lines = []
328
+ seen_imports = set()
329
+
330
+ for line in lines:
331
+ if not line.strip():
332
+ continue
333
+
334
+ if line.startswith('import ') or line.startswith('from '):
335
+ import_key = line.split('#')[0].strip()
336
+ if import_key in seen_imports:
337
+ continue
338
+ seen_imports.add(import_key)
339
+
340
+ if 'if __name__ == "__main__":' in line:
341
+ continue
342
+ if 'demo.launch()' in line:
343
+ continue
344
+
345
+ filtered_lines.append(line)
346
 
347
+ return '\n'.join(filtered_lines)
 
 
 
 
 
 
 
 
 
348
 
349
  def boost_prompt(prompt: str) -> str:
350
  if not prompt:
 
408
  print(f"Boost ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
409
  return prompt, gr.update(active_key="empty")
410
 
411
+ # ๋ฐฐํฌ ๊ด€๋ จ ํ•จ์ˆ˜ ์ถ”๊ฐ€
412
+ def generate_space_name():
413
+ """6์ž๋ฆฌ ๋žœ๋ค ์˜๋ฌธ ์ด๋ฆ„ ์ƒ์„ฑ"""
414
+ letters = string.ascii_lowercase
415
+ return ''.join(random.choice(letters) for i in range(6))
416
+
417
+ def deploy_to_huggingface(code: str, token: str):
418
  try:
419
+ # 1) ๊ธฐ๋ณธ ๊ฒ€์ฆ
420
+ if not token:
421
+ return "HuggingFace ํ† ํฐ์ด ์ž…๋ ฅ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
422
+
423
+ # 2) Space ์ƒ์„ฑ ์ค€๋น„
424
+ api = HfApi(token=token)
425
+ space_name = generate_space_name()
426
+ username = api.whoami()['name']
427
+ repo_id = f"{username}/{space_name}"
428
+
429
+ # 3) Space ์ƒ์„ฑ (private๋กœ ์„ค์ •)
430
+ try:
431
+ create_repo(
432
+ repo_id,
433
+ repo_type="space",
434
+ space_sdk="gradio",
435
+ token=token,
436
+ private=True
437
+ )
438
+ except Exception as e:
439
+ raise e
440
+
441
+ # 4) ์ฝ”๋“œ ์ •๋ฆฌ
442
+ code = code.replace("```python", "").replace("```", "").strip()
443
+
444
+ # 5) ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฝ”๋“œ ์ƒ์„ฑ
445
+ if "demo.launch()" not in code:
446
+ full_app_code = code + "\n\nif __name__ == '__main__':\n demo.launch()"
447
  else:
448
+ full_app_code = code
449
 
450
+ # 6) ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์—…๋กœ๋“œ
451
+ with open("app.py", "w", encoding="utf-8") as f:
452
+ f.write(full_app_code)
453
+
454
+ api.upload_file(
455
+ path_or_fileobj="app.py",
456
+ path_in_repo="app.py",
457
+ repo_id=repo_id,
458
+ repo_type="space"
459
+ )
460
+
461
+ # 7) requirements.txt ์ƒ์„ฑ ๋ฐ ์—…๋กœ๋“œ
462
+ analysis_result = analyze_code(code)
463
+ requirements = ""
464
+ # HTML์—์„œ requirements.txt ์„น์…˜ ์ฐพ๊ธฐ
465
+ if "<h3>๐Ÿ“‹ Requirements.txt</h3>" in analysis_result:
466
+ start_idx = analysis_result.find("<pre>") + 5
467
+ end_idx = analysis_result.find("</pre>")
468
+ if start_idx > 4 and end_idx > 0:
469
+ requirements = analysis_result[start_idx:end_idx].strip()
470
+
471
+ # requirements.txt ์ž‘์„ฑ
472
+ with open("requirements.txt", "w") as f:
473
+ if requirements:
474
+ f.write(requirements)
475
+ else:
476
+ f.write("gradio==5.6.0\n")
477
 
478
+ api.upload_file(
479
+ path_or_fileobj="requirements.txt",
480
+ path_in_repo="requirements.txt",
481
+ repo_id=repo_id,
482
+ repo_type="space"
483
+ )
484
+
485
+ # 8) ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
486
+ space_url = f"https://huggingface.co/spaces/{username}/{space_name}"
487
+ return f'๋ฐฐํฌ ์™„๋ฃŒ! Private Space๋กœ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. <a href="{space_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์—ฌ๊ธฐ๋ฅผ ํด๋ฆญํ•˜์—ฌ Space ์—ด๊ธฐ</a>'
488
+ except Exception as e:
489
+ return f"๋ฐฐํฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  class Demo:
492
  def __init__(self):
493
  pass
 
520
  yield [
521
  "Generating code...",
522
  _history,
 
523
  gr.update(active_key="loading"),
524
  gr.update(open=True)
525
  ]
 
533
  yield [
534
  code,
535
  _history,
 
536
  gr.update(active_key="loading"),
537
  gr.update(open=True)
538
  ]
 
548
  yield [
549
  code,
550
  _history,
 
551
  gr.update(active_key="loading"),
552
  gr.update(open=True)
553
  ]
 
565
  yield [
566
  collected_content,
567
  _history,
568
+ gr.update(active_key="empty"),
 
569
  gr.update(open=True)
570
  ]
571
  else:
 
582
  # theme = gr.themes.Soft()
583
  theme='earneleh/paris'
584
 
585
+ # ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
586
+ example_prompts = [
587
+ "๋งŒ๋…„๋‹ฌ๋ ฅ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ๋…„๋„์™€ ์›”์„ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ์›”์˜ ๋‹ฌ๋ ฅ์ด ํ‘œ์‹œ๋˜๋Š” ์•ฑ์ž…๋‹ˆ๋‹ค.",
588
+ "BMI ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ํ‚ค์™€ ๋ชธ๋ฌด๊ฒŒ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด BMI ์ง€์ˆ˜์™€ ๋น„๋งŒ๋„๋ฅผ ๊ณ„์‚ฐํ•ด์ฃผ๋Š” ์•ฑ์ž…๋‹ˆ๋‹ค.",
589
+ "๊ฐ„๋‹จํ•œ ๋ฉ”๋ชจ์žฅ์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ๋ฉ”๋ชจ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์ €์žฅํ•˜๋ฉด ๋ชฉ๋ก์— ํ‘œ์‹œ๋˜๋ฉฐ, ์ €์žฅ๋œ ๋ฉ”๋ชจ๋ฅผ ์„ ํƒํ•˜์—ฌ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.",
590
+ "๋‹จ์œ„ ๋ณ€ํ™˜๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. ๊ธธ์ด(m, cm, km ๋“ฑ), ๋ฌด๊ฒŒ(kg, g ๋“ฑ), ์˜จ๋„(์„ญ์”จ, ํ™”์”จ) ๋“ฑ์„ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๋Š” ์•ฑ์ž…๋‹ˆ๋‹ค.",
591
+ "ํฌ๋ชจ๋„๋กœ ํƒ€์ด๋จธ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”. 25๋ถ„ ์ง‘์ค‘, 5๋ถ„ ํœด์‹์„ ๋ฐ˜๋ณตํ•˜๋Š” ํƒ€์ด๋จธ๋กœ, ์‚ฌ์ดํด ํšŸ์ˆ˜๋„ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค."
592
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
594
  # Demo ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
595
  demo_instance = Demo()
596
 
 
609
  with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
610
  history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
611
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  # ๋ฉ”์ธ ์ปจํ…์ธ ๋ฅผ ์œ„ํ•œ Row
613
  with antd.Row(gutter=[32, 12]) as layout:
614
  # ์ขŒ์ธก ํŒจ๋„
615
+ with antd.Col(span=24, md=12):
616
  with antd.Flex(vertical=True, gap="middle", wrap=True):
617
  header = gr.HTML(f"""
618
  <div class="left_header">
619
  <img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
620
  <h1 style="font-size: 18px;">๊ณ ์–‘์ด๋„ ๋ฐœ๋กœ ์ฝ”๋”ฉํ•˜๋Š” 'MOUSE-II'</h2>
621
+ <h1 style="font-size: 10px;">ํ”„๋กฌํ”„ํŠธ์— ์›ํ•˜๋Š” ๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜๊ณ  Boost ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ํ”„๋กฌํ”„ํŠธ ์ฆ๊ฐ•์ด ๋จ. -> ๋ฐฐํฌํ•˜๊ธฐ ํด๋ฆญํ•˜๋ฉด ํ—ˆ๊น…ํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์›น์„œ๋น„์Šค๊ฐ€ ๋ฐฐํฌ๋ฉ๋‹ˆ๋‹ค. ๋ฌธ์˜: [email protected] </h2>
622
  </div>
623
  """)
624
 
625
  input = antd.InputTextarea(
626
  size="large",
627
  allow_clear=True,
628
+ placeholder=random.choice(DEMO_LIST)['description'],
629
+ height=400
630
+ )
631
+
632
+ gr.Examples(
633
+ examples=example_prompts,
634
+ inputs=input
635
  )
636
 
637
  with antd.Flex(gap="small", justify="space-between"):
638
  btn = antd.Button("Send", type="primary", size="large")
639
  boost_btn = antd.Button("Boost", type="default", size="large")
 
 
640
  clear_btn = antd.Button("ํด๋ฆฌ์–ด", type="default", size="large")
641
 
642
+ # ์šฐ์ธก ํŒจ๋„
643
+ with antd.Col(span=24, md=12):
 
644
  with ms.Div(elem_classes="right_panel"):
645
  with antd.Flex(gap="small", elem_classes="setting-buttons"):
646
  codeBtn = antd.Button("๐Ÿง‘โ€๐Ÿ’ป ์ฝ”๋“œ ๋ณด๊ธฐ", type="default")
647
  historyBtn = antd.Button("๐Ÿ“œ ํžˆ์Šคํ† ๋ฆฌ", type="default")
 
 
 
648
 
649
  gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
650
 
 
653
  empty = antd.Empty(description="empty input", elem_classes="right_content")
654
  with antd.Tabs.Item(key="loading"):
655
  loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
656
+
657
+ code_display = gr.Code(language="python", height=400)
658
+
659
+ gr.HTML("<h3>๋ฐฐํฌ ์„ค์ •</h3>")
660
+ hf_token = gr.Textbox(label="Hugging Face ํ† ํฐ", type="password", placeholder="hf_...")
661
+ deploy_btn = antd.Button("๋ฐฐํฌํ•˜๊ธฐ", type="primary", size="large")
662
+ deploy_result = gr.HTML(label="๋ฐฐํฌ ๊ฒฐ๊ณผ")
663
 
664
  # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์—ฐ๊ฒฐ
665
+ btn.click(
666
+ demo_instance.generation_code,
667
+ inputs=[input, setting, history],
668
+ outputs=[code_output, history, state_tab, code_drawer]
669
+ ).then(
670
+ lambda code: code,
671
+ inputs=[code_output],
672
+ outputs=[code_display]
673
  )
674
 
675
  boost_btn.click(
 
678
  outputs=[input, state_tab]
679
  )
680
 
 
 
 
 
 
 
681
  clear_btn.click(
682
  demo_instance.clear_history,
683
  inputs=[],
 
685
  )
686
 
687
  deploy_btn.click(
688
+ fn=lambda code, token: deploy_to_huggingface(remove_code_block(code), token) if code else "์ฝ”๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",
689
+ inputs=[code_output, hf_token],
690
  outputs=[deploy_result]
691
  )
692
 
 
714
  outputs=[history_drawer]
715
  )
716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  if __name__ == "__main__":
718
  try:
719
  demo_instance = Demo()
720
  demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
721
  except Exception as e:
722
  print(f"Initialization error: {e}")
723
+ raise