Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -615,13 +615,17 @@ def create_main_interface():
|
|
615 |
Create a comprehensive visual response that incorporates relevant information from the search results.
|
616 |
"""
|
617 |
|
618 |
-
# 기존 generation_code 함수 호출
|
619 |
return demo_instance.generation_code(enhanced_prompt, setting)
|
620 |
-
|
621 |
except Exception as e:
|
622 |
print(f"Search error: {str(e)}")
|
623 |
-
|
624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
|
626 |
def execute_code(query: str):
|
627 |
if not query or query.strip() == '':
|
@@ -694,7 +698,25 @@ def create_main_interface():
|
|
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 |
|
@@ -715,26 +737,198 @@ def create_main_interface():
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
@@ -800,6 +994,24 @@ def create_main_interface():
|
|
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),
|
@@ -811,6 +1023,8 @@ def create_main_interface():
|
|
811 |
outputs=[input]
|
812 |
)
|
813 |
|
|
|
|
|
814 |
boost_btn.click(
|
815 |
fn=handle_boost,
|
816 |
inputs=[input],
|
|
|
615 |
Create a comprehensive visual response that incorporates relevant information from the search results.
|
616 |
"""
|
617 |
|
|
|
618 |
return demo_instance.generation_code(enhanced_prompt, setting)
|
|
|
619 |
except Exception as e:
|
620 |
print(f"Search error: {str(e)}")
|
621 |
+
return [
|
622 |
+
"",
|
623 |
+
None,
|
624 |
+
gr.update(active_key="error"),
|
625 |
+
gr.update(open=False)
|
626 |
+
]
|
627 |
+
|
628 |
+
|
629 |
|
630 |
def execute_code(query: str):
|
631 |
if not query or query.strip() == '':
|
|
|
698 |
align-items: center;
|
699 |
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
700 |
}
|
701 |
+
.mode-selector {
|
702 |
+
margin-bottom: 15px;
|
703 |
+
padding: 10px;
|
704 |
+
border-radius: 8px;
|
705 |
+
background: #f8f9fa;
|
706 |
+
}
|
707 |
+
|
708 |
+
.error-content {
|
709 |
+
padding: 20px;
|
710 |
+
background: #fff2f0;
|
711 |
+
border-radius: 8px;
|
712 |
+
border: 1px solid #ff4d4f;
|
713 |
+
}
|
714 |
+
|
715 |
+
.search-mode-active {
|
716 |
+
background-color: rgba(66,133,244,0.1);
|
717 |
+
}
|
718 |
+
"""
|
719 |
+
|
720 |
|
721 |
demo = gr.Blocks(css=custom_css, theme=theme)
|
722 |
|
|
|
737 |
mode = gr.Radio(
|
738 |
choices=["Generate", "Web Search"],
|
739 |
label="Mode",
|
740 |
+
value="Generate",
|
741 |
+
elem_classes="mode-selector"
|
742 |
)
|
743 |
|
744 |
+
|
745 |
+
|
746 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
747 |
+
gr.HTML("""
|
748 |
+
<div class="thinking-container">
|
749 |
+
<style>
|
750 |
+
.custom-textarea {
|
751 |
+
background: #f8f9fa !important;
|
752 |
+
border: 1px solid #e0e0e0 !important;
|
753 |
+
border-radius: 10px !important;
|
754 |
+
padding: 15px !important;
|
755 |
+
min-height: 150px !important;
|
756 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
|
757 |
+
}
|
758 |
+
|
759 |
+
.custom-textarea:focus {
|
760 |
+
border-color: #007aff !important;
|
761 |
+
box-shadow: 0 0 0 2px rgba(0,122,255,0.2) !important;
|
762 |
+
}
|
763 |
+
|
764 |
+
.thinking-container {
|
765 |
+
text-align: center;
|
766 |
+
padding: 20px;
|
767 |
+
background: #f8f9fa;
|
768 |
+
border-radius: 15px;
|
769 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
770 |
+
}
|
771 |
+
|
772 |
+
.progress-bar {
|
773 |
+
width: 100%;
|
774 |
+
height: 4px;
|
775 |
+
background: #e9ecef;
|
776 |
+
border-radius: 4px;
|
777 |
+
margin: 20px 0;
|
778 |
+
overflow: hidden;
|
779 |
+
}
|
780 |
+
|
781 |
+
.progress-bar-inner {
|
782 |
+
width: 30%;
|
783 |
+
height: 100%;
|
784 |
+
background: linear-gradient(90deg, #007aff, #28c840);
|
785 |
+
animation: progress 2s ease-in-out infinite;
|
786 |
+
}
|
787 |
+
|
788 |
+
.thinking-icon {
|
789 |
+
font-size: 48px;
|
790 |
+
margin: 20px 0;
|
791 |
+
animation: bounce 1s ease infinite;
|
792 |
+
}
|
793 |
+
|
794 |
+
.tip-box {
|
795 |
+
background: white;
|
796 |
+
padding: 20px;
|
797 |
+
border-radius: 10px;
|
798 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
799 |
+
margin: 20px 0;
|
800 |
+
transition: all 0.3s ease;
|
801 |
+
}
|
802 |
+
|
803 |
+
.status-text {
|
804 |
+
color: #007aff;
|
805 |
+
font-size: 18px;
|
806 |
+
margin: 15px 0;
|
807 |
+
animation: fade 1.5s ease infinite;
|
808 |
+
}
|
809 |
+
|
810 |
+
.icon-grid {
|
811 |
+
display: grid;
|
812 |
+
grid-template-columns: repeat(4, 1fr);
|
813 |
+
gap: 15px;
|
814 |
+
margin: 20px 0;
|
815 |
+
}
|
816 |
+
|
817 |
+
.icon-item {
|
818 |
+
padding: 10px;
|
819 |
+
background: rgba(0,122,255,0.1);
|
820 |
+
border-radius: 8px;
|
821 |
+
animation: pulse 2s ease infinite;
|
822 |
+
}
|
823 |
+
|
824 |
+
@keyframes progress {
|
825 |
+
0% { transform: translateX(-100%); }
|
826 |
+
100% { transform: translateX(400%); }
|
827 |
+
}
|
828 |
+
|
829 |
+
@keyframes bounce {
|
830 |
+
0%, 100% { transform: translateY(0); }
|
831 |
+
50% { transform: translateY(-10px); }
|
832 |
+
}
|
833 |
+
|
834 |
+
@keyframes fade {
|
835 |
+
0%, 100% { opacity: 1; }
|
836 |
+
50% { opacity: 0.6; }
|
837 |
+
}
|
838 |
+
|
839 |
+
@keyframes pulse {
|
840 |
+
0% { transform: scale(1); }
|
841 |
+
50% { transform: scale(1.05); }
|
842 |
+
100% { transform: scale(1); }
|
843 |
+
}
|
844 |
+
</style>
|
845 |
+
|
846 |
+
<div class="thinking-icon">🎨</div>
|
847 |
+
<div class="status-text">Creating Your Visualization...</div>
|
848 |
+
<div class="progress-bar">
|
849 |
+
<div class="progress-bar-inner"></div>
|
850 |
+
</div>
|
851 |
+
<div class="icon-grid">
|
852 |
+
<div class="icon-item">📊</div>
|
853 |
+
<div class="icon-item">🎯</div>
|
854 |
+
<div class="icon-item">💡</div>
|
855 |
+
<div class="icon-item">✨</div>
|
856 |
+
</div>
|
857 |
+
<div class="tip-box">
|
858 |
+
<h3 style="color: #007aff; margin-bottom: 10px;">Did You Know?</h3>
|
859 |
+
<div id="tip-content" style="font-size: 16px; line-height: 1.6;"></div>
|
860 |
+
</div>
|
861 |
+
|
862 |
+
<script>
|
863 |
+
const tips = [
|
864 |
+
"MOUSE-I is creating responsive and interactive visualizations! 📊",
|
865 |
+
"We're applying modern design principles for the best user experience! 🎨",
|
866 |
+
"Your content will be optimized for all devices! 📱",
|
867 |
+
"Adding engaging animations to bring your data to life! ✨",
|
868 |
+
"Crafting a beautiful presentation just for you! 🎯",
|
869 |
+
"Implementing interactive elements for better engagement! 🎮",
|
870 |
+
"Optimizing colors and layout for visual appeal! 🎪",
|
871 |
+
"Creating smooth transitions and animations! 🌟"
|
872 |
+
];
|
873 |
+
|
874 |
+
function updateTip() {
|
875 |
+
const tipElement = document.getElementById('tip-content');
|
876 |
+
if (tipElement) {
|
877 |
+
const randomTip = tips[Math.floor(Math.random() * tips.length)];
|
878 |
+
tipElement.innerHTML = randomTip;
|
879 |
+
tipElement.style.opacity = 0;
|
880 |
+
setTimeout(() => {
|
881 |
+
tipElement.style.transition = 'opacity 0.5s ease';
|
882 |
+
tipElement.style.opacity = 1;
|
883 |
+
}, 100);
|
884 |
+
}
|
885 |
+
}
|
886 |
+
|
887 |
+
updateTip();
|
888 |
+
setInterval(updateTip, 3000);
|
889 |
+
</script>
|
890 |
+
</div>
|
891 |
+
""")
|
892 |
code_output = legacy.Markdown(visible=False)
|
893 |
+
|
894 |
+
|
895 |
|
896 |
# 메인 컨텐츠를 위한 Row
|
897 |
with antd.Row(gutter=[32, 12]) as layout:
|
898 |
# 좌측 패널
|
899 |
with antd.Col(span=24, md=8):
|
900 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
901 |
+
header = gr.HTML("""
|
902 |
+
<div class="window-frame">
|
903 |
+
<div class="window-header">
|
904 |
+
<div class="window-controls">
|
905 |
+
<div class="control close"></div>
|
906 |
+
<div class="control minimize"></div>
|
907 |
+
<div class="control maximize"></div>
|
908 |
+
</div>
|
909 |
+
<div class="window-title">
|
910 |
+
<div class="window-address">
|
911 |
+
<div class="secure-icon">🔒</div>
|
912 |
+
<div class="url-bar">https://VIDraft-mouse-chat.hf.space</div>
|
913 |
+
</div>
|
914 |
+
</div>
|
915 |
+
</div>
|
916 |
+
<div class="app-content">
|
917 |
+
<img src="data:image/gif;base64,{}" width="360px" />
|
918 |
+
<h1 class="app-title">MOUSE-Chat Visual AI</h1>
|
919 |
+
<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.
|
920 |
+
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>
|
921 |
+
</div>
|
922 |
+
</div>
|
923 |
+
""".format(get_image_base64('mouse.gif')))
|
924 |
|
925 |
# 입력 영역
|
926 |
input = antd.InputTextarea(
|
927 |
size="large",
|
928 |
allow_clear=True,
|
929 |
placeholder=get_random_placeholder(),
|
930 |
+
elem_classes="custom-textarea" # style 대신 class 사용
|
931 |
+
|
932 |
)
|
933 |
|
934 |
|
|
|
994 |
with antd.Tabs.Item(key="render"):
|
995 |
sandbox = gr.HTML(elem_classes="html_content")
|
996 |
|
997 |
+
|
998 |
+
with antd.Tabs.Item(key="error"):
|
999 |
+
error = antd.Empty(
|
1000 |
+
description="An error occurred. Please try again.",
|
1001 |
+
elem_classes="right_content error-content"
|
1002 |
+
)
|
1003 |
+
|
1004 |
+
|
1005 |
+
# 여기에 추가 (들여쓰기 맞춤)
|
1006 |
+
mode.change(
|
1007 |
+
fn=lambda x: x == "Web Search",
|
1008 |
+
inputs=[mode],
|
1009 |
+
outputs=[search_mode]
|
1010 |
+
)
|
1011 |
+
|
1012 |
+
|
1013 |
+
|
1014 |
+
|
1015 |
# 버튼 이벤트 핸들러
|
1016 |
btn.click(
|
1017 |
fn=lambda q, s, m: execute_search_and_generate(q, s) if m else demo_instance.generation_code(q, s),
|
|
|
1023 |
outputs=[input]
|
1024 |
)
|
1025 |
|
1026 |
+
|
1027 |
+
|
1028 |
boost_btn.click(
|
1029 |
fn=handle_boost,
|
1030 |
inputs=[input],
|