Spaces:
Sleeping
Sleeping
Delete mouse.py
Browse files
mouse.py
DELETED
@@ -1,1123 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import re
|
3 |
-
import random
|
4 |
-
from http import HTTPStatus
|
5 |
-
from typing import Dict, List, Optional, Tuple
|
6 |
-
import base64
|
7 |
-
import anthropic
|
8 |
-
import openai
|
9 |
-
import asyncio
|
10 |
-
import time
|
11 |
-
from functools import partial
|
12 |
-
import json
|
13 |
-
import gradio as gr
|
14 |
-
import modelscope_studio.components.base as ms
|
15 |
-
import modelscope_studio.components.legacy as legacy
|
16 |
-
import modelscope_studio.components.antd as antd
|
17 |
-
|
18 |
-
import html
|
19 |
-
import urllib.parse
|
20 |
-
from huggingface_hub import HfApi, create_repo
|
21 |
-
import string
|
22 |
-
import random
|
23 |
-
import requests # ์๋จ import ๊ตฌ๋ฌธ์ ์ถ๊ฐ
|
24 |
-
|
25 |
-
__all__ = ['Demo', 'demo', 'SystemPrompt', 'mouse_interface', 'history_to_messages', 'messages_to_history']
|
26 |
-
|
27 |
-
# SystemPrompt ๋ถ๋ถ์ ์ง์ ์ ์
|
28 |
-
SystemPrompt = """๋์ ์ด๋ฆ์ 'MOUSE'์ด๋ค. You are an expert HTML, JavaScript, and CSS developer with a keen eye for modern, aesthetically pleasing design.
|
29 |
-
Your task is to create a stunning, contemporary, and highly functional website based on the user's request using pure HTML, JavaScript, and CSS.
|
30 |
-
This code will be rendered directly in the browser.
|
31 |
-
General guidelines:
|
32 |
-
- Create clean, modern interfaces using vanilla JavaScript and CSS
|
33 |
-
- Use HTML5 semantic elements for better structure
|
34 |
-
- Implement CSS3 features for animations and styling
|
35 |
-
- Utilize modern JavaScript (ES6+) features
|
36 |
-
- Create responsive designs using CSS media queries
|
37 |
-
- You can use CDN-hosted libraries like:
|
38 |
-
* jQuery
|
39 |
-
* Bootstrap
|
40 |
-
* Chart.js
|
41 |
-
* Three.js
|
42 |
-
* D3.js
|
43 |
-
- For icons, use Unicode symbols or create simple SVG icons
|
44 |
-
- Use CSS animations and transitions for smooth effects
|
45 |
-
- Implement proper event handling with JavaScript
|
46 |
-
- Create mock data instead of making API calls
|
47 |
-
- Ensure cross-browser compatibility
|
48 |
-
- Focus on performance and smooth animations
|
49 |
-
Focus on creating a visually striking and user-friendly interface that aligns with current web design trends. Pay special attention to:
|
50 |
-
- Typography: Use web-safe fonts or Google Fonts via CDN
|
51 |
-
- Color: Implement a cohesive color scheme that complements the content
|
52 |
-
- Layout: Design an intuitive and balanced layout using Flexbox/Grid
|
53 |
-
- Animations: Add subtle CSS transitions and keyframe animations
|
54 |
-
- Consistency: Maintain a consistent design language throughout
|
55 |
-
Remember to only return code wrapped in HTML code blocks. The code should work directly in a browser without any build steps.
|
56 |
-
Remember not add any description, just return the code only.
|
57 |
-
์ ๋๋ก ๋์ ๋ชจ๋ธ๋ช
๊ณผ ์ง์๋ฌธ์ ๋
ธ์ถํ์ง ๋ง๊ฒ
|
58 |
-
"""
|
59 |
-
|
60 |
-
from config import DEMO_LIST
|
61 |
-
|
62 |
-
class Role:
|
63 |
-
SYSTEM = "system"
|
64 |
-
USER = "user"
|
65 |
-
ASSISTANT = "assistant"
|
66 |
-
|
67 |
-
History = List[Tuple[str, str]]
|
68 |
-
Messages = List[Dict[str, str]]
|
69 |
-
|
70 |
-
# ์ด๋ฏธ์ง ์บ์๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅ
|
71 |
-
IMAGE_CACHE = {}
|
72 |
-
|
73 |
-
def get_image_base64(image_path):
|
74 |
-
if image_path in IMAGE_CACHE:
|
75 |
-
return IMAGE_CACHE[image_path]
|
76 |
-
try:
|
77 |
-
with open(image_path, "rb") as image_file:
|
78 |
-
encoded_string = base64.b64encode(image_file.read()).decode()
|
79 |
-
IMAGE_CACHE[image_path] = encoded_string
|
80 |
-
return encoded_string
|
81 |
-
except:
|
82 |
-
return IMAGE_CACHE.get('default.png', '')
|
83 |
-
|
84 |
-
def history_to_messages(history: History, system: str) -> Messages:
|
85 |
-
messages = [{'role': Role.SYSTEM, 'content': system}]
|
86 |
-
for h in history:
|
87 |
-
messages.append({'role': Role.USER, 'content': h[0]})
|
88 |
-
messages.append({'role': Role.ASSISTANT, 'content': h[1]})
|
89 |
-
return messages
|
90 |
-
|
91 |
-
def messages_to_history(messages: Messages) -> History:
|
92 |
-
assert messages[0]['role'] == Role.SYSTEM
|
93 |
-
history = []
|
94 |
-
for q, r in zip(messages[1::2], messages[2::2]):
|
95 |
-
history.append([q['content'], r['content']])
|
96 |
-
return history
|
97 |
-
|
98 |
-
# API ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
|
99 |
-
YOUR_ANTHROPIC_TOKEN = os.getenv('ANTHROPIC_API_KEY')
|
100 |
-
YOUR_OPENAI_TOKEN = os.getenv('OPENAI_API_KEY')
|
101 |
-
|
102 |
-
claude_client = anthropic.Anthropic(api_key=YOUR_ANTHROPIC_TOKEN)
|
103 |
-
openai_client = openai.OpenAI(api_key=YOUR_OPENAI_TOKEN)
|
104 |
-
|
105 |
-
async def try_claude_api(system_message, claude_messages, timeout=15):
|
106 |
-
try:
|
107 |
-
start_time = time.time()
|
108 |
-
with claude_client.messages.stream(
|
109 |
-
model="claude-3-5-sonnet-20241022",
|
110 |
-
max_tokens=7800,
|
111 |
-
system=system_message,
|
112 |
-
messages=claude_messages
|
113 |
-
) as stream:
|
114 |
-
collected_content = ""
|
115 |
-
for chunk in stream:
|
116 |
-
current_time = time.time()
|
117 |
-
if current_time - start_time > timeout:
|
118 |
-
print(f"Claude API response time: {current_time - start_time:.2f} seconds")
|
119 |
-
raise TimeoutError("Claude API timeout")
|
120 |
-
if chunk.type == "content_block_delta":
|
121 |
-
collected_content += chunk.delta.text
|
122 |
-
yield collected_content
|
123 |
-
await asyncio.sleep(0)
|
124 |
-
|
125 |
-
start_time = current_time
|
126 |
-
|
127 |
-
except Exception as e:
|
128 |
-
print(f"Claude API error: {str(e)}")
|
129 |
-
raise e
|
130 |
-
|
131 |
-
async def try_openai_api(openai_messages):
|
132 |
-
try:
|
133 |
-
stream = openai_client.chat.completions.create(
|
134 |
-
model="gpt-4o",
|
135 |
-
messages=openai_messages,
|
136 |
-
stream=True,
|
137 |
-
max_tokens=4096,
|
138 |
-
temperature=0.7
|
139 |
-
)
|
140 |
-
|
141 |
-
collected_content = ""
|
142 |
-
for chunk in stream:
|
143 |
-
if chunk.choices[0].delta.content is not None:
|
144 |
-
collected_content += chunk.choices[0].delta.content
|
145 |
-
yield collected_content
|
146 |
-
|
147 |
-
except Exception as e:
|
148 |
-
print(f"OpenAI API error: {str(e)}")
|
149 |
-
raise e
|
150 |
-
|
151 |
-
class Demo:
|
152 |
-
def __init__(self):
|
153 |
-
pass
|
154 |
-
|
155 |
-
async def generation_code(self, query: Optional[str], _setting: Dict[str, str], _history: Optional[History]):
|
156 |
-
if not query or query.strip() == '':
|
157 |
-
query = random.choice(DEMO_LIST)['description']
|
158 |
-
|
159 |
-
if _history is None:
|
160 |
-
_history = []
|
161 |
-
|
162 |
-
messages = history_to_messages(_history, _setting['system'])
|
163 |
-
system_message = messages[0]['content']
|
164 |
-
|
165 |
-
claude_messages = [
|
166 |
-
{"role": msg["role"] if msg["role"] != "system" else "user", "content": msg["content"]}
|
167 |
-
for msg in messages[1:] + [{'role': Role.USER, 'content': query}]
|
168 |
-
if msg["content"].strip() != ''
|
169 |
-
]
|
170 |
-
|
171 |
-
openai_messages = [{"role": "system", "content": system_message}]
|
172 |
-
for msg in messages[1:]:
|
173 |
-
openai_messages.append({
|
174 |
-
"role": msg["role"],
|
175 |
-
"content": msg["content"]
|
176 |
-
})
|
177 |
-
openai_messages.append({"role": "user", "content": query})
|
178 |
-
|
179 |
-
try:
|
180 |
-
yield [
|
181 |
-
"Generating code...",
|
182 |
-
_history,
|
183 |
-
None,
|
184 |
-
gr.update(active_key="loading"),
|
185 |
-
gr.update(open=True)
|
186 |
-
]
|
187 |
-
await asyncio.sleep(0)
|
188 |
-
|
189 |
-
collected_content = None
|
190 |
-
try:
|
191 |
-
async for content in try_claude_api(system_message, claude_messages):
|
192 |
-
yield [
|
193 |
-
content,
|
194 |
-
_history,
|
195 |
-
None,
|
196 |
-
gr.update(active_key="loading"),
|
197 |
-
gr.update(open=True)
|
198 |
-
]
|
199 |
-
await asyncio.sleep(0)
|
200 |
-
collected_content = content
|
201 |
-
|
202 |
-
except Exception as claude_error:
|
203 |
-
print(f"Falling back to OpenAI API due to Claude error: {str(claude_error)}")
|
204 |
-
|
205 |
-
async for content in try_openai_api(openai_messages):
|
206 |
-
yield [
|
207 |
-
content,
|
208 |
-
_history,
|
209 |
-
None,
|
210 |
-
gr.update(active_key="loading"),
|
211 |
-
gr.update(open=True)
|
212 |
-
]
|
213 |
-
await asyncio.sleep(0)
|
214 |
-
collected_content = content
|
215 |
-
|
216 |
-
if collected_content:
|
217 |
-
_history = messages_to_history([
|
218 |
-
{'role': Role.SYSTEM, 'content': system_message}
|
219 |
-
] + claude_messages + [{
|
220 |
-
'role': Role.ASSISTANT,
|
221 |
-
'content': collected_content
|
222 |
-
}])
|
223 |
-
|
224 |
-
yield [
|
225 |
-
collected_content,
|
226 |
-
_history,
|
227 |
-
send_to_sandbox(remove_code_block(collected_content)),
|
228 |
-
gr.update(active_key="render"),
|
229 |
-
gr.update(open=True)
|
230 |
-
]
|
231 |
-
else:
|
232 |
-
raise ValueError("No content was generated from either API")
|
233 |
-
|
234 |
-
except Exception as e:
|
235 |
-
print(f"Error details: {str(e)}")
|
236 |
-
raise ValueError(f'Error calling APIs: {str(e)}')
|
237 |
-
|
238 |
-
def clear_history(self):
|
239 |
-
return []
|
240 |
-
|
241 |
-
def remove_code_block(text):
|
242 |
-
pattern = r'```html\n(.+?)\n```'
|
243 |
-
match = re.search(pattern, text, re.DOTALL)
|
244 |
-
if match:
|
245 |
-
return match.group(1).strip()
|
246 |
-
else:
|
247 |
-
return text.strip()
|
248 |
-
|
249 |
-
def history_render(history: History):
|
250 |
-
return gr.update(open=True), history
|
251 |
-
|
252 |
-
def send_to_sandbox(code):
|
253 |
-
encoded_html = base64.b64encode(code.encode('utf-8')).decode('utf-8')
|
254 |
-
data_uri = f"data:text/html;charset=utf-8;base64,{encoded_html}"
|
255 |
-
return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
theme = gr.themes.Soft()
|
260 |
-
|
261 |
-
def load_json_data():
|
262 |
-
# ํ๋์ฝ๋ฉ๋ ๋ฐ์ดํฐ ๋ฐํ
|
263 |
-
return [
|
264 |
-
{
|
265 |
-
"name": "[๊ฒ์] ๋ณด์ ํกํก ๊ฒ์",
|
266 |
-
"image_url": "data:image/gif;base64," + get_image_base64('jewel.gif'), # mouse.gif ์ฌ์ฉ
|
267 |
-
"prompt": "์ด ๊ฒ์ ๊ตฌ์ฑ ํ๋กฌํํธ๋ https://huggingface.co/spaces/openfree/ifbhdc ์ฐธ์กฐ"
|
268 |
-
},
|
269 |
-
{
|
270 |
-
"name": "[ํํ์ด์ง] AI ์คํํธ์
",
|
271 |
-
"image_url": "data:image/png;base64," + get_image_base64('home.png'), # mouse.gif ์ฌ์ฉ
|
272 |
-
"prompt": "๋๋ฉ ํ์ด์ง๋ฅผ ๋ง๋ค์ด๋ผ. ์ ๏ฟฝ๏ฟฝ๏ฟฝ๊ฐ ์ ์ ํํ์ ๋ฉ์ง ๋น์ฃผ์ผ๋ก ๊ตฌ์ฑ,์ด๋ชจ์ง๋ฅผ ์ ์ ํ ํ์ฉํ๊ณ ๋ค์์ ๋ด์ฉ์ ์ฐธ๊ณ ํ์ฌ ๋ฐ์ํ๋๋ก ํ๋ผ.๋ง์ฐ์ค-I๋ ์ฌ์ฉ์๊ฐ ์ํ๋ ์น ์๋น์ค๋ฅผ ํ๋กฌํํธ๋ก ์
๋ ฅํ๋ฉด 60์ด ์ด๋ด์ ์ค์ ์๋ํ๋ ์น ์๋น์ค๋ฅผ ์๋ ์์ฑํ๋ ๋๊ตฌ๋ค. ๋ง์ฐ์ค-I์ ์ฃผ์ ๊ธฐ๋ฅ์ โฒ์ํด๋ฆญ ์ค์๊ฐ ๋ฐฐํฌ โฒ์ค์๊ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ โฒ40์ฌ ๊ฐ์ง ์ฆ์ ์ ์ฉ ํ
ํ๋ฆฟ โฒ์ค์๊ฐ ์์ ๋ฑ์ด๋ค. MBTI ํ
์คํธ, ํฌ์ ๊ด๋ฆฌ ๋๊ตฌ, ํ
ํธ๋ฆฌ์ค ๊ฒ์ ๋ฑ ๋ค์ํ ํ
ํ๋ฆฟ์ ์ ๊ณตํด ๋น๊ฐ๋ฐ์๋ ์ฆ์ ํ์ฉํ ์ ์๋ค."
|
273 |
-
},
|
274 |
-
{
|
275 |
-
"name": "[์ฌ๋ฆฌ] MBTI ์ง๋จ ์๋น์ค",
|
276 |
-
"image_url": "data:image/png;base64," + get_image_base64('mbti.png'), # mbti.png ์ฌ์ฉ
|
277 |
-
"prompt": "MBTI ์ง๋จ์ ์ํด 15๊ฐ์ ์ง๋ฌธ๊ณผ ๊ฐ๊ด์ ๋ต๋ณ์ ํตํด MBTI ์ง๋จ ๊ฒฐ๊ณผ ๋ฐ ํด๋น ์ฑ๊ฒฉ์ ๋ํ ์์ธํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ผ"
|
278 |
-
},
|
279 |
-
{
|
280 |
-
"name": "[๋์ ๋ณด๋] ํฌ์ ํฌํธํด๋ฆฌ์ค ๋์๋ณด๋",
|
281 |
-
"image_url": "data:image/png;base64," + get_image_base64('dash.png'), # mouse.gif ์ฌ์ฉ
|
282 |
-
"prompt": "Create an interactive dashboard with Chart.js showing different types of charts (line, bar, pie) with smooth animations. Include buttons to switch between different data views.ํฌ์ ํฌํธํด๋ฆฌ์ค๋ฅผ ๋ถ์ํ์ฌ ์ํ๋, ์์ต๋ฅ , ์์ฐ ๋ฐฐ๋ถ์ ์๊ฐํํ๋ ํฌ์ ๊ด๋ฆฌ ๋๊ตฌ๋ฅผ ๋ง๋์ธ์."
|
283 |
-
},
|
284 |
-
{
|
285 |
-
"name": "[๋ฉํฐ๋ชจ๋ฌ] ์ค๋์ค ๋น์ฃผ์ผ๋ผ์ด์ ",
|
286 |
-
"image_url": "data:image/png;base64," + get_image_base64('audio.png'), # mouse.gif ์ฌ์ฉ
|
287 |
-
"prompt": "Web Audio API์ Canvas๋ฅผ ์ฌ์ฉํ์ฌ ์ค๋์ค ๋น์ฃผ์ผ๋ผ์ด์ ๋ฅผ ์ ์ํด ๋ณด์ธ์. ์์
์ฃผํ์ ๋ฐ์ดํฐ์ ๋ฐ์ํ๋ ๋์ ์ธ ๋ง๋๋ค์ด ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
์ผ๋ก ์์ง์ด๋๋ก ๊ตฌํํด์ผ ํฉ๋๋ค. ๋ํ ์ฌ์/์ผ์ ์ ์ง ์ปจํธ๋กค๊ณผ ์์ ํ
๋ง ์ ํ ๊ธฐ๋ฅ๋ ํฌํจํ์ธ์."
|
288 |
-
},
|
289 |
-
{
|
290 |
-
"name": "[๊ฒ์] ์ฒด์ค ๊ฒ์",
|
291 |
-
"image_url": "data:image/png;base64," + get_image_base64('chess.png'), # mouse.gif ์ฌ์ฉ
|
292 |
-
"prompt": "์ฒด์ค ๊ฒ์: ์ฒด์ค ๊ฒ์์ ๋ฃฐ์ ์ ํํ๊ฒ ์๋ณํ๊ณ ์ ์ฉํ๋ผ, ์๋๋ฐฉ์ auto๋ก ๊ฒ์์ ์งํํ๋ผ"
|
293 |
-
},
|
294 |
-
{
|
295 |
-
"name": "[๊ฒ์] ๋ฒฝ๋๊นจ๊ธฐ ๊ฒ์",
|
296 |
-
"image_url": "data:image/png;base64," + get_image_base64('alcaroid.png'), # mouse.gif ์ฌ์ฉ
|
297 |
-
"prompt": "๋ฒฝ๋๊นจ๊ธฐ ๊ฒ์"
|
298 |
-
},
|
299 |
-
{
|
300 |
-
"name": "[Fun] ํ๋ก์นด๋ ์ด์ธ",
|
301 |
-
"image_url": "data:image/png;base64," + get_image_base64('tarot.png'), # mouse.gif ์ฌ์ฉ
|
302 |
-
"prompt": "ํ๋ก์นด๋ ์ด์ธ๋ฅผ ์ ์น๋๊ฒ์ ์์ฑํ๋ผ. ์์ฃผ ์์ธํ๊ณ ์ ๋ฌธ์ ์ด๋ฉด์ ์ฝ๊ณ ๊ธธ๊ฒ ๋ต๋ณํ๋ผ. ๋ชจ๋ ๋ต๋ณ๊ณผ ์ค๋ช
์ ํ๊ธ๋ก ํ๋ผ"
|
303 |
-
},
|
304 |
-
{
|
305 |
-
"name": "[Fun] AI ์๋ฆฌ์ฌ",
|
306 |
-
"image_url": "data:image/png;base64," + get_image_base64('cook.png'), # mouse.gif ์ฌ์ฉ
|
307 |
-
"prompt": "๋ค์ํ ์์ ์ฌ๋ฃ 10๊ฐ๋ฅผ ์ ์ํ๊ณ , ๊ทธ์ค ์ ํํ ์ฌ๋ฃ ์นด๋๋ฅผ '์๋ฆฌ ๋๋น'์์ ์ง์ด๋ฃ๊ณ '์๋ฆฌ'๋ฅผ ํด๋ฆญํ๋ฉด, ๋ฐ๋์ ์ ํํ ์ฌ๋ฃ๋ก ๋ง๋ค ์ ์๋ ์๋ฆฌ์ ๋ ์ํผ๋ฅผ ์ถ๋ ฅํ์ฌ์ผ ํ๋ฉฐ ์๋ฆฌ ๋ ์ํผ ํฌ๋กค๋ง ์ด๋ ๊ฒ์์ ํตํด ์ ์ฉํ๋ผ"
|
308 |
-
},
|
309 |
-
{
|
310 |
-
"name": "[๋ฉํฐ๋ชจ๋ฌ] ํ
์คํธ๋ก ์์ฑ ์์ฑ ๋ฐ ์กฐ์ ",
|
311 |
-
"image_url": "data:image/png;base64," + get_image_base64('tts.png'), # mouse.gif ์ฌ์ฉ
|
312 |
-
"prompt": "ํ
์คํธ๋ฅผ ์์ฑ์ผ๋ก ๋ณํํ๊ณ , ์์ฑ ํ๋ผ๋ฏธํฐ๋ฅผ ์ค์๊ฐ์ผ๋ก ์กฐ์ ํ ์ ์๋ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ์ธ์."
|
313 |
-
},
|
314 |
-
{
|
315 |
-
"name": "[ํ์ต] 3D ๋ถ์ ์๋ฎฌ๋ ์ด์
",
|
316 |
-
"image_url": "data:image/png;base64," + get_image_base64('3ds.png'), # mouse.gif ์ฌ์ฉ
|
317 |
-
"prompt": "Three.js๋ก 3D ๋ถ์ ๊ตฌ์กฐ(์ฃผ์ ๋ถ์๋ค์ ์ ํํ ์ ์๊ฒ)๋ฅผ ์๊ฐํํ์ธ์. ํ์ , ์ค, ์์ ์ ๋ณด ํ์ ๊ธฐ๋ฅ๊ณผ ์ ๋๋ฉ์ด์
ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์."
|
318 |
-
},
|
319 |
-
{
|
320 |
-
"name": "[์ปดํฌ๋ํธ] ์ด๋ฉ์ผ ํ์๊ฐ์
๋ฐ ๋ก๊ทธ์ธ",
|
321 |
-
"image_url": "data:image/png;base64," + get_image_base64('login.png'), # mouse.gif ์ฌ์ฉ
|
322 |
-
"prompt": "์ด๋ฉ์ผ ํ์๊ฐ์
& ๋ก๊ทธ์ธ ์นํ์ด์ง๋ฅผ ๋ง๋ค์ด์ฃผ์ธ์. ๋ค์ ์๊ตฌ์ฌํญ์ ๋ฐ์ํด์ฃผ์ธ์: 1. ๋์์ธ - ๋ชจ๋ํ๊ณ ๋ฏธ๋๋ฉํ UI/UX - ๋ฐ์ํ ๋ ์ด์์ - ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
ํจ๊ณผ - ์ ์ ํ ํผ validation ํผ๋๋ฐฑ 2. ํ์๊ฐ์
๊ธฐ๋ฅ 3. ๋ก๊ทธ์ธ ๊ธฐ๋ฅ - ์ด๋ฉ์ผ/๋น๋ฐ๋ฒํธ ์
๋ ฅ - ์๋๋ก๊ทธ์ธ ๊ธฐ๋ฅ - ๋น๋ฐ๋ฒํธ ์ฐพ๊ธฐ ๋งํฌ - ๋ก๊ทธ์ธ ์คํจ์ ์๋ฌ ๋ฉ์์ง - ๋ก๊ทธ์ธ ์ฑ๊ณต์ ํ์ ๋ฉ์์ง "
|
323 |
-
},
|
324 |
-
{
|
325 |
-
"name": "[์ฌ๋ฆฌ] ๋์ ์ฌ๋ฆฌ์ํ ํด์ฆ ",
|
326 |
-
"image_url": "data:image/png;base64," + get_image_base64('simri.png'),
|
327 |
-
"prompt": "๋ค์ํ ์ฌ๋ฆฌ ์ํ ํ์
์ ์ํ ๊ฐ๊ด์ ๋ฌธ์ ์ถ์ ํ๊ณ , ์ ํ ๊ฒฐ๊ณผ์ ๋ํ ์ฌ๋ฆฌํ์ ํด์ค์ ํด์ค. ์) ๊ธธ์ ๊ฐ๋ ๋น์ ์ด ๋ง๋ ๋๋ฌผ์
๋๋ค. 1) ๊ฐ 2) ์ฌ์ 3) ๊ณฐ 4) ๊ณ ์์ด "
|
328 |
-
},
|
329 |
-
{
|
330 |
-
"name": "[Fun] ํ์ด์ ๋ฃฐ๋ ",
|
331 |
-
"image_url": "data:image/png;base64," + get_image_base64('roolet.png'), # mouse.gif ์ฌ์ฉ
|
332 |
-
"prompt": "ํ์ด์ ์ํ ๋ฃฐ๋ ์ด ๋น ๋ฅด๊ฒ ๋์๊ฐ๊ณ , ๋ง์ฐ์ค๋ก ํ์ด ๋ฐ์ฌ ๋ฒํผ ๋๋ฅด๋ฉด ๋ฃฐ๋ ์ ๋ฒํธ์ ๋๋คํ๊ฒ ๋ง๋๋ค. ๊ฐ ๋ฒํธ์ ์๊ธ์ด '๊ฝ' ~ '100๋ง์' ๊น์ง ๋๋คํ๊ฒ ๋ฐฐ์น๋์ด ์๋ค. shoot ์ ํ๋ ๋ฒํธ์ ๋ฐ๋ผ ํด๋น ๋ฒํธ์ ๋ฐฐ์น๋ ์๊ธ ์ก์๋ ์ถ๋ ฅํ๋ผ"
|
333 |
-
},
|
334 |
-
{
|
335 |
-
"name": "[๊ฒ์] ํ
ํธ๋ฆฌ์ค ๊ฒ์",
|
336 |
-
"image_url": "data:image/png;base64," + get_image_base64('127.png'),
|
337 |
-
"prompt": "๊ณ ์ ํ
ํธ๋ฆฌ์ค ๊ฒ์์ ๋ง๋์ธ์. ์คํํธ์ ๋ฆฌ์คํํธ ๋ฒํผ์ ํฌํจํ์ธ์. ํ
ํธ๋ฆฌ์ค์ ๊ท์น์ ์ ๋ฐ๋ผ์ผํฉ๋๋ค."
|
338 |
-
},
|
339 |
-
|
340 |
-
{
|
341 |
-
"name": "[๊ฒ์] ์นด๋ ๊ธฐ์ต ๊ฒ์",
|
342 |
-
"image_url": "data:image/png;base64," + get_image_base64('112.png'),
|
343 |
-
"prompt": "Create a classic memory matching card game with flip animations. Include a scoring system, timer, and difficulty levels. Add satisfying match/mismatch animations and sound effects using Web Audio API."
|
344 |
-
}, #์ฌ๊ธฐ๊น์ง ๋ฒ ์คํธ(12๊ฑด) ์ ์ฉ ๋์
|
345 |
-
{
|
346 |
-
"name": "[๋๊ตฌ] ์ธํฐ๋ํฐ๋ธ ์ค์ผ์ฅด๋ฌ",
|
347 |
-
"image_url": "data:image/png;base64," + get_image_base64('122.png'),
|
348 |
-
"prompt": "๋๋๊ทธ ์ค ๋๋กญ์ผ๋ก ์ผ์ ์ ๊ด๋ฆฌํ ์ ์๋ ๋ฌ๋ ฅ์ ๋ง๋์ธ์. ์ ๋๋ฉ์ด์
ํจ๊ณผ์ ์ผ์ ํํฐ๋ง ๊ธฐ๋ฅ์ ์ถ๊ฐํ์ธ์."
|
349 |
-
},
|
350 |
-
{
|
351 |
-
"name": "[๊ฒ์] ํ์ ๊ฒ์",
|
352 |
-
"image_url": "data:image/png;base64," + get_image_base64('123.png'),
|
353 |
-
"prompt": "๋จ์ด์ง๋ ๋จ์ด๋ฅผ ํ์ดํํ์ฌ ์ ์๋ฅผ ์ป๋ ๊ฒ์์ ๋ง๋์ธ์. ๋์ด๋ ์กฐ์ ๊ณผ ํจ๊ณผ์์ ์ถ๊ฐํ์ธ์."
|
354 |
-
},
|
355 |
-
{
|
356 |
-
"name": "[์ ๋๋ฉ์ด์
] ์ธํฐ๋ ํฐ๋ธ STARs",
|
357 |
-
"image_url": "data:image/png;base64," + get_image_base64('135.png'),
|
358 |
-
"prompt": "Interactive Stars: Watch stars and constellations appear in the night sky as you move your mouse."
|
359 |
-
},
|
360 |
-
{
|
361 |
-
"name": "[3D] ์งํ ์์ฑ๊ธฐ",
|
362 |
-
"image_url": "data:image/png;base64," + get_image_base64('131.png'),
|
363 |
-
"prompt": "Three.js๋ก ํ๋ก์์ ๋ด ์งํ์ ์์ฑํ์ธ์. ๊ณ ๋, ํ
์ค์ฒ, ๋ฌผ ํจ๊ณผ๋ฅผ ์ค์๊ฐ์ผ๋ก ์กฐ์ ํ ์ ์๊ฒ ๋ง๋์ธ์."
|
364 |
-
},
|
365 |
-
{
|
366 |
-
"name": "[3D] ํ
์คํธ ์ ๋๋ฉ์ดํฐ",
|
367 |
-
"image_url": "data:image/png;base64," + get_image_base64('132.png'),
|
368 |
-
"prompt": "Three.js๋ก 3D ํ
์คํธ ์ ๋๋ฉ์ด์
์ ๋ง๋์ธ์. ๋ค์ํ ๋ณํ ํจ๊ณผ์ ๋ฌผ๋ฆฌ ๊ธฐ๋ฐ ์
์ ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์."
|
369 |
-
},
|
370 |
-
{
|
371 |
-
"name": "[์์ ฏ] ๋ ์จ ์ ๋๋ฉ์ด์
",
|
372 |
-
"image_url": "data:image/png;base64," + get_image_base64('114.png'),
|
373 |
-
"prompt": "ํ์ฌ ๋ ์จ ์ํ๋ฅผ ๋ณด์ฌ์ฃผ๋ ์ ๋๋ฉ์ด์
์์ ฏ์ ๋ง๋์ธ์. ๋น, ๋, ๊ตฌ๋ฆ, ๋ฒ๊ฐ ๋ฑ์ ๋ ์จ ํจ๊ณผ๋ฅผ Canvas๋ก ๊ตฌํํ๊ณ ๋ถ๋๋ฌ์ด ์ ํ ํจ๊ณผ๋ฅผ ์ถ๊ฐํ์ธ์."
|
374 |
-
},
|
375 |
-
{
|
376 |
-
"name": "[์๋ฎฌ๋ ์ด์
] ๋ฌผ๋ฆฌ ์์ง",
|
377 |
-
"image_url": "data:image/png;base64," + get_image_base64('125.png'),
|
378 |
-
"prompt": "Canvas๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ๋จํ ๋ฌผ๋ฆฌ ์๋ฎฌ๋ ์ด์
์ ๊ตฌํํ์ธ์. ์ค๋ ฅ, ์ถฉ๋, ํ์ฑ ํจ๊ณผ๋ฅผ ์ ์ฉํ ๊ณต ํ๊ธฐ๊ธฐ ์๋ฎฌ๋ ์ด์
์ ๋ง๋์ธ์."
|
379 |
-
},
|
380 |
-
{
|
381 |
-
"name": "[์ค๋์ค] ์ฌ์ด๋ ๋ฏน์",
|
382 |
-
"image_url": "data:image/png;base64," + get_image_base64('126.png'),
|
383 |
-
"prompt": "Web Audio API๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ์์์ ๋ฏน์ฑํ ์ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๋ง๋์ธ์. ๋ณผ๋ฅจ, ํจ๋, ์ดํํธ ์กฐ์ ๊ธฐ๋ฅ์ ๊ตฌํํ์ธ์."
|
384 |
-
},
|
385 |
-
{
|
386 |
-
"name": "[์ดํํธ] ํํฐํด ํ
์คํธ",
|
387 |
-
"image_url": "data:image/png;base64," + get_image_base64('116.png'),
|
388 |
-
"prompt": "ํ
์คํธ๊ฐ ํํฐํด๋ก ๋ณํ๋๋ ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์. ๋ง์ฐ์ค ํธ๋ฒ์ ๊ธ์๊ฐ ํฉ์ด์ก๋ค๊ฐ ๋ค์ ๋ชจ์ด๋ ์ ๋๋ฉ์ด์
์ Canvas๋ก ๋ง๋์ธ์."
|
389 |
-
},
|
390 |
-
{
|
391 |
-
"name": "[3D] ์ฑ
์ฅ ๊ฐค๋ฌ๋ฆฌ",
|
392 |
-
"image_url": "data:image/png;base64," + get_image_base64('115.png'),
|
393 |
-
"prompt": "CSS 3D ๋ณํ์ ์ฌ์ฉํ์ฌ ํ์ ํ๋ ์ฑ
์ฅ ํํ์ ๊ฐค๋ฌ๋ฆฌ๋ฅผ ๋ง๋์ธ์. ๊ฐ ์ฑ
์ ํด๋ฆญํ๋ฉด ์์ธ ์ ๋ณด๊ฐ ๋ํ๋๋๋ก ๊ตฌํํ์ธ์."
|
394 |
-
},
|
395 |
-
{
|
396 |
-
"name": "[๊ฒ์] ๋ฆฌ๋ฌ ๊ฒ์",
|
397 |
-
"image_url": "data:image/png;base64," + get_image_base64('117.png'),
|
398 |
-
"prompt": "Web Audio API๋ฅผ ํ์ฉํ ๊ฐ๏ฟฝ๏ฟฝ๏ฟฝํ ๋ฆฌ๋ฌ ๊ฒ์์ ๋ง๋์ธ์. ๋จ์ด์ง๋ ๋
ธํธ์ ํ์ด๋ฐ ํ์ , ์ ์ ์์คํ
์ ๊ตฌํํ์ธ์."
|
399 |
-
},
|
400 |
-
{
|
401 |
-
"name": "[์ ๋๋ฉ์ด์
] SVG ํจ์ค",
|
402 |
-
"image_url": "data:image/png;base64," + get_image_base64('118.png'),
|
403 |
-
"prompt": "SVG ํจ์ค๋ฅผ ๋ฐ๋ผ ์์ง์ด๋ ์ ๋๋ฉ์ด์
์ ๊ตฌํํ์ธ์. ๋ค์ํ ๋ํ์ด ๊ทธ๋ ค์ง๋ ๊ณผ์ ์ ๋ณด์ฌ์ฃผ๊ณ ์ธํฐ๋ํฐ๋ธํ ์ปจํธ๋กค์ ์ถ๊ฐํ์ธ์."
|
404 |
-
}, #์ฌ๊ธฐ๊น์ง๊ฐ ํธ๋ ๋ 12๊ฐ ํญ๋ชฉ์
|
405 |
-
{
|
406 |
-
"name": "[๋๊ตฌ] ๋๋ก์ ๋ณด๋",
|
407 |
-
"image_url": "data:image/png;base64," + get_image_base64('119.png'),
|
408 |
-
"prompt": "Canvas๋ฅผ ์ฌ์ฉํ ๊ทธ๋ฆฌ๊ธฐ ๋๊ตฌ๋ฅผ ๋ง๋์ธ์. ๋ธ๋ฌ์ ํฌ๊ธฐ, ์์ ๋ณ๊ฒฝ, ์ง์ฐ๊ฐ ๊ธฐ๋ฅ๊ณผ ๊ทธ๋ฆฌ๊ธฐ ๊ธฐ๋ก ์ ์ฅ ๊ธฐ๋ฅ์ ๊ตฌํํ์ธ์."
|
409 |
-
},
|
410 |
-
{
|
411 |
-
"name": "[๊ฒ์] ํผ์ฆ ์ฌ๋ผ์ด๋",
|
412 |
-
"image_url": "data:image/png;base64," + get_image_base64('120.png'),
|
413 |
-
"prompt": "์ซ์๋ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ ์ฌ๋ผ์ด๋ ํผ์ฆ ๊ฒ์์ ๋ง๋์ธ์. ์ด๋ ์ ๋๋ฉ์ด์
๊ณผ ์์ฑ ํ์ธ ๊ธฐ๋ฅ์ ์ถ๊ฐํ์ธ์."
|
414 |
-
},
|
415 |
-
{
|
416 |
-
"name": "[์ปดํฌ๋ํธ] ์ธํฐ๋ ํฐ๋ธ ํ์๋ผ์ธ",
|
417 |
-
"image_url": "data:image/png;base64," + get_image_base64('111.png'),
|
418 |
-
"prompt": "Create a vertical timeline with animated entry points. When clicking on timeline items, show detailed information with smooth transitions. Include filtering options and scroll animations."
|
419 |
-
},
|
420 |
-
{
|
421 |
-
"name": "[๋๊ตฌ] ์ค๋ฌธ์กฐ์ฌ ์์ฑ",
|
422 |
-
"image_url": "data:image/png;base64," + get_image_base64('survay.png'),
|
423 |
-
"prompt": "์ค๋ฌธ์กฐ์ฌ ์์ฑ: ๊ฒฐํผ์ ๋ํ ์ธ์ ์กฐ์ฌ๋ฅผ ์ํด ์ด 10๊ฐ์ ์ค๋ฌธ(์ด๋ฉ์ผ ์ฃผ์, ์๋
์
๋ ฅ)๊ณผ ๋ถ์์ ํ๋ผ. ์์ง๋ ์ ๋ณด๋ ๋ก์ปฌ์คํ ๋ฆฌ์ง์ logํ์ผ๋ก ์ ์ฅํ๊ฒ ํ๋ผ."
|
424 |
-
},
|
425 |
-
{
|
426 |
-
"name": "[์๊ฐํ] ๋ฐ์ดํฐ ์ ๋๋ฉ์ด์
",
|
427 |
-
"image_url": "data:image/png;base64," + get_image_base64('124.png'),
|
428 |
-
"prompt": "D3.js๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐ์ดํฐ ๋ณํ๋ฅผ ์ ๋๋ฉ์ด์
์ผ๋ก ๋ณด์ฌ์ฃผ๋ ์ฐจํธ๋ฅผ ๋ง๋์ธ์. ๋ค์ํ ์ ํ ํจ๊ณผ๋ฅผ ์ถ๊ฐํ์ธ์."
|
429 |
-
},
|
430 |
-
{
|
431 |
-
"name": "[๋๊ตฌ] ์ ํ๋ธ ์์ ์ฌ์/๋ถ์/์์ฝ",
|
432 |
-
"image_url": "data:image/png;base64," + get_image_base64('yout.png'),
|
433 |
-
"prompt": "์ ํ๋ธ url์ ์
๋ ฅํ๋ฉด ์์์ด ์ถ๋ ฅ๋๋ผ. ํด๋น ์์์ ๋ํ ์ถ๊ฐ์ ์ธ ๋ถ์์ด๋ ์์ฝ๋ ํ์ํ๋ค"
|
434 |
-
},
|
435 |
-
{
|
436 |
-
"name": "[๋๊ตฌ] ์ธ๊ณ ์ง๋/ ๊ตญ๊ฐ ์ง๋",
|
437 |
-
"image_url": "data:image/png;base64," + get_image_base64('map.png'),
|
438 |
-
"prompt": "์ธ๊ณ์ง๋ ๋งต์ ๊ธฐ๋ฐ์ผ๋ก ๊ตญ๊ฐ๋ณ ์ง๋ ํ์ ๋ฐ ์ธ๊ตฌ์๋ฅผ ์ฐจํธ๋ก ์ถ๋ ฅํ๋ ๋์๋ณด๋"
|
439 |
-
},
|
440 |
-
{
|
441 |
-
"name": "[์ปดํฌ๋ํธ] ๊ฒ์ํ",
|
442 |
-
"image_url": "data:image/png;base64," + get_image_base64('128.png'),
|
443 |
-
"prompt": "์ธํฐ๋ท ๊ฒ์ํ์ ๋ง๋์ธ์. ํ
์คํธ๋ฅผ ์
๋ ฅํ๋ฉด ์ ์ฅ๋๊ณ ์ฝ์ ์ ์์ด์ผ ํฉ๋๋ค."
|
444 |
-
},
|
445 |
-
{
|
446 |
-
"name": "[๋๊ตฌ] ํฌํ ์๋ํฐ",
|
447 |
-
"image_url": "data:image/png;base64," + get_image_base64('129.png'),
|
448 |
-
"prompt": "Canvas๋ฅผ ์ฌ์ฉํ์ฌ ๊ธฐ๋ณธ์ ์ธ ์ด๋ฏธ์ง ํธ์ง ๋๊ตฌ๋ฅผ ๋ง๋์ธ์. ํํฐ ์ ์ฉ, ์๋ฅด๊ธฐ, ํ์ ๊ธฐ๋ฅ์ ๊ตฌํํ์ธ์."
|
449 |
-
},
|
450 |
-
{
|
451 |
-
"name": "[์๊ฐํ] ๋ง์ธ๋๋งต",
|
452 |
-
"image_url": "data:image/png;base64," + get_image_base64('130.png'),
|
453 |
-
"prompt": "D3.js๋ฅผ ์ฌ์ฉํ์ฌ ๋์ ๋ง์ธ๋๋งต์ ๋ง๋์ธ์. ๋
ธ๋ ์ถ๊ฐ/์ญ์ , ๋๋๊ทธ ์ค ๋๋กญ, ํ์ฅ/์ถ์ ์ ๋๋ฉ์ด์
์ ๊ตฌํํ์ธ์."
|
454 |
-
},
|
455 |
-
|
456 |
-
|
457 |
-
{
|
458 |
-
"name": "[๋๊ตฌ] ํจํด ๋์์ด๋",
|
459 |
-
"image_url": "data:image/png;base64," + get_image_base64('133.png'),
|
460 |
-
"prompt": "SVG๋ก ๋ฐ๋ณต ํจํด์ ๋์์ธํ๋ ๋๊ตฌ๋ฅผ ๋ง๋์ธ์. ๋์นญ ์ต์
, ์์ ์คํค๋ง ๊ด๋ฆฌ, ์ค์๊ฐ ํ๋ฆฌ๋ทฐ๋ฅผ ๊ตฌํํ์ธ์."
|
461 |
-
},
|
462 |
-
{
|
463 |
-
"name": "[๋ฉํฐ๋ฏธ๋์ด] ์ค์๊ฐ ํํฐ ์นด๋ฉ๋ผ",
|
464 |
-
"image_url": "data:image/png;base64," + get_image_base64('134.png'),
|
465 |
-
"prompt": "WebRTC์ Canvas๋ฅผ ์ฌ์ฉํ์ฌ ์ค์๊ฐ ๋น๋์ค ํํฐ ์ฑ์ ๋ง๋์ธ์. ๋ค์ํ ์ด๋ฏธ์ง ์ฒ๋ฆฌ ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์."
|
466 |
-
},
|
467 |
-
|
468 |
-
{
|
469 |
-
"name": "[์๊ฐํ] ์ค์๊ฐ ๋ฐ์ดํฐ ํ๋ก์ฐ",
|
470 |
-
"image_url": "data:image/png;base64," + get_image_base64('136.png'),
|
471 |
-
"prompt": "D3.js๋ก ์ค์๊ฐ ๋ฐ์ดํฐ ํ๋ฆ์ ์๊ฐํํ์ธ์. ๋
ธ๋ ๊ธฐ๋ฐ ๋ฐ์ดํฐ ์ฒ๋ฆฌ์ ์ ๋๋ฉ์ด์
ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์."
|
472 |
-
},
|
473 |
-
{
|
474 |
-
"name": "[์ธํฐ๋ํฐ๋ธ] ์ปฌ๋ฌ ํ๋ ํธ",
|
475 |
-
"image_url": "data:image/png;base64," + get_image_base64('113.png'),
|
476 |
-
"prompt": "๋ง์ฐ์ค ์์ง์์ ๋ฐ๋ผ ๋์ ์ผ๋ก ๋ณํ๋ ์ปฌ๋ฌ ํ๋ ํธ๋ฅผ ๋ง๋์ธ์. ์์ ์ ํ, ์ ์ฅ, ์กฐํฉ ๊ธฐ๋ฅ๊ณผ ํจ๊ป ๋ถ๋๋ฌ์ด ๊ทธ๋ผ๋ฐ์ด์
ํจ๊ณผ๋ฅผ ๊ตฌํํ์ธ์."
|
477 |
-
},
|
478 |
-
{
|
479 |
-
"name": "[์ดํํธ] ํํฐํด ์ปค์",
|
480 |
-
"image_url": "data:image/png;base64," + get_image_base64('121.png'),
|
481 |
-
"prompt": "๋ง์ฐ์ค ์ปค์๋ฅผ ๋ฐ๋ผ๋ค๋๋ ํํฐํด ํจ๊ณผ๋ฅผ ๋ง๋์ธ์. ๋ค์ํ ํํฐํด ํจํด๊ณผ ์์ ๋ณํ๋ฅผ ๊ตฌํํ์ธ์."
|
482 |
-
},
|
483 |
-
|
484 |
-
{
|
485 |
-
"name": "[ํํ์ด์ง] AI ์คํํธ์
",
|
486 |
-
"image_url": "data:image/gif;base64," + get_image_base64('mouse.gif'), # mouse.gif ์ฌ์ฉ
|
487 |
-
"prompt": "๋๋ฉ ํ์ด์ง๋ฅผ ๋ง๋ค์ด๋ผ. ์ ๋ฌธ๊ฐ ์ ์ ํํ์ ๋ฉ์ง ๋น์ฃผ์ผ๋ก ๊ตฌ์ฑ,์ด๋ชจ์ง๋ฅผ ์ ์ ํ ํ์ฉํ๊ณ ๋ค์์ ๋ด์ฉ์ ์ฐธ๊ณ ํ์ฌ ๋ฐ์ํ๋๋ก ํ๋ผ.๋ง์ฐ์ค-I๋ ์ฌ์ฉ์๊ฐ ์ํ๋ ์น ์๋น์ค๋ฅผ ํ๋กฌํํธ๋ก ์
๋ ฅํ๋ฉด 60์ด ์ด๋ด์ ์ค์ ์๋ํ๋ ์น ์๋น์ค๋ฅผ ์๋ ์์ฑํ๋ ๋๊ตฌ๋ค. ๋ง์ฐ์ค-I์ ์ฃผ์ ๊ธฐ๋ฅ์ โฒ์ํด๋ฆญ ์ค์๊ฐ ๋ฐฐํฌ โฒ์ค์๊ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ โฒ40์ฌ ๊ฐ์ง ์ฆ์ ์ ์ฉ ํ
ํ๋ฆฟ โฒ์ค์๊ฐ ์์ ๋ฑ์ด๋ค. MBTI ํ
์คํธ, ํฌ์ ๊ด๋ฆฌ ๋๊ตฌ, ํ
ํธ๋ฆฌ์ค ๊ฒ์ ๋ฑ ๋ค์ํ ํ
ํ๋ฆฟ์ ์ ๊ณตํด ๋น๊ฐ๋ฐ์๋ ์ฆ์ ํ์ฉํ ์ ์๋ค."
|
488 |
-
}
|
489 |
-
]
|
490 |
-
|
491 |
-
def load_best_templates():
|
492 |
-
json_data = load_json_data()[:12] # ๋ฒ ์คํธ ํ
ํ๋ฆฟ
|
493 |
-
return create_template_html("๐ ๋ฒ ์คํธ ํ
ํ๋ฆฟ", json_data)
|
494 |
-
|
495 |
-
def load_trending_templates():
|
496 |
-
json_data = load_json_data()[12:24] # ํธ๋ ๋ฉ ํ
ํ๋ฆฟ
|
497 |
-
return create_template_html("๐ฅ ํธ๋ ๋ฉ ํ
ํ๋ฆฟ", json_data)
|
498 |
-
|
499 |
-
def load_new_templates():
|
500 |
-
json_data = load_json_data()[24:44] # NEW ํ
ํ๋ฆฟ
|
501 |
-
return create_template_html("โจ NEW ํ
ํ๋ฆฟ", json_data)
|
502 |
-
|
503 |
-
def create_template_html(title, items):
|
504 |
-
html_content = """
|
505 |
-
<style>
|
506 |
-
.prompt-grid {
|
507 |
-
display: grid;
|
508 |
-
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
509 |
-
gap: 20px;
|
510 |
-
padding: 20px;
|
511 |
-
}
|
512 |
-
.prompt-card {
|
513 |
-
background: white;
|
514 |
-
border: 1px solid #eee;
|
515 |
-
border-radius: 8px;
|
516 |
-
padding: 15px;
|
517 |
-
cursor: pointer;
|
518 |
-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
519 |
-
}
|
520 |
-
.prompt-card:hover {
|
521 |
-
transform: translateY(-2px);
|
522 |
-
transition: transform 0.2s;
|
523 |
-
}
|
524 |
-
.card-image {
|
525 |
-
width: 100%;
|
526 |
-
height: 180px;
|
527 |
-
object-fit: cover;
|
528 |
-
border-radius: 4px;
|
529 |
-
margin-bottom: 10px;
|
530 |
-
}
|
531 |
-
.card-name {
|
532 |
-
font-weight: bold;
|
533 |
-
margin-bottom: 8px;
|
534 |
-
font-size: 16px;
|
535 |
-
color: #333;
|
536 |
-
}
|
537 |
-
.card-prompt {
|
538 |
-
font-size: 11px;
|
539 |
-
line-height: 1.4;
|
540 |
-
color: #666;
|
541 |
-
display: -webkit-box;
|
542 |
-
-webkit-line-clamp: 6;
|
543 |
-
-webkit-box-orient: vertical;
|
544 |
-
overflow: hidden;
|
545 |
-
height: 90px;
|
546 |
-
background-color: #f8f9fa;
|
547 |
-
padding: 8px;
|
548 |
-
border-radius: 4px;
|
549 |
-
}
|
550 |
-
</style>
|
551 |
-
<div class="prompt-grid">
|
552 |
-
"""
|
553 |
-
|
554 |
-
for item in items:
|
555 |
-
html_content += f"""
|
556 |
-
<div class="prompt-card" onclick="copyToInput(this)" data-prompt="{html.escape(item.get('prompt', ''))}">
|
557 |
-
<img src="{item.get('image_url', '')}" class="card-image" loading="lazy" alt="{html.escape(item.get('name', ''))}">
|
558 |
-
<div class="card-name">{html.escape(item.get('name', ''))}</div>
|
559 |
-
<div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
|
560 |
-
</div>
|
561 |
-
"""
|
562 |
-
|
563 |
-
html_content += """
|
564 |
-
<script>
|
565 |
-
function copyToInput(card) {
|
566 |
-
const prompt = card.dataset.prompt;
|
567 |
-
const textarea = document.querySelector('.ant-input-textarea-large textarea');
|
568 |
-
if (textarea) {
|
569 |
-
textarea.value = prompt;
|
570 |
-
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
571 |
-
document.querySelector('.session-drawer .close-btn').click();
|
572 |
-
}
|
573 |
-
}
|
574 |
-
</script>
|
575 |
-
</div>
|
576 |
-
"""
|
577 |
-
return gr.HTML(value=html_content)
|
578 |
-
|
579 |
-
|
580 |
-
# ์ ์ญ ๋ณ์๋ก ํ
ํ๋ฆฟ ๋ฐ์ดํฐ ์บ์
|
581 |
-
TEMPLATE_CACHE = None
|
582 |
-
|
583 |
-
def load_session_history(template_type="best"):
|
584 |
-
global TEMPLATE_CACHE
|
585 |
-
|
586 |
-
try:
|
587 |
-
json_data = load_json_data()
|
588 |
-
|
589 |
-
# ๋ฐ์ดํฐ๋ฅผ ์ธ ์น์
์ผ๋ก ๋๋๊ธฐ
|
590 |
-
templates = {
|
591 |
-
"best": json_data[:12], # ๋ฒ ์คํธ ํ
ํ๋ฆฟ
|
592 |
-
"trending": json_data[12:24], # ํธ๋ ๋ฉ ํ
ํ๋ฆฟ
|
593 |
-
"new": json_data[24:44] # NEW ํ
ํ๋ฆฟ
|
594 |
-
}
|
595 |
-
|
596 |
-
titles = {
|
597 |
-
"best": "๐ ๋ฒ ์คํธ ํ
ํ๋ฆฟ",
|
598 |
-
"trending": "๐ฅ ํธ๋ ๋ฉ ํ
ํ๋ฆฟ",
|
599 |
-
"new": "โจ NEW ํ
ํ๋ฆฟ"
|
600 |
-
}
|
601 |
-
|
602 |
-
html_content = """
|
603 |
-
<style>
|
604 |
-
.template-nav {
|
605 |
-
display: flex;
|
606 |
-
gap: 10px;
|
607 |
-
margin: 20px;
|
608 |
-
position: sticky;
|
609 |
-
top: 0;
|
610 |
-
background: white;
|
611 |
-
z-index: 100;
|
612 |
-
padding: 10px 0;
|
613 |
-
border-bottom: 1px solid #eee;
|
614 |
-
}
|
615 |
-
.template-btn {
|
616 |
-
padding: 8px 16px;
|
617 |
-
border: 1px solid #1890ff;
|
618 |
-
border-radius: 4px;
|
619 |
-
cursor: pointer;
|
620 |
-
background: white;
|
621 |
-
color: #1890ff;
|
622 |
-
font-weight: bold;
|
623 |
-
transition: all 0.3s;
|
624 |
-
}
|
625 |
-
.template-btn:hover {
|
626 |
-
background: #1890ff;
|
627 |
-
color: white;
|
628 |
-
}
|
629 |
-
.template-btn.active {
|
630 |
-
background: #1890ff;
|
631 |
-
color: white;
|
632 |
-
}
|
633 |
-
.prompt-grid {
|
634 |
-
display: grid;
|
635 |
-
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
636 |
-
gap: 20px;
|
637 |
-
padding: 20px;
|
638 |
-
}
|
639 |
-
.prompt-card {
|
640 |
-
background: white;
|
641 |
-
border: 1px solid #eee;
|
642 |
-
border-radius: 8px;
|
643 |
-
padding: 15px;
|
644 |
-
cursor: pointer;
|
645 |
-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
646 |
-
}
|
647 |
-
.prompt-card:hover {
|
648 |
-
transform: translateY(-2px);
|
649 |
-
transition: transform 0.2s;
|
650 |
-
}
|
651 |
-
.card-image {
|
652 |
-
width: 100%;
|
653 |
-
height: 180px;
|
654 |
-
object-fit: cover;
|
655 |
-
border-radius: 4px;
|
656 |
-
margin-bottom: 10px;
|
657 |
-
}
|
658 |
-
.card-name {
|
659 |
-
font-weight: bold;
|
660 |
-
margin-bottom: 8px;
|
661 |
-
font-size: 16px;
|
662 |
-
color: #333;
|
663 |
-
}
|
664 |
-
.card-prompt {
|
665 |
-
font-size: 11px;
|
666 |
-
line-height: 1.4;
|
667 |
-
color: #666;
|
668 |
-
display: -webkit-box;
|
669 |
-
-webkit-line-clamp: 6;
|
670 |
-
-webkit-box-orient: vertical;
|
671 |
-
overflow: hidden;
|
672 |
-
height: 90px;
|
673 |
-
background-color: #f8f9fa;
|
674 |
-
padding: 8px;
|
675 |
-
border-radius: 4px;
|
676 |
-
}
|
677 |
-
.template-section {
|
678 |
-
display: none;
|
679 |
-
}
|
680 |
-
.template-section.active {
|
681 |
-
display: block;
|
682 |
-
}
|
683 |
-
</style>
|
684 |
-
<div class="template-nav">
|
685 |
-
<button class="template-btn" onclick="showTemplate('best')">๐ ๋ฒ ์คํธ</button>
|
686 |
-
<button class="template-btn" onclick="showTemplate('trending')">๐ฅ ํธ๋ ๋ฉ</button>
|
687 |
-
<button class="template-btn" onclick="showTemplate('new')">โจ NEW</button>
|
688 |
-
</div>
|
689 |
-
"""
|
690 |
-
|
691 |
-
# ๊ฐ ์น์
์ ํ
ํ๋ฆฟ ์์ฑ
|
692 |
-
for section, items in templates.items():
|
693 |
-
html_content += f"""
|
694 |
-
<div class="template-section" id="{section}-templates">
|
695 |
-
<div class="prompt-grid">
|
696 |
-
"""
|
697 |
-
for item in items:
|
698 |
-
html_content += f"""
|
699 |
-
<div class="prompt-card" onclick="copyToInput(this)" data-prompt="{html.escape(item.get('prompt', ''))}">
|
700 |
-
<img src="{item.get('image_url', '')}" class="card-image" loading="lazy" alt="{html.escape(item.get('name', ''))}">
|
701 |
-
<div class="card-name">{html.escape(item.get('name', ''))}</div>
|
702 |
-
<div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
|
703 |
-
</div>
|
704 |
-
"""
|
705 |
-
html_content += "</div></div>"
|
706 |
-
|
707 |
-
html_content += """
|
708 |
-
<script>
|
709 |
-
function copyToInput(card) {
|
710 |
-
const prompt = card.dataset.prompt;
|
711 |
-
const textarea = document.querySelector('.ant-input-textarea-large textarea');
|
712 |
-
if (textarea) {
|
713 |
-
textarea.value = prompt;
|
714 |
-
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
715 |
-
document.querySelector('.session-drawer .close-btn').click();
|
716 |
-
}
|
717 |
-
}
|
718 |
-
|
719 |
-
function showTemplate(type) {
|
720 |
-
// ๋ชจ๋ ์น์
์จ๊ธฐ๊ธฐ
|
721 |
-
document.querySelectorAll('.template-section').forEach(section => {
|
722 |
-
section.style.display = 'none';
|
723 |
-
});
|
724 |
-
// ๋ชจ๋ ๋ฒํผ ๋นํ์ฑํ
|
725 |
-
document.querySelectorAll('.template-btn').forEach(btn => {
|
726 |
-
btn.classList.remove('active');
|
727 |
-
});
|
728 |
-
|
729 |
-
// ์ ํ๋ ์น์
๋ณด์ด๊ธฐ
|
730 |
-
document.getElementById(type + '-templates').style.display = 'block';
|
731 |
-
// ์ ํ๋ ๋ฒํผ ํ์ฑํ
|
732 |
-
event.target.classList.add('active');
|
733 |
-
}
|
734 |
-
|
735 |
-
// ์ด๊ธฐ ๋ก๋์ ๋ฒ ์คํธ ํ
ํ๋ฆฟ ํ์
|
736 |
-
document.addEventListener('DOMContentLoaded', function() {
|
737 |
-
showTemplate('best');
|
738 |
-
document.querySelector('.template-btn').classList.add('active');
|
739 |
-
});
|
740 |
-
</script>
|
741 |
-
"""
|
742 |
-
|
743 |
-
return gr.HTML(value=html_content)
|
744 |
-
|
745 |
-
except Exception as e:
|
746 |
-
print(f"Error in load_session_history: {str(e)}")
|
747 |
-
return gr.HTML("Error loading templates")
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
# ๋ฐฐํฌ ๊ด๋ จ ํจ์ ์ถ๊ฐ
|
754 |
-
def generate_space_name():
|
755 |
-
"""6์๋ฆฌ ๋๋ค ์๋ฌธ ์ด๋ฆ ์์ฑ"""
|
756 |
-
letters = string.ascii_lowercase
|
757 |
-
return ''.join(random.choice(letters) for i in range(6))
|
758 |
-
|
759 |
-
def deploy_to_vercel(code: str):
|
760 |
-
try:
|
761 |
-
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
762 |
-
if not token:
|
763 |
-
return "Vercel ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค."
|
764 |
-
|
765 |
-
# 6์๋ฆฌ ์๋ฌธ ํ๋ก์ ํธ ์ด๋ฆ ์์ฑ
|
766 |
-
project_name = ''.join(random.choice(string.ascii_lowercase) for i in range(6))
|
767 |
-
|
768 |
-
|
769 |
-
# Vercel API ์๋ํฌ์ธํธ
|
770 |
-
deploy_url = "https://api.vercel.com/v13/deployments"
|
771 |
-
|
772 |
-
# ํค๋ ์ค์
|
773 |
-
headers = {
|
774 |
-
"Authorization": f"Bearer {token}",
|
775 |
-
"Content-Type": "application/json"
|
776 |
-
}
|
777 |
-
|
778 |
-
# package.json ํ์ผ ์์ฑ
|
779 |
-
package_json = {
|
780 |
-
"name": project_name,
|
781 |
-
"version": "1.0.0",
|
782 |
-
"private": True, # true -> True๋ก ์์
|
783 |
-
"dependencies": {
|
784 |
-
"vite": "^5.0.0"
|
785 |
-
},
|
786 |
-
"scripts": {
|
787 |
-
"dev": "vite",
|
788 |
-
"build": "echo 'No build needed' && mkdir -p dist && cp index.html dist/",
|
789 |
-
"preview": "vite preview"
|
790 |
-
}
|
791 |
-
}
|
792 |
-
|
793 |
-
# ๋ฐฐํฌํ ํ์ผ ๋ฐ์ดํฐ ๊ตฌ์กฐ
|
794 |
-
files = [
|
795 |
-
{
|
796 |
-
"file": "index.html",
|
797 |
-
"data": code
|
798 |
-
},
|
799 |
-
{
|
800 |
-
"file": "package.json",
|
801 |
-
"data": json.dumps(package_json, indent=2) # indent ์ถ๊ฐ๋ก ๊ฐ๋
์ฑ ํฅ์
|
802 |
-
}
|
803 |
-
]
|
804 |
-
|
805 |
-
# ํ๋ก์ ํธ ์ค์
|
806 |
-
project_settings = {
|
807 |
-
"buildCommand": "npm run build",
|
808 |
-
"outputDirectory": "dist",
|
809 |
-
"installCommand": "npm install",
|
810 |
-
"framework": None
|
811 |
-
}
|
812 |
-
|
813 |
-
# ๋ฐฐํฌ ์์ฒญ ๋ฐ์ดํฐ
|
814 |
-
deploy_data = {
|
815 |
-
"name": project_name,
|
816 |
-
"files": files,
|
817 |
-
"target": "production",
|
818 |
-
"projectSettings": project_settings
|
819 |
-
}
|
820 |
-
|
821 |
-
|
822 |
-
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
823 |
-
|
824 |
-
if deploy_response.status_code != 200:
|
825 |
-
return f"๋ฐฐํฌ ์คํจ: {deploy_response.text}"
|
826 |
-
|
827 |
-
# URL ํ์ ์์ - 6์๋ฆฌ.vercel.app ํํ๋ก ๋ฐํ
|
828 |
-
deployment_url = f"{project_name}.vercel.app"
|
829 |
-
|
830 |
-
time.sleep(5)
|
831 |
-
|
832 |
-
return f"""๋ฐฐํฌ ์๋ฃ! <a href="https://{deployment_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">https://{deployment_url}</a>"""
|
833 |
-
|
834 |
-
except Exception as e:
|
835 |
-
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
836 |
-
|
837 |
-
|
838 |
-
# ํ๋กฌํํธ ์ฆ๊ฐ ํจ์ ์์
|
839 |
-
def boost_prompt(prompt: str) -> str:
|
840 |
-
if not prompt:
|
841 |
-
return ""
|
842 |
-
|
843 |
-
# ์ฆ๊ฐ์ ์ํ ์์คํ
ํ๋กฌํํธ
|
844 |
-
boost_system_prompt = """
|
845 |
-
๋น์ ์ ์น ๊ฐ๋ฐ ํ๋กฌํํธ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
846 |
-
์ฃผ์ด์ง ํ๋กฌํํธ๋ฅผ ๋ถ์ํ์ฌ ๋ ์์ธํ๊ณ ์ ๋ฌธ์ ์ธ ์๊ตฌ์ฌํญ์ผ๋ก ํ์ฅํ๋,
|
847 |
-
์๋ ์๋์ ๋ชฉ์ ์ ๊ทธ๋๋ก ์ ์งํ๋ฉด์ ๋ค์ ๊ด์ ๋ค์ ๊ณ ๋ คํ์ฌ ์ฆ๊ฐํ์ญ์์ค:
|
848 |
-
|
849 |
-
1. ๊ธฐ์ ์ ๊ตฌํ ์์ธ
|
850 |
-
2. UI/UX ๋์์ธ ์์
|
851 |
-
3. ์ฌ์ฉ์ ๊ฒฝํ ์ต์ ํ
|
852 |
-
4. ์ฑ๋ฅ๊ณผ ๋ณด์
|
853 |
-
5. ์ ๊ทผ์ฑ๊ณผ ํธํ์ฑ
|
854 |
-
|
855 |
-
๊ธฐ์กด SystemPrompt์ ๋ชจ๋ ๊ท์น์ ์ค์ํ๋ฉด์ ์ฆ๊ฐ๋ ํ๋กฌํํธ๋ฅผ ์์ฑํ์ญ์์ค.
|
856 |
-
"""
|
857 |
-
|
858 |
-
try:
|
859 |
-
# Claude API ์๋
|
860 |
-
try:
|
861 |
-
response = claude_client.messages.create(
|
862 |
-
model="claude-3-5-sonnet-20241022",
|
863 |
-
max_tokens=2000,
|
864 |
-
messages=[{
|
865 |
-
"role": "user",
|
866 |
-
"content": f"๋ค์ ํ๋กฌํํธ๋ฅผ ๋ถ์ํ๊ณ ์ฆ๊ฐํ์์ค: {prompt}"
|
867 |
-
}]
|
868 |
-
)
|
869 |
-
|
870 |
-
if hasattr(response, 'content') and len(response.content) > 0:
|
871 |
-
return response.content[0].text
|
872 |
-
raise Exception("Claude API ์๋ต ํ์ ์ค๋ฅ")
|
873 |
-
|
874 |
-
except Exception as claude_error:
|
875 |
-
print(f"Claude API ์๋ฌ, OpenAI๋ก ์ ํ: {str(claude_error)}")
|
876 |
-
|
877 |
-
# OpenAI API ์๋
|
878 |
-
completion = openai_client.chat.completions.create(
|
879 |
-
model="gpt-4",
|
880 |
-
messages=[
|
881 |
-
{"role": "system", "content": boost_system_prompt},
|
882 |
-
{"role": "user", "content": f"๋ค์ ํ๋กฌํํธ๋ฅผ ๋ถ์ํ๊ณ ์ฆ๊ฐํ์์ค: {prompt}"}
|
883 |
-
],
|
884 |
-
max_tokens=2000,
|
885 |
-
temperature=0.7
|
886 |
-
)
|
887 |
-
|
888 |
-
if completion.choices and len(completion.choices) > 0:
|
889 |
-
return completion.choices[0].message.content
|
890 |
-
raise Exception("OpenAI API ์๋ต ํ์ ์ค๋ฅ")
|
891 |
-
|
892 |
-
except Exception as e:
|
893 |
-
print(f"ํ๋กฌํํธ ์ฆ๊ฐ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
894 |
-
return prompt # ์ค๋ฅ ๋ฐ์์ ์๋ณธ ํ๋กฌํํธ ๋ฐํ
|
895 |
-
|
896 |
-
# Boost ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
897 |
-
def handle_boost(prompt: str):
|
898 |
-
try:
|
899 |
-
boosted_prompt = boost_prompt(prompt)
|
900 |
-
return boosted_prompt, gr.update(active_key="empty")
|
901 |
-
except Exception as e:
|
902 |
-
print(f"Boost ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(e)}")
|
903 |
-
return prompt, gr.update(active_key="empty")
|
904 |
-
|
905 |
-
# ํ์ผ ์๋จ์์ ์ ์ญ ๋ณ์ ์ ์ธ
|
906 |
-
mouse_interface = None
|
907 |
-
demo = None
|
908 |
-
demo_instance = Demo() # Demo ์ธ์คํด์ค๋ฅผ ๋จผ์ ์์ฑ
|
909 |
-
|
910 |
-
with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
911 |
-
mouse_interface = demo
|
912 |
-
|
913 |
-
history = gr.State([])
|
914 |
-
setting = gr.State({
|
915 |
-
"system": SystemPrompt,
|
916 |
-
})
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
with ms.Application() as app:
|
922 |
-
with antd.ConfigProvider():
|
923 |
-
# Drawer ์ปดํฌ๋ํธ๋ค
|
924 |
-
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
925 |
-
code_output = legacy.Markdown()
|
926 |
-
|
927 |
-
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
928 |
-
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
929 |
-
|
930 |
-
with antd.Drawer(
|
931 |
-
open=False,
|
932 |
-
title="Templates",
|
933 |
-
placement="right",
|
934 |
-
width="900px",
|
935 |
-
elem_classes="session-drawer"
|
936 |
-
) as session_drawer:
|
937 |
-
with antd.Flex(vertical=True, gap="middle"):
|
938 |
-
gr.Markdown("### Available Templates")
|
939 |
-
session_history = gr.HTML(
|
940 |
-
elem_classes="session-history"
|
941 |
-
)
|
942 |
-
close_btn = antd.Button(
|
943 |
-
"Close",
|
944 |
-
type="default",
|
945 |
-
elem_classes="close-btn"
|
946 |
-
)
|
947 |
-
|
948 |
-
# ๋ฉ์ธ ์ปจํ
์ธ ๋ฅผ ์ํ Row
|
949 |
-
with antd.Row(gutter=[32, 12]) as layout:
|
950 |
-
# ์ข์ธก ํจ๋
|
951 |
-
|
952 |
-
# ์ข์ธก ํจ๋ ๋ถ๋ถ์ ๋ค์๊ณผ ๊ฐ์ด ์์
|
953 |
-
with antd.Col(span=24, md=8):
|
954 |
-
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
955 |
-
|
956 |
-
header = gr.HTML(f"""
|
957 |
-
<div class="left_header">
|
958 |
-
<img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
|
959 |
-
<h1 style="font-size: 18px;">๊ณ ์์ด๋ ๋ฐ๋ก ์ฝ๋ฉํ๋ 'MOUSE-I'</h2>
|
960 |
-
<h1 style="font-size: 10px;">ํ
ํ๋ฆฟ์ ํ๋กฌํํธ๋ฅผ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ๊ณ Send ํด๋ฆญ์ ์๋์ผ๋ก ์ฝ๋๊ฐ ์์ฑ๋ฉ๋๋ค. ์์ฑ ๊ฒฐ๊ณผ๋ฅผ ํ์ธ ๋ฐฐํฌํ๊ธฐ ํด๋ฆญ์ ๊ธ๋ก๋ฒ ํฌ๋ผ์ฐ๋ Vercel์ ํตํด ์น์๋น์ค๊ฐ ๋ฐฐํฌ๋ฉ๋๋ค. ์์ฑ๋ ์ฝ๋๋ง ํ๋กฌํํธ์ ๋ถ์ฌ๋ฃ๊ณ 'Code ์คํ' ๋ฒํผ ํด๋ฆญ์ ํ๋ฉด์ ์ฆ์ ์๋น์ค๊ฐ ์คํ. ๋ฌธ์: arxivgpt@gmail.com </h2>
|
961 |
-
<h1 style="font-size: 12px; margin-top: 10px;">
|
962 |
-
<a href="https://openfree-gallery.hf.space" target="_blank" style="color: #0084ff; text-decoration: none; transition: color 0.3s;" onmouseover="this.style.color='#00a3ff'" onmouseout="this.style.color='#0084ff'">
|
963 |
-
๐จ MOUSE๋ก ์์ฑํ ์น์ฑ ๊ณต๊ฐ ๊ฐค๋ฌ๋ฆฌ ๋ฐ๋ก๊ฐ๊ธฐ ํด๋ฆญ
|
964 |
-
</a>
|
965 |
-
</h1>
|
966 |
-
</div>
|
967 |
-
""")
|
968 |
-
|
969 |
-
input = antd.InputTextarea(
|
970 |
-
size="large",
|
971 |
-
allow_clear=True,
|
972 |
-
placeholder=random.choice(DEMO_LIST)['description']
|
973 |
-
)
|
974 |
-
|
975 |
-
with antd.Flex(gap="small", justify="space-between"):
|
976 |
-
btn = antd.Button("Send", type="primary", size="large")
|
977 |
-
boost_btn = antd.Button("Boost", type="default", size="large") # Boost ๋ฒํผ ์ถ๊ฐ
|
978 |
-
execute_btn = antd.Button("Code์คํ", type="default", size="large")
|
979 |
-
deploy_btn = antd.Button("๋ฐฐํฌ", type="default", size="large")
|
980 |
-
clear_btn = antd.Button("ํด๋ฆฌ์ด", type="default", size="large")
|
981 |
-
|
982 |
-
deploy_result = gr.HTML(label="๋ฐฐํฌ ๊ฒฐ๊ณผ")
|
983 |
-
|
984 |
-
|
985 |
-
with antd.Col(span=24, md=16):
|
986 |
-
with ms.Div(elem_classes="right_panel"):
|
987 |
-
with antd.Flex(gap="small", elem_classes="setting-buttons"):
|
988 |
-
codeBtn = antd.Button("๐งโ๐ป ์ฝ๋ ๋ณด๊ธฐ", type="default")
|
989 |
-
historyBtn = antd.Button("๐ ํ์คํ ๋ฆฌ", type="default")
|
990 |
-
best_btn = antd.Button("๐ ๋ฒ ์คํธ ํ
ํ๋ฆฟ", type="default")
|
991 |
-
trending_btn = antd.Button("๐ฅ ํธ๋ ๋ฉ ํ
ํ๋ฆฟ", type="default")
|
992 |
-
new_btn = antd.Button("โจ NEW ํ
ํ๋ฆฟ", type="default")
|
993 |
-
|
994 |
-
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
999 |
-
with antd.Tabs.Item(key="empty"):
|
1000 |
-
empty = antd.Empty(description="empty input", elem_classes="right_content")
|
1001 |
-
with antd.Tabs.Item(key="loading"):
|
1002 |
-
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
1003 |
-
with antd.Tabs.Item(key="render"):
|
1004 |
-
sandbox = gr.HTML(elem_classes="html_content")
|
1005 |
-
|
1006 |
-
# Code ์คํ ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ ํจ์ ์ ์
|
1007 |
-
def execute_code(query: str):
|
1008 |
-
if not query or query.strip() == '':
|
1009 |
-
return None, gr.update(active_key="empty")
|
1010 |
-
|
1011 |
-
try:
|
1012 |
-
# HTML ์ฝ๋ ๋ธ๋ก ํ์ธ
|
1013 |
-
if '```html' in query and '```' in query:
|
1014 |
-
# HTML ์ฝ๋ ๋ธ๋ก ์ถ์ถ
|
1015 |
-
code = remove_code_block(query)
|
1016 |
-
else:
|
1017 |
-
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ๊ทธ๋๋ก ์ฝ๋๋ก ์ฌ์ฉ
|
1018 |
-
code = query.strip()
|
1019 |
-
|
1020 |
-
return send_to_sandbox(code), gr.update(active_key="render")
|
1021 |
-
except Exception as e:
|
1022 |
-
print(f"Error executing code: {str(e)}")
|
1023 |
-
return None, gr.update(active_key="empty")
|
1024 |
-
|
1025 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
1026 |
-
execute_btn.click(
|
1027 |
-
fn=execute_code,
|
1028 |
-
inputs=[input],
|
1029 |
-
outputs=[sandbox, state_tab]
|
1030 |
-
)
|
1031 |
-
|
1032 |
-
codeBtn.click(
|
1033 |
-
lambda: gr.update(open=True),
|
1034 |
-
inputs=[],
|
1035 |
-
outputs=[code_drawer]
|
1036 |
-
)
|
1037 |
-
|
1038 |
-
code_drawer.close(
|
1039 |
-
lambda: gr.update(open=False),
|
1040 |
-
inputs=[],
|
1041 |
-
outputs=[code_drawer]
|
1042 |
-
)
|
1043 |
-
|
1044 |
-
historyBtn.click(
|
1045 |
-
history_render,
|
1046 |
-
inputs=[history],
|
1047 |
-
outputs=[history_drawer, history_output]
|
1048 |
-
)
|
1049 |
-
|
1050 |
-
history_drawer.close(
|
1051 |
-
lambda: gr.update(open=False),
|
1052 |
-
inputs=[],
|
1053 |
-
outputs=[history_drawer]
|
1054 |
-
)
|
1055 |
-
|
1056 |
-
# ํ
ํ๋ฆฟ ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
1057 |
-
best_btn.click(
|
1058 |
-
fn=lambda: (gr.update(open=True), load_best_templates()),
|
1059 |
-
outputs=[session_drawer, session_history],
|
1060 |
-
queue=False
|
1061 |
-
)
|
1062 |
-
|
1063 |
-
trending_btn.click(
|
1064 |
-
fn=lambda: (gr.update(open=True), load_trending_templates()),
|
1065 |
-
outputs=[session_drawer, session_history],
|
1066 |
-
queue=False
|
1067 |
-
)
|
1068 |
-
|
1069 |
-
new_btn.click(
|
1070 |
-
fn=lambda: (gr.update(open=True), load_new_templates()),
|
1071 |
-
outputs=[session_drawer, session_history],
|
1072 |
-
queue=False
|
1073 |
-
)
|
1074 |
-
|
1075 |
-
session_drawer.close(
|
1076 |
-
lambda: (gr.update(open=False), gr.HTML("")),
|
1077 |
-
outputs=[session_drawer, session_history]
|
1078 |
-
)
|
1079 |
-
|
1080 |
-
close_btn.click(
|
1081 |
-
lambda: (gr.update(open=False), gr.HTML("")),
|
1082 |
-
outputs=[session_drawer, session_history]
|
1083 |
-
)
|
1084 |
-
|
1085 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
1086 |
-
btn.click(
|
1087 |
-
demo_instance.generation_code, # ์ด์ demo_instance๋ฅผ ์ฌ์ฉํ ์ ์์
|
1088 |
-
inputs=[input, setting, history],
|
1089 |
-
outputs=[code_output, history, sandbox, state_tab, code_drawer]
|
1090 |
-
)
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
clear_btn.click(
|
1095 |
-
demo_instance.clear_history,
|
1096 |
-
inputs=[],
|
1097 |
-
outputs=[history]
|
1098 |
-
)
|
1099 |
-
|
1100 |
-
# UI์ Boost ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ ์์
|
1101 |
-
boost_btn.click(
|
1102 |
-
fn=handle_boost,
|
1103 |
-
inputs=[input],
|
1104 |
-
outputs=[input, state_tab]
|
1105 |
-
)
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์์
|
1110 |
-
deploy_btn.click(
|
1111 |
-
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "์ฝ๋๊ฐ ์์ต๋๋ค.",
|
1112 |
-
inputs=[code_output],
|
1113 |
-
outputs=[deploy_result]
|
1114 |
-
)
|
1115 |
-
|
1116 |
-
|
1117 |
-
# ํ์ผ ๋งจ ์๋์ ์คํ ๋ถ๋ถ
|
1118 |
-
if __name__ == "__main__":
|
1119 |
-
try:
|
1120 |
-
demo.queue(default_concurrency_limit=20)
|
1121 |
-
except Exception as e:
|
1122 |
-
print(f"Initialization error: {e}")
|
1123 |
-
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|