Update app.py
Browse files
app.py
CHANGED
@@ -143,10 +143,11 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
143 |
except Exception as e:
|
144 |
raise ValueError(f'Error calling Claude API: {str(e)}')
|
145 |
|
|
|
146 |
with ms.Application() as app:
|
147 |
with antd.ConfigProvider():
|
148 |
-
# ๋ฉ์ธ
|
149 |
-
with antd.Row(gutter=[32, 12]
|
150 |
# ์ข์ธก ํจ๋
|
151 |
with antd.Col(span=24, md=8):
|
152 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
@@ -165,109 +166,71 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
165 |
btn = antd.Button("send", type="primary", size="large")
|
166 |
clear_btn = antd.Button("clear history", type="default", size="large")
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
# ์ฐ์ธก ํจ๋
|
169 |
with antd.Col(span=24, md=16):
|
170 |
-
# Setting ๋ฒํผ๋ค์ ์ฐ์ธก ์๋จ์ ๋ณ๋๋ก ๋ฐฐ์น
|
171 |
-
with antd.Row(justify="end", elem_classes="setting-buttons-row"):
|
172 |
-
settingPromptBtn = antd.Button("โ๏ธ set system Prompt", type="default")
|
173 |
-
codeBtn = antd.Button("๐งโ๐ป view code", type="default")
|
174 |
-
historyBtn = antd.Button("๐ history", type="default")
|
175 |
-
|
176 |
-
# ์น ์ถ๋ ฅ ํจ๋
|
177 |
with ms.Div(elem_classes="right_panel"):
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
179 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
180 |
with antd.Tabs.Item(key="empty"):
|
181 |
empty = antd.Empty(description="empty input", elem_classes="right_content")
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
|
187 |
-
# Examples
|
188 |
-
with antd.Row(elem_classes="examples-section"):
|
189 |
with antd.Col(span=24):
|
190 |
antd.Divider("examples")
|
191 |
-
with antd.Row():
|
192 |
-
|
193 |
-
with antd.Col(span=8):
|
194 |
-
with antd.Card(hoverable=True) as demoCard:
|
195 |
-
antd.CardMeta(
|
196 |
-
demoCard.click(
|
197 |
-
|
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:
|
204 |
-
systemPromptInput = antd.InputTextarea(
|
205 |
-
SystemPrompt, auto_size=True)
|
206 |
-
|
207 |
-
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
208 |
-
code_output = legacy.Markdown()
|
209 |
-
|
210 |
-
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
211 |
-
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
212 |
-
|
213 |
# ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
214 |
-
settingPromptBtn.click(
|
215 |
-
|
216 |
-
|
217 |
-
outputs=[system_prompt_modal]
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
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 |
-
|
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 |
|
269 |
if __name__ == "__main__":
|
270 |
-
demo
|
271 |
-
with demo:
|
272 |
-
app
|
273 |
-
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
143 |
except Exception as e:
|
144 |
raise ValueError(f'Error calling Claude API: {str(e)}')
|
145 |
|
146 |
+
|
147 |
with ms.Application() as app:
|
148 |
with antd.ConfigProvider():
|
149 |
+
# ๋ฉ์ธ ์ปจํ
์ธ ๋ฅผ ์ํ Row
|
150 |
+
with antd.Row(gutter=[32, 12]) as layout:
|
151 |
# ์ข์ธก ํจ๋
|
152 |
with antd.Col(span=24, md=8):
|
153 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
|
|
166 |
btn = antd.Button("send", type="primary", size="large")
|
167 |
clear_btn = antd.Button("clear history", type="default", size="large")
|
168 |
|
169 |
+
# Modal๊ณผ Drawer ์ปดํฌ๋ํธ๋ค
|
170 |
+
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
171 |
+
systemPromptInput = antd.InputTextarea(
|
172 |
+
SystemPrompt, auto_size=True)
|
173 |
+
|
174 |
+
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
175 |
+
code_output = legacy.Markdown()
|
176 |
+
|
177 |
+
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
178 |
+
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
179 |
+
|
180 |
# ์ฐ์ธก ํจ๋
|
181 |
with antd.Col(span=24, md=16):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
with ms.Div(elem_classes="right_panel"):
|
183 |
+
with antd.Flex(gap="small", elem_classes="setting-buttons"):
|
184 |
+
settingPromptBtn = antd.Button(
|
185 |
+
"โ๏ธ set system Prompt", type="default")
|
186 |
+
codeBtn = antd.Button("๐งโ๐ป view code", type="default")
|
187 |
+
historyBtn = antd.Button("๐ history", type="default")
|
188 |
+
|
189 |
gr.HTML('<div class="render_header"><span class="header_btn"></span><span class="header_btn"></span><span class="header_btn"></span></div>')
|
190 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
191 |
with antd.Tabs.Item(key="empty"):
|
192 |
empty = antd.Empty(description="empty input", elem_classes="right_content")
|
193 |
+
with antd.Tabs.Item(key="loading"):
|
194 |
+
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
195 |
+
with antd.Tabs.Item(key="render"):
|
196 |
+
sandbox = gr.HTML(elem_classes="html_content")
|
197 |
|
198 |
+
# Examples ์น์
์ ๋ณ๋์ Row๋ก ์ถ๊ฐ (์ ์ฒด ํ๋ฉด ํ๋จ)
|
199 |
+
with antd.Row(gutter=[0, 24], elem_classes="examples-section"):
|
200 |
with antd.Col(span=24):
|
201 |
antd.Divider("examples")
|
202 |
+
with antd.Row(gutter=[16, 16]):
|
203 |
+
with ms.Each(DEMO_LIST):
|
204 |
+
with antd.Col(span=8): # ํ ์ค์ 3๊ฐ์ฉ (24/3 = 8)
|
205 |
+
with antd.Card(hoverable=True, as_item="card") as demoCard:
|
206 |
+
antd.CardMeta()
|
207 |
+
demoCard.click(demo_card_click, outputs=[input])
|
208 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
# ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
210 |
+
settingPromptBtn.click(lambda: gr.update(
|
211 |
+
open=True), inputs=[], outputs=[system_prompt_modal])
|
212 |
+
system_prompt_modal.ok(lambda input: ({"system": input}, gr.update(
|
213 |
+
open=False)), inputs=[systemPromptInput], outputs=[setting, system_prompt_modal])
|
214 |
+
system_prompt_modal.cancel(lambda: gr.update(
|
215 |
+
open=False), outputs=[system_prompt_modal])
|
216 |
+
|
217 |
+
codeBtn.click(lambda: gr.update(open=True),
|
218 |
+
inputs=[], outputs=[code_drawer])
|
219 |
+
code_drawer.close(lambda: gr.update(
|
220 |
+
open=False), inputs=[], outputs=[code_drawer])
|
221 |
+
|
222 |
+
historyBtn.click(history_render, inputs=[history], outputs=[history_drawer, history_output])
|
223 |
+
history_drawer.close(lambda: gr.update(
|
224 |
+
open=False), inputs=[], outputs=[history_drawer])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
btn.click(
|
227 |
+
generation_code,
|
228 |
inputs=[input, setting, history],
|
229 |
outputs=[code_output, history, sandbox, state_tab, code_drawer]
|
230 |
)
|
231 |
|
232 |
+
clear_btn.click(clear_history, inputs=[], outputs=[history])
|
|
|
|
|
|
|
|
|
233 |
|
234 |
|
235 |
if __name__ == "__main__":
|
236 |
+
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
|
|
|