Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -638,7 +638,9 @@ def create_main_interface():
|
|
| 638 |
print(f"Error executing code: {str(e)}")
|
| 639 |
return None, gr.update(active_key="empty")
|
| 640 |
|
| 641 |
-
|
|
|
|
|
|
|
| 642 |
with open('app.css', 'r', encoding='utf-8') as f:
|
| 643 |
custom_css = f.read()
|
| 644 |
|
|
@@ -676,111 +678,25 @@ def create_main_interface():
|
|
| 676 |
line-height: 1.5;
|
| 677 |
}
|
| 678 |
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
.app-window {
|
| 697 |
-
background: white;
|
| 698 |
-
border-radius: 10px;
|
| 699 |
-
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
| 700 |
-
width: 100%;
|
| 701 |
-
max-width: 1400px;
|
| 702 |
-
overflow: hidden;
|
| 703 |
-
}
|
| 704 |
-
|
| 705 |
-
.window-header {
|
| 706 |
-
background: #f0f0f0;
|
| 707 |
-
padding: 12px 16px;
|
| 708 |
-
display: flex;
|
| 709 |
-
align-items: center;
|
| 710 |
-
border-bottom: 1px solid #e0e0e0;
|
| 711 |
-
}
|
| 712 |
-
|
| 713 |
-
.window-controls {
|
| 714 |
-
display: flex;
|
| 715 |
-
gap: 8px;
|
| 716 |
-
}
|
| 717 |
-
|
| 718 |
-
.control {
|
| 719 |
-
width: 12px;
|
| 720 |
-
height: 12px;
|
| 721 |
-
border-radius: 50%;
|
| 722 |
-
cursor: pointer;
|
| 723 |
-
}
|
| 724 |
-
|
| 725 |
-
.control.close { background: #ff5f57; }
|
| 726 |
-
.control.minimize { background: #febc2e; }
|
| 727 |
-
.control.maximize { background: #28c840; }
|
| 728 |
-
|
| 729 |
-
.window-title {
|
| 730 |
-
flex: 1;
|
| 731 |
-
text-align: center;
|
| 732 |
-
color: #333;
|
| 733 |
-
font-size: 14px;
|
| 734 |
-
font-weight: 500;
|
| 735 |
-
}
|
| 736 |
-
|
| 737 |
-
.main-content {
|
| 738 |
-
display: flex;
|
| 739 |
-
height: calc(100vh - 100px);
|
| 740 |
-
}
|
| 741 |
-
|
| 742 |
-
.left-panel {
|
| 743 |
-
width: 40%;
|
| 744 |
-
border-right: 1px solid #e0e0e0;
|
| 745 |
-
padding: 20px;
|
| 746 |
-
display: flex;
|
| 747 |
-
flex-direction: column;
|
| 748 |
-
}
|
| 749 |
-
|
| 750 |
-
.right-panel {
|
| 751 |
-
width: 60%;
|
| 752 |
-
background: #fff;
|
| 753 |
-
position: relative;
|
| 754 |
-
}
|
| 755 |
-
|
| 756 |
-
.input-area {
|
| 757 |
-
background: #f8f9fa;
|
| 758 |
-
border-radius: 10px;
|
| 759 |
-
padding: 20px;
|
| 760 |
-
margin-top: 20px;
|
| 761 |
-
}
|
| 762 |
-
|
| 763 |
-
.button-group {
|
| 764 |
-
display: flex;
|
| 765 |
-
gap: 10px;
|
| 766 |
-
margin-top: 20px;
|
| 767 |
-
}
|
| 768 |
-
|
| 769 |
-
.custom-button {
|
| 770 |
-
background: #007aff;
|
| 771 |
-
color: white;
|
| 772 |
-
border: none;
|
| 773 |
-
padding: 10px 20px;
|
| 774 |
-
border-radius: 6px;
|
| 775 |
-
cursor: pointer;
|
| 776 |
-
transition: all 0.2s;
|
| 777 |
-
}
|
| 778 |
-
|
| 779 |
-
.custom-button:hover {
|
| 780 |
-
background: #0056b3;
|
| 781 |
-
}
|
| 782 |
-
""", theme=theme)
|
| 783 |
|
|
|
|
| 784 |
|
| 785 |
with demo:
|
| 786 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
|
@@ -792,200 +708,37 @@ def create_main_interface():
|
|
| 792 |
#NEW - 검색 모드 상태 추가
|
| 793 |
search_mode = gr.State(False)
|
| 794 |
|
| 795 |
-
|
| 796 |
-
|
| 797 |
with ms.Application() as app:
|
| 798 |
with antd.ConfigProvider():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 799 |
|
| 800 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 801 |
-
|
| 802 |
-
<div class="thinking-container">
|
| 803 |
-
<style>
|
| 804 |
-
.custom-textarea {
|
| 805 |
-
background: #f8f9fa !important;
|
| 806 |
-
border: 1px solid #e0e0e0 !important;
|
| 807 |
-
border-radius: 10px !important;
|
| 808 |
-
padding: 15px !important;
|
| 809 |
-
min-height: 150px !important;
|
| 810 |
-
font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 811 |
-
}
|
| 812 |
-
|
| 813 |
-
.custom-textarea:focus {
|
| 814 |
-
border-color: #007aff !important;
|
| 815 |
-
box-shadow: 0 0 0 2px rgba(0,122,255,0.2) !important;
|
| 816 |
-
}
|
| 817 |
-
|
| 818 |
-
.thinking-container {
|
| 819 |
-
text-align: center;
|
| 820 |
-
padding: 20px;
|
| 821 |
-
background: #f8f9fa;
|
| 822 |
-
border-radius: 15px;
|
| 823 |
-
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 824 |
-
}
|
| 825 |
-
|
| 826 |
-
.progress-bar {
|
| 827 |
-
width: 100%;
|
| 828 |
-
height: 4px;
|
| 829 |
-
background: #e9ecef;
|
| 830 |
-
border-radius: 4px;
|
| 831 |
-
margin: 20px 0;
|
| 832 |
-
overflow: hidden;
|
| 833 |
-
}
|
| 834 |
-
|
| 835 |
-
.progress-bar-inner {
|
| 836 |
-
width: 30%;
|
| 837 |
-
height: 100%;
|
| 838 |
-
background: linear-gradient(90deg, #007aff, #28c840);
|
| 839 |
-
animation: progress 2s ease-in-out infinite;
|
| 840 |
-
}
|
| 841 |
-
|
| 842 |
-
.thinking-icon {
|
| 843 |
-
font-size: 48px;
|
| 844 |
-
margin: 20px 0;
|
| 845 |
-
animation: bounce 1s ease infinite;
|
| 846 |
-
}
|
| 847 |
-
|
| 848 |
-
.tip-box {
|
| 849 |
-
background: white;
|
| 850 |
-
padding: 20px;
|
| 851 |
-
border-radius: 10px;
|
| 852 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 853 |
-
margin: 20px 0;
|
| 854 |
-
transition: all 0.3s ease;
|
| 855 |
-
}
|
| 856 |
-
|
| 857 |
-
.status-text {
|
| 858 |
-
color: #007aff;
|
| 859 |
-
font-size: 18px;
|
| 860 |
-
margin: 15px 0;
|
| 861 |
-
animation: fade 1.5s ease infinite;
|
| 862 |
-
}
|
| 863 |
-
|
| 864 |
-
.icon-grid {
|
| 865 |
-
display: grid;
|
| 866 |
-
grid-template-columns: repeat(4, 1fr);
|
| 867 |
-
gap: 15px;
|
| 868 |
-
margin: 20px 0;
|
| 869 |
-
}
|
| 870 |
-
|
| 871 |
-
.icon-item {
|
| 872 |
-
padding: 10px;
|
| 873 |
-
background: rgba(0,122,255,0.1);
|
| 874 |
-
border-radius: 8px;
|
| 875 |
-
animation: pulse 2s ease infinite;
|
| 876 |
-
}
|
| 877 |
-
|
| 878 |
-
@keyframes progress {
|
| 879 |
-
0% { transform: translateX(-100%); }
|
| 880 |
-
100% { transform: translateX(400%); }
|
| 881 |
-
}
|
| 882 |
-
|
| 883 |
-
@keyframes bounce {
|
| 884 |
-
0%, 100% { transform: translateY(0); }
|
| 885 |
-
50% { transform: translateY(-10px); }
|
| 886 |
-
}
|
| 887 |
-
|
| 888 |
-
@keyframes fade {
|
| 889 |
-
0%, 100% { opacity: 1; }
|
| 890 |
-
50% { opacity: 0.6; }
|
| 891 |
-
}
|
| 892 |
-
|
| 893 |
-
@keyframes pulse {
|
| 894 |
-
0% { transform: scale(1); }
|
| 895 |
-
50% { transform: scale(1.05); }
|
| 896 |
-
100% { transform: scale(1); }
|
| 897 |
-
}
|
| 898 |
-
</style>
|
| 899 |
-
|
| 900 |
-
<div class="thinking-icon">🎨</div>
|
| 901 |
-
<div class="status-text">Creating Your Visualization...</div>
|
| 902 |
-
<div class="progress-bar">
|
| 903 |
-
<div class="progress-bar-inner"></div>
|
| 904 |
-
</div>
|
| 905 |
-
<div class="icon-grid">
|
| 906 |
-
<div class="icon-item">📊</div>
|
| 907 |
-
<div class="icon-item">🎯</div>
|
| 908 |
-
<div class="icon-item">💡</div>
|
| 909 |
-
<div class="icon-item">✨</div>
|
| 910 |
-
</div>
|
| 911 |
-
<div class="tip-box">
|
| 912 |
-
<h3 style="color: #007aff; margin-bottom: 10px;">Did You Know?</h3>
|
| 913 |
-
<div id="tip-content" style="font-size: 16px; line-height: 1.6;"></div>
|
| 914 |
-
</div>
|
| 915 |
-
|
| 916 |
-
<script>
|
| 917 |
-
const tips = [
|
| 918 |
-
"MOUSE-I is creating responsive and interactive visualizations! 📊",
|
| 919 |
-
"We're applying modern design principles for the best user experience! 🎨",
|
| 920 |
-
"Your content will be optimized for all devices! 📱",
|
| 921 |
-
"Adding engaging animations to bring your data to life! ✨",
|
| 922 |
-
"Crafting a beautiful presentation just for you! 🎯",
|
| 923 |
-
"Implementing interactive elements for better engagement! 🎮",
|
| 924 |
-
"Optimizing colors and layout for visual appeal! 🎪",
|
| 925 |
-
"Creating smooth transitions and animations! 🌟"
|
| 926 |
-
];
|
| 927 |
-
|
| 928 |
-
function updateTip() {
|
| 929 |
-
const tipElement = document.getElementById('tip-content');
|
| 930 |
-
if (tipElement) {
|
| 931 |
-
const randomTip = tips[Math.floor(Math.random() * tips.length)];
|
| 932 |
-
tipElement.innerHTML = randomTip;
|
| 933 |
-
tipElement.style.opacity = 0;
|
| 934 |
-
setTimeout(() => {
|
| 935 |
-
tipElement.style.transition = 'opacity 0.5s ease';
|
| 936 |
-
tipElement.style.opacity = 1;
|
| 937 |
-
}, 100);
|
| 938 |
-
}
|
| 939 |
-
}
|
| 940 |
-
|
| 941 |
-
updateTip();
|
| 942 |
-
setInterval(updateTip, 3000);
|
| 943 |
-
</script>
|
| 944 |
-
</div>
|
| 945 |
-
""")
|
| 946 |
code_output = legacy.Markdown(visible=False)
|
| 947 |
|
| 948 |
-
|
| 949 |
-
# 메인 컨텐츠를 위한 Row
|
| 950 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 951 |
# 좌측 패널
|
| 952 |
with antd.Col(span=24, md=8):
|
| 953 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 954 |
-
|
| 955 |
-
header = gr.HTML("""
|
| 956 |
-
<div class="window-frame">
|
| 957 |
-
<div class="window-header">
|
| 958 |
-
<div class="window-controls">
|
| 959 |
-
<div class="control close"></div>
|
| 960 |
-
<div class="control minimize"></div>
|
| 961 |
-
<div class="control maximize"></div>
|
| 962 |
-
</div>
|
| 963 |
-
<div class="window-title">
|
| 964 |
-
<div class="window-address">
|
| 965 |
-
<div class="secure-icon">🔒</div>
|
| 966 |
-
<div class="url-bar">https://VIDraft-mouse-chat.hf.space</div>
|
| 967 |
-
</div>
|
| 968 |
-
</div>
|
| 969 |
-
</div>
|
| 970 |
-
<div class="app-content">
|
| 971 |
-
<img src="data:image/gif;base64,{}" width="360px" />
|
| 972 |
-
<h1 class="app-title">MOUSE-Chat Visual AI</h1>
|
| 973 |
-
<p class="app-description">Creates visualized web pages from text input, and when you include keywords like "image:", "그림:", or "image:" in your input, it automatically generates AI images based on the description and incorporates them into the web page.
|
| 974 |
-
Use the "Generate" button for basic creation, "Enhance" button for prompt improvement, "Share" button to deploy results to the web, and input like "image: a dog playing in the park" to create results containing both text and generated images.</p>
|
| 975 |
-
</div>
|
| 976 |
-
</div>
|
| 977 |
-
""".format(get_image_base64('mouse.gif')))
|
| 978 |
|
| 979 |
# 입력 영역
|
| 980 |
input = antd.InputTextarea(
|
| 981 |
size="large",
|
| 982 |
allow_clear=True,
|
| 983 |
placeholder=get_random_placeholder(),
|
| 984 |
-
elem_classes="custom-textarea"
|
| 985 |
-
|
| 986 |
)
|
| 987 |
-
|
| 988 |
-
|
|
|
|
| 989 |
with antd.Flex(gap="small", justify="flex-start"):
|
| 990 |
btn = antd.Button(
|
| 991 |
"Generate",
|
|
@@ -1006,39 +759,11 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1006 |
elem_classes="share-btn"
|
| 1007 |
)
|
| 1008 |
|
| 1009 |
-
|
| 1010 |
deploy_result = gr.HTML(
|
| 1011 |
label="Share Result",
|
| 1012 |
elem_classes="deploy-result"
|
| 1013 |
)
|
| 1014 |
|
| 1015 |
-
|
| 1016 |
-
# 버튼 이벤트 핸들러 수정
|
| 1017 |
-
btn.click(
|
| 1018 |
-
fn=lambda q, s, m: execute_search_and_generate(q, s) if m else demo_instance.generation_code(q, s),
|
| 1019 |
-
inputs=[input, setting, search_mode],
|
| 1020 |
-
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 1021 |
-
).then(
|
| 1022 |
-
fn=update_placeholder,
|
| 1023 |
-
inputs=[],
|
| 1024 |
-
outputs=[input]
|
| 1025 |
-
)
|
| 1026 |
-
|
| 1027 |
-
#NEW - 검색 모드 토글 버튼 추가
|
| 1028 |
-
search_toggle = antd.Button(
|
| 1029 |
-
"Toggle Search Mode",
|
| 1030 |
-
type="default",
|
| 1031 |
-
size="large",
|
| 1032 |
-
elem_classes="search-toggle-btn"
|
| 1033 |
-
)
|
| 1034 |
-
|
| 1035 |
-
search_toggle.click(
|
| 1036 |
-
fn=lambda x: not x,
|
| 1037 |
-
inputs=[search_mode],
|
| 1038 |
-
outputs=[search_mode]
|
| 1039 |
-
)
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
# 우측 패널
|
| 1043 |
with antd.Col(span=24, md=16):
|
| 1044 |
with ms.Div(elem_classes="right_panel"):
|
|
@@ -1061,9 +786,7 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1061 |
with antd.Tabs.Item(key="empty"):
|
| 1062 |
empty = antd.Empty(
|
| 1063 |
description="Enter your question to begin",
|
| 1064 |
-
|
| 1065 |
-
elem_classes="right_content empty-content" # style 대신 class 사용
|
| 1066 |
-
|
| 1067 |
)
|
| 1068 |
|
| 1069 |
with antd.Tabs.Item(key="loading"):
|
|
@@ -1076,11 +799,11 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1076 |
|
| 1077 |
with antd.Tabs.Item(key="render"):
|
| 1078 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 1079 |
-
|
| 1080 |
|
|
|
|
| 1081 |
btn.click(
|
| 1082 |
-
demo_instance.generation_code,
|
| 1083 |
-
inputs=[input, setting],
|
| 1084 |
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 1085 |
).then(
|
| 1086 |
fn=update_placeholder,
|
|
@@ -1088,7 +811,6 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1088 |
outputs=[input]
|
| 1089 |
)
|
| 1090 |
|
| 1091 |
-
|
| 1092 |
boost_btn.click(
|
| 1093 |
fn=handle_boost,
|
| 1094 |
inputs=[input],
|
|
@@ -1121,6 +843,12 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1121 |
color: #28c840 !important;
|
| 1122 |
}
|
| 1123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1124 |
/* hover 효과 */
|
| 1125 |
.generate-btn:hover {
|
| 1126 |
background: #0056b3 !important;
|
|
@@ -1133,56 +861,9 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1133 |
.share-btn:hover {
|
| 1134 |
background: rgba(40,200,64,0.1) !important;
|
| 1135 |
}
|
| 1136 |
-
|
| 1137 |
-
.app-content {
|
| 1138 |
-
padding: 20px;
|
| 1139 |
-
text-align: center;
|
| 1140 |
-
}
|
| 1141 |
-
|
| 1142 |
-
.app-title {
|
| 1143 |
-
font-size: 24px;
|
| 1144 |
-
color: #333;
|
| 1145 |
-
margin: 20px 0 10px;
|
| 1146 |
-
font-weight: 600;
|
| 1147 |
-
}
|
| 1148 |
-
|
| 1149 |
-
.app-description {
|
| 1150 |
-
color: #666;
|
| 1151 |
-
font-size: 14px;
|
| 1152 |
-
margin-bottom: 30px;
|
| 1153 |
-
}
|
| 1154 |
-
|
| 1155 |
-
.deploy-result {
|
| 1156 |
-
margin-top: 20px;
|
| 1157 |
-
padding: 15px;
|
| 1158 |
-
background: #f8f9fa;
|
| 1159 |
-
border-radius: 8px;
|
| 1160 |
-
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 1161 |
-
}
|
| 1162 |
-
|
| 1163 |
-
.deploy-result a {
|
| 1164 |
-
color: #007aff;
|
| 1165 |
-
text-decoration: none;
|
| 1166 |
-
font-weight: 500;
|
| 1167 |
-
}
|
| 1168 |
-
|
| 1169 |
-
.deploy-result a:hover {
|
| 1170 |
-
text-decoration: underline;
|
| 1171 |
-
}
|
| 1172 |
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
.window-frame {
|
| 1176 |
-
border-radius: 0;
|
| 1177 |
-
}
|
| 1178 |
-
|
| 1179 |
-
.left-panel, .right-panel {
|
| 1180 |
-
width: 100%;
|
| 1181 |
-
}
|
| 1182 |
-
|
| 1183 |
-
.main-content {
|
| 1184 |
-
flex-direction: column;
|
| 1185 |
-
}
|
| 1186 |
}
|
| 1187 |
</style>
|
| 1188 |
""")
|
|
@@ -1192,10 +873,10 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1192 |
# 메인 실행 부분
|
| 1193 |
if __name__ == "__main__":
|
| 1194 |
try:
|
| 1195 |
-
demo_instance = Demo()
|
| 1196 |
-
demo = create_main_interface()
|
| 1197 |
demo.queue(
|
| 1198 |
-
default_concurrency_limit=20,
|
| 1199 |
status_update_rate=10,
|
| 1200 |
api_open=False
|
| 1201 |
).launch(
|
|
@@ -1206,4 +887,4 @@ if __name__ == "__main__":
|
|
| 1206 |
)
|
| 1207 |
except Exception as e:
|
| 1208 |
print(f"Initialization error: {e}")
|
| 1209 |
-
raise
|
|
|
|
| 638 |
print(f"Error executing code: {str(e)}")
|
| 639 |
return None, gr.update(active_key="empty")
|
| 640 |
|
| 641 |
+
|
| 642 |
+
|
| 643 |
+
# CSS 파일 내용을 직접 적용
|
| 644 |
with open('app.css', 'r', encoding='utf-8') as f:
|
| 645 |
custom_css = f.read()
|
| 646 |
|
|
|
|
| 678 |
line-height: 1.5;
|
| 679 |
}
|
| 680 |
|
| 681 |
+
.empty-content {
|
| 682 |
+
padding: 40px !important;
|
| 683 |
+
background: #f8f9fa !important;
|
| 684 |
+
border-radius: 10px !important;
|
| 685 |
+
margin: 20px !important;
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
.container {
|
| 689 |
+
background: #f0f0f0;
|
| 690 |
+
min-height: 100vh;
|
| 691 |
+
padding: 20px;
|
| 692 |
+
display: flex;
|
| 693 |
+
justify-content: center;
|
| 694 |
+
align-items: center;
|
| 695 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 696 |
+
}
|
| 697 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 698 |
|
| 699 |
+
demo = gr.Blocks(css=custom_css, theme=theme)
|
| 700 |
|
| 701 |
with demo:
|
| 702 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
|
|
|
| 708 |
#NEW - 검색 모드 상태 추가
|
| 709 |
search_mode = gr.State(False)
|
| 710 |
|
|
|
|
|
|
|
| 711 |
with ms.Application() as app:
|
| 712 |
with antd.ConfigProvider():
|
| 713 |
+
#NEW - 모드 선택 라디오 버튼 추가
|
| 714 |
+
with gr.Row():
|
| 715 |
+
mode = gr.Radio(
|
| 716 |
+
choices=["Generate", "Web Search"],
|
| 717 |
+
label="Mode",
|
| 718 |
+
value="Generate"
|
| 719 |
+
)
|
| 720 |
|
| 721 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 722 |
+
[이전 Drawer HTML 내용 유지]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
code_output = legacy.Markdown(visible=False)
|
| 724 |
|
| 725 |
+
# 메인 컨텐츠를 위한 Row
|
|
|
|
| 726 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 727 |
# 좌측 패널
|
| 728 |
with antd.Col(span=24, md=8):
|
| 729 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 730 |
+
[이전 헤더 HTML 내용 유지]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 731 |
|
| 732 |
# 입력 영역
|
| 733 |
input = antd.InputTextarea(
|
| 734 |
size="large",
|
| 735 |
allow_clear=True,
|
| 736 |
placeholder=get_random_placeholder(),
|
| 737 |
+
elem_classes="custom-textarea"
|
|
|
|
| 738 |
)
|
| 739 |
+
|
| 740 |
+
|
| 741 |
+
# 버튼 그룹
|
| 742 |
with antd.Flex(gap="small", justify="flex-start"):
|
| 743 |
btn = antd.Button(
|
| 744 |
"Generate",
|
|
|
|
| 759 |
elem_classes="share-btn"
|
| 760 |
)
|
| 761 |
|
|
|
|
| 762 |
deploy_result = gr.HTML(
|
| 763 |
label="Share Result",
|
| 764 |
elem_classes="deploy-result"
|
| 765 |
)
|
| 766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 767 |
# 우측 패널
|
| 768 |
with antd.Col(span=24, md=16):
|
| 769 |
with ms.Div(elem_classes="right_panel"):
|
|
|
|
| 786 |
with antd.Tabs.Item(key="empty"):
|
| 787 |
empty = antd.Empty(
|
| 788 |
description="Enter your question to begin",
|
| 789 |
+
elem_classes="right_content empty-content"
|
|
|
|
|
|
|
| 790 |
)
|
| 791 |
|
| 792 |
with antd.Tabs.Item(key="loading"):
|
|
|
|
| 799 |
|
| 800 |
with antd.Tabs.Item(key="render"):
|
| 801 |
sandbox = gr.HTML(elem_classes="html_content")
|
|
|
|
| 802 |
|
| 803 |
+
# 버튼 이벤트 핸들러
|
| 804 |
btn.click(
|
| 805 |
+
fn=lambda q, s, m: execute_search_and_generate(q, s) if m else demo_instance.generation_code(q, s),
|
| 806 |
+
inputs=[input, setting, search_mode],
|
| 807 |
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 808 |
).then(
|
| 809 |
fn=update_placeholder,
|
|
|
|
| 811 |
outputs=[input]
|
| 812 |
)
|
| 813 |
|
|
|
|
| 814 |
boost_btn.click(
|
| 815 |
fn=handle_boost,
|
| 816 |
inputs=[input],
|
|
|
|
| 843 |
color: #28c840 !important;
|
| 844 |
}
|
| 845 |
|
| 846 |
+
.search-toggle-btn {
|
| 847 |
+
border-radius: 8px !important;
|
| 848 |
+
border: 1px solid #4285f4 !important;
|
| 849 |
+
color: #4285f4 !important;
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
/* hover 효과 */
|
| 853 |
.generate-btn:hover {
|
| 854 |
background: #0056b3 !important;
|
|
|
|
| 861 |
.share-btn:hover {
|
| 862 |
background: rgba(40,200,64,0.1) !important;
|
| 863 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 864 |
|
| 865 |
+
.search-toggle-btn:hover {
|
| 866 |
+
background: rgba(66,133,244,0.1) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
}
|
| 868 |
</style>
|
| 869 |
""")
|
|
|
|
| 873 |
# 메인 실행 부분
|
| 874 |
if __name__ == "__main__":
|
| 875 |
try:
|
| 876 |
+
demo_instance = Demo()
|
| 877 |
+
demo = create_main_interface()
|
| 878 |
demo.queue(
|
| 879 |
+
default_concurrency_limit=20,
|
| 880 |
status_update_rate=10,
|
| 881 |
api_open=False
|
| 882 |
).launch(
|
|
|
|
| 887 |
)
|
| 888 |
except Exception as e:
|
| 889 |
print(f"Initialization error: {e}")
|
| 890 |
+
raise
|