Spaces:
Running
Running
File size: 3,454 Bytes
f18a2c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import gradio as gr
import modelscope_studio.components.antd as antd
import modelscope_studio.components.antdx as antdx
import modelscope_studio.components.base as ms
def item_click(e: gr.EventData):
payload = e._data["payload"]
gr.Info("You clicked on item " + payload[0]["data"]["key"])
default_vertical = False
default_wrap = False
with gr.Blocks() as demo:
with ms.Application():
with antdx.XProvider():
vertical = antd.Switch(value=default_vertical,
checked_children="Vertical",
un_checked_children="Horizontal")
wrap = antd.Switch(value=default_wrap,
checked_children="Wrap",
un_checked_children="No Wrap")
with antdx.Prompts(
title="✨ Inspirational Sparks and Marvelous Tips",
wrap=default_wrap,
vertical=default_vertical) as prompts:
with antdx.Prompts.Item(
key='1',
label='Ignite Your Creativity',
description='Got any sparks for a new project?',
disabled=True):
with ms.Slot("icon"):
antd.Icon("BulbOutlined",
elem_style={"color": '#FFD700'})
with antdx.Prompts.Item(
key='2',
label='Uncover Background Info',
description=
'Help me understand the background of this topic.',
):
with ms.Slot("icon"):
antd.Icon("InfoCircleOutlined",
elem_style={"color": '#1890FF'})
with antdx.Prompts.Item(
key='3',
label='Efficiency Boost Battle',
description='How can I work faster and better?',
):
with ms.Slot("icon"):
antd.Icon("RocketOutlined",
elem_style={"color": '#722ED1'})
with antdx.Prompts.Item(
key='4',
label='Tell me a Joke',
description=
'Why do not ants get sick? Because they have tiny ant-bodies!',
):
with ms.Slot("icon"):
antd.Icon("SmileOutlined",
elem_style={"color": '#52C41A'})
with antdx.Prompts.Item(
key='5',
label='Common Issue Solutions',
description=
'How to solve common issues? Share some tips!',
):
with ms.Slot("icon"):
antd.Icon("WarningOutlined",
elem_style={"color": '#FF4D4F'})
prompts.item_click(fn=item_click)
vertical.change(fn=lambda x: gr.update(vertical=x),
inputs=[vertical],
outputs=[prompts])
wrap.change(fn=lambda x: gr.update(wrap=x),
inputs=[wrap],
outputs=[prompts])
if __name__ == "__main__":
demo.queue().launch()
|