Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -183,47 +183,7 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 183 |
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
| 184 |
with antd.Tabs.Item(key="render"):
|
| 185 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 186 |
-
|
| 187 |
-
with antd.ConfigProvider():
|
| 188 |
-
# 메인 컨텐츠 영역
|
| 189 |
-
with antd.Row(gutter=[32, 12], elem_classes="main-content") as layout:
|
| 190 |
-
# 좌측 패널
|
| 191 |
-
with antd.Col(span=24, md=8):
|
| 192 |
-
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 193 |
-
header = gr.HTML(f"""
|
| 194 |
-
<div class="left_header">
|
| 195 |
-
<img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
|
| 196 |
-
<h1 style="font-size: 20px;">AI 코딩 코파일럿: MOUSE(WEB)</h2>
|
| 197 |
-
</div>
|
| 198 |
-
""")
|
| 199 |
-
input = antd.InputTextarea(
|
| 200 |
-
size="large",
|
| 201 |
-
allow_clear=True,
|
| 202 |
-
placeholder="Please enter what kind of application you want"
|
| 203 |
-
)
|
| 204 |
|
| 205 |
-
btn = antd.Button("send", type="primary", size="large")
|
| 206 |
-
clear_btn = antd.Button("clear history", type="default", size="large")
|
| 207 |
-
|
| 208 |
-
# 우측 패널
|
| 209 |
-
with antd.Col(span=24, md=16):
|
| 210 |
-
# Setting 버튼들을 우측 상단에 별도로 배치
|
| 211 |
-
with antd.Row(justify="end", elem_classes="setting-buttons-row"):
|
| 212 |
-
settingPromptBtn = antd.Button("⚙️ set system Prompt", type="default")
|
| 213 |
-
codeBtn = antd.Button("🧑💻 view code", type="default")
|
| 214 |
-
historyBtn = antd.Button("📜 history", type="default")
|
| 215 |
-
|
| 216 |
-
# 웹 출력 패널
|
| 217 |
-
with ms.Div(elem_classes="right_panel"):
|
| 218 |
-
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
| 219 |
-
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 220 |
-
with antd.Tabs.Item(key="empty"):
|
| 221 |
-
empty = antd.Empty(description="empty input", elem_classes="right_content")
|
| 222 |
-
with antd.Tabs.Item(key="loading"):
|
| 223 |
-
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
| 224 |
-
with antd.Tabs.Item(key="render"):
|
| 225 |
-
sandbox = gr.HTML(elem_classes="html_content")
|
| 226 |
-
|
| 227 |
# Examples 섹션
|
| 228 |
with antd.Row(elem_classes="examples-section"):
|
| 229 |
with antd.Col(span=24):
|
|
@@ -232,8 +192,12 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 232 |
for idx, demo in enumerate(DEMO_LIST):
|
| 233 |
with antd.Col(span=8):
|
| 234 |
with antd.Card(hoverable=True) as demoCard:
|
| 235 |
-
antd.CardMeta(title=f
|
| 236 |
-
demoCard.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
# Modal과 Drawer 컴포넌트들
|
| 239 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
|
@@ -247,34 +211,64 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 247 |
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 248 |
|
| 249 |
# 버튼 이벤트 핸들러
|
| 250 |
-
settingPromptBtn.click(
|
| 251 |
-
open=True),
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
btn.click(
|
| 267 |
-
generation_code,
|
| 268 |
inputs=[input, setting, history],
|
| 269 |
outputs=[code_output, history, sandbox, state_tab, code_drawer]
|
| 270 |
)
|
| 271 |
|
| 272 |
-
clear_btn.click(
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
if __name__ == "__main__":
|
| 276 |
-
demo.launch(
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
| 183 |
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
| 184 |
with antd.Tabs.Item(key="render"):
|
| 185 |
sandbox = gr.HTML(elem_classes="html_content")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
# Examples 섹션
|
| 188 |
with antd.Row(elem_classes="examples-section"):
|
| 189 |
with antd.Col(span=24):
|
|
|
|
| 192 |
for idx, demo in enumerate(DEMO_LIST):
|
| 193 |
with antd.Col(span=8):
|
| 194 |
with antd.Card(hoverable=True) as demoCard:
|
| 195 |
+
antd.CardMeta(title=demo.get('title', f'Example {idx + 1}'))
|
| 196 |
+
demoCard.click(
|
| 197 |
+
fn=lambda x, i=idx: DEMO_LIST[i]['description'],
|
| 198 |
+
inputs=[gr.State(None)], # 더미 입력 추가
|
| 199 |
+
outputs=[input]
|
| 200 |
+
)
|
| 201 |
|
| 202 |
# Modal과 Drawer 컴포넌트들
|
| 203 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
|
|
|
| 211 |
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 212 |
|
| 213 |
# 버튼 이벤트 핸들러
|
| 214 |
+
settingPromptBtn.click(
|
| 215 |
+
fn=lambda: gr.update(open=True),
|
| 216 |
+
inputs=[],
|
| 217 |
+
outputs=[system_prompt_modal]
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
system_prompt_modal.ok(
|
| 221 |
+
fn=lambda x: ({"system": x}, gr.update(open=False)),
|
| 222 |
+
inputs=[systemPromptInput],
|
| 223 |
+
outputs=[setting, system_prompt_modal]
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
system_prompt_modal.cancel(
|
| 227 |
+
fn=lambda: gr.update(open=False),
|
| 228 |
+
inputs=[],
|
| 229 |
+
outputs=[system_prompt_modal]
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
codeBtn.click(
|
| 233 |
+
fn=lambda: gr.update(open=True),
|
| 234 |
+
inputs=[],
|
| 235 |
+
outputs=[code_drawer]
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
code_drawer.close(
|
| 239 |
+
fn=lambda: gr.update(open=False),
|
| 240 |
+
inputs=[],
|
| 241 |
+
outputs=[code_drawer]
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
historyBtn.click(
|
| 245 |
+
fn=history_render,
|
| 246 |
+
inputs=[history],
|
| 247 |
+
outputs=[history_drawer, history_output]
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
history_drawer.close(
|
| 251 |
+
fn=lambda: gr.update(open=False),
|
| 252 |
+
inputs=[],
|
| 253 |
+
outputs=[history_drawer]
|
| 254 |
+
)
|
| 255 |
|
| 256 |
btn.click(
|
| 257 |
+
fn=generation_code,
|
| 258 |
inputs=[input, setting, history],
|
| 259 |
outputs=[code_output, history, sandbox, state_tab, code_drawer]
|
| 260 |
)
|
| 261 |
|
| 262 |
+
clear_btn.click(
|
| 263 |
+
fn=clear_history,
|
| 264 |
+
inputs=[],
|
| 265 |
+
outputs=[history]
|
| 266 |
+
)
|
| 267 |
|
| 268 |
if __name__ == "__main__":
|
| 269 |
+
demo.launch(
|
| 270 |
+
server_name="0.0.0.0",
|
| 271 |
+
server_port=7860,
|
| 272 |
+
share=False,
|
| 273 |
+
show_error=True
|
| 274 |
+
)
|