Update app.py
Browse files
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'
|
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
|
469 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
-
|
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 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
|
|
|
|
|
|
600 |
try:
|
601 |
-
|
602 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
else:
|
604 |
-
|
605 |
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
|
634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
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 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
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=
|
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;"
|
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 |
-
|
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 |
-
|
1566 |
-
|
|
|
|
|
|
|
|
|
|
|
1567 |
|
1568 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ฐ๊ฒฐ
|
1569 |
-
|
1570 |
-
|
1571 |
-
inputs=[input],
|
1572 |
-
outputs=[
|
|
|
|
|
|
|
|
|
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
|