Spaces:
Running
Running
update
Browse files
app.py
CHANGED
|
@@ -187,6 +187,7 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 187 |
with antd.Col(span=24, md=8):
|
| 188 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 189 |
gr.LoginButton()
|
|
|
|
| 190 |
header = gr.HTML("""
|
| 191 |
<div class="left_header">
|
| 192 |
<img src="https://huggingface.co/spaces/akhaliq/anycoder/resolve/main/Animated_Logo_Video_Ready.gif" width="200px" />
|
|
@@ -194,23 +195,23 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 194 |
</div>
|
| 195 |
""")
|
| 196 |
input = antd.InputTextarea(
|
| 197 |
-
size="large", allow_clear=True, placeholder="Please enter what kind of application you want")
|
| 198 |
-
btn = antd.Button("send", type="primary", size="large")
|
| 199 |
-
clear_btn = antd.Button("clear history", type="default", size="large")
|
| 200 |
|
| 201 |
-
antd.Divider("examples")
|
| 202 |
-
with antd.Flex(gap="small", wrap=True):
|
| 203 |
for i, demo_item in enumerate(DEMO_LIST):
|
| 204 |
with antd.Card(hoverable=True, title=demo_item["title"]) as demoCard:
|
| 205 |
antd.CardMeta(description=demo_item["description"])
|
| 206 |
demoCard.click(lambda e, idx=i: DEMO_LIST[idx]['description'], outputs=[input])
|
| 207 |
|
| 208 |
-
antd.Divider("setting")
|
| 209 |
-
with antd.Flex(gap="small", wrap=True):
|
| 210 |
settingPromptBtn = antd.Button(
|
| 211 |
-
"βοΈ set system Prompt", type="default")
|
| 212 |
-
codeBtn = antd.Button("π§βπ» view code", type="default")
|
| 213 |
-
historyBtn = antd.Button("π history", type="default")
|
| 214 |
|
| 215 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
| 216 |
systemPromptInput = antd.InputTextarea(
|
|
@@ -249,6 +250,32 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 249 |
with antd.Tabs.Item(key="loading"):
|
| 250 |
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
def generation_code(query: Optional[str], _setting: Dict[str, str], _history: Optional[History], profile: gr.OAuthProfile | None):
|
| 253 |
if profile is None:
|
| 254 |
return (
|
|
@@ -312,5 +339,21 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 312 |
|
| 313 |
clear_btn.click(clear_history, inputs=[], outputs=[history])
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
if __name__ == "__main__":
|
| 316 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
|
| 187 |
with antd.Col(span=24, md=8):
|
| 188 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 189 |
gr.LoginButton()
|
| 190 |
+
login_message = gr.Markdown("", visible=False)
|
| 191 |
header = gr.HTML("""
|
| 192 |
<div class="left_header">
|
| 193 |
<img src="https://huggingface.co/spaces/akhaliq/anycoder/resolve/main/Animated_Logo_Video_Ready.gif" width="200px" />
|
|
|
|
| 195 |
</div>
|
| 196 |
""")
|
| 197 |
input = antd.InputTextarea(
|
| 198 |
+
size="large", allow_clear=True, placeholder="Please enter what kind of application you want", visible=False)
|
| 199 |
+
btn = antd.Button("send", type="primary", size="large", visible=False)
|
| 200 |
+
clear_btn = antd.Button("clear history", type="default", size="large", visible=False)
|
| 201 |
|
| 202 |
+
antd.Divider("examples", visible=False)
|
| 203 |
+
with antd.Flex(gap="small", wrap=True, visible=False) as examples_flex:
|
| 204 |
for i, demo_item in enumerate(DEMO_LIST):
|
| 205 |
with antd.Card(hoverable=True, title=demo_item["title"]) as demoCard:
|
| 206 |
antd.CardMeta(description=demo_item["description"])
|
| 207 |
demoCard.click(lambda e, idx=i: DEMO_LIST[idx]['description'], outputs=[input])
|
| 208 |
|
| 209 |
+
antd.Divider("setting", visible=False)
|
| 210 |
+
with antd.Flex(gap="small", wrap=True, visible=False) as setting_flex:
|
| 211 |
settingPromptBtn = antd.Button(
|
| 212 |
+
"βοΈ set system Prompt", type="default", visible=False)
|
| 213 |
+
codeBtn = antd.Button("π§βπ» view code", type="default", visible=False)
|
| 214 |
+
historyBtn = antd.Button("π history", type="default", visible=False)
|
| 215 |
|
| 216 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
| 217 |
systemPromptInput = antd.InputTextarea(
|
|
|
|
| 250 |
with antd.Tabs.Item(key="loading"):
|
| 251 |
loading = antd.Spin(True, tip="coding...", size="large", elem_classes="right_content")
|
| 252 |
|
| 253 |
+
def update_login_ui(profile: gr.OAuthProfile | None):
|
| 254 |
+
if profile is None:
|
| 255 |
+
return (
|
| 256 |
+
gr.update(value="**You must sign in with Hugging Face to use this app.**", visible=True),
|
| 257 |
+
gr.update(visible=False),
|
| 258 |
+
gr.update(visible=False),
|
| 259 |
+
gr.update(visible=False),
|
| 260 |
+
gr.update(visible=False),
|
| 261 |
+
gr.update(visible=False),
|
| 262 |
+
gr.update(visible=False),
|
| 263 |
+
gr.update(visible=False),
|
| 264 |
+
gr.update(visible=False),
|
| 265 |
+
)
|
| 266 |
+
else:
|
| 267 |
+
return (
|
| 268 |
+
gr.update(visible=False),
|
| 269 |
+
gr.update(visible=True),
|
| 270 |
+
gr.update(visible=True),
|
| 271 |
+
gr.update(visible=True),
|
| 272 |
+
gr.update(visible=True),
|
| 273 |
+
gr.update(visible=True),
|
| 274 |
+
gr.update(visible=True),
|
| 275 |
+
gr.update(visible=True),
|
| 276 |
+
gr.update(visible=True),
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
def generation_code(query: Optional[str], _setting: Dict[str, str], _history: Optional[History], profile: gr.OAuthProfile | None):
|
| 280 |
if profile is None:
|
| 281 |
return (
|
|
|
|
| 339 |
|
| 340 |
clear_btn.click(clear_history, inputs=[], outputs=[history])
|
| 341 |
|
| 342 |
+
demo.load(
|
| 343 |
+
update_login_ui,
|
| 344 |
+
inputs=None,
|
| 345 |
+
outputs=[
|
| 346 |
+
login_message,
|
| 347 |
+
input,
|
| 348 |
+
btn,
|
| 349 |
+
clear_btn,
|
| 350 |
+
examples_flex,
|
| 351 |
+
setting_flex,
|
| 352 |
+
settingPromptBtn,
|
| 353 |
+
codeBtn,
|
| 354 |
+
historyBtn,
|
| 355 |
+
]
|
| 356 |
+
)
|
| 357 |
+
|
| 358 |
if __name__ == "__main__":
|
| 359 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|