seawolf2357 commited on
Commit
25a4084
·
verified ·
1 Parent(s): 635a5d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -5
app.py CHANGED
@@ -106,14 +106,20 @@ with gr.Blocks(css_paths="app.css") as demo:
106
  antd.CardMeta()
107
  demoCard.click(demo_card_click, outputs=[input])
108
 
 
 
 
 
 
 
 
 
 
 
 
109
  with antd.Col(span=24, md=16):
110
  with ms.Div(elem_classes="right_panel"):
111
  # 우측 상단에 setting 버튼들 추가
112
- gr.HTML("""
113
- <div style="display: flex; justify-content: flex-end; gap: 8px; padding: 10px;">
114
- <div id="setting-buttons"></div>
115
- </div>
116
- """)
117
  with antd.Flex(gap="small", elem_classes="setting-buttons"):
118
  settingPromptBtn = antd.Button(
119
  "⚙️ set system Prompt", type="default")
@@ -129,6 +135,31 @@ with gr.Blocks(css_paths="app.css") as demo:
129
  with antd.Tabs.Item(key="render"):
130
  sandbox = gr.HTML(elem_classes="html_content")
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  def generation_code(query: Optional[str], _setting: Dict[str, str], _history: Optional[History]):
133
  if query is None:
134
  query = ''
 
106
  antd.CardMeta()
107
  demoCard.click(demo_card_click, outputs=[input])
108
 
109
+ # Modal과 Drawer 컴포넌트들
110
+ with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
111
+ systemPromptInput = antd.InputTextarea(
112
+ SystemPrompt, auto_size=True)
113
+
114
+ with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
115
+ code_output = legacy.Markdown()
116
+
117
+ with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
118
+ history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
119
+
120
  with antd.Col(span=24, md=16):
121
  with ms.Div(elem_classes="right_panel"):
122
  # 우측 상단에 setting 버튼들 추가
 
 
 
 
 
123
  with antd.Flex(gap="small", elem_classes="setting-buttons"):
124
  settingPromptBtn = antd.Button(
125
  "⚙️ set system Prompt", type="default")
 
135
  with antd.Tabs.Item(key="render"):
136
  sandbox = gr.HTML(elem_classes="html_content")
137
 
138
+ # 버튼 이벤트 핸들러
139
+ settingPromptBtn.click(lambda: gr.update(
140
+ open=True), inputs=[], outputs=[system_prompt_modal])
141
+ system_prompt_modal.ok(lambda input: ({"system": input}, gr.update(
142
+ open=False)), inputs=[systemPromptInput], outputs=[setting, system_prompt_modal])
143
+ system_prompt_modal.cancel(lambda: gr.update(
144
+ open=False), outputs=[system_prompt_modal])
145
+
146
+ codeBtn.click(lambda: gr.update(open=True),
147
+ inputs=[], outputs=[code_drawer])
148
+ code_drawer.close(lambda: gr.update(
149
+ open=False), inputs=[], outputs=[code_drawer])
150
+
151
+ historyBtn.click(history_render, inputs=[history], outputs=[history_drawer, history_output])
152
+ history_drawer.close(lambda: gr.update(
153
+ open=False), inputs=[], outputs=[history_drawer])
154
+
155
+ btn.click(
156
+ generation_code,
157
+ inputs=[input, setting, history],
158
+ outputs=[code_output, history, sandbox, state_tab, code_drawer]
159
+ )
160
+
161
+ clear_btn.click(clear_history, inputs=[], outputs=[history])
162
+
163
  def generation_code(query: Optional[str], _setting: Dict[str, str], _history: Optional[History]):
164
  if query is None:
165
  query = ''