Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -686,6 +686,8 @@ def get_random_placeholder():
|
|
| 686 |
def update_placeholder():
|
| 687 |
return gr.update(placeholder=get_random_placeholder())
|
| 688 |
|
|
|
|
|
|
|
| 689 |
def create_main_interface():
|
| 690 |
"""๋ฉ์ธ ์ธํฐํ์ด์ค ์์ฑ ํจ์"""
|
| 691 |
|
|
@@ -852,18 +854,13 @@ def create_main_interface():
|
|
| 852 |
""", theme=theme)
|
| 853 |
|
| 854 |
|
| 855 |
-
|
| 856 |
with demo:
|
| 857 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
| 858 |
with gr.Tab("Visual AI Assistant", elem_id="mouse-tab", elem_classes="mouse-tab"):
|
| 859 |
-
|
| 860 |
-
setting = gr.State({
|
| 861 |
-
"system": SystemPrompt,
|
| 862 |
-
})
|
| 863 |
|
| 864 |
with ms.Application() as app:
|
| 865 |
with antd.ConfigProvider():
|
| 866 |
-
|
| 867 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 868 |
gr.HTML("""
|
| 869 |
<div class="thinking-container">
|
|
@@ -1012,15 +1009,11 @@ def create_main_interface():
|
|
| 1012 |
""")
|
| 1013 |
code_output = legacy.Markdown(visible=False)
|
| 1014 |
|
| 1015 |
-
|
| 1016 |
-
# ๋ฉ์ธ ์ปจํ
์ธ ๋ฅผ ์ํ Row
|
| 1017 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 1018 |
# ์ข์ธก ํจ๋
|
| 1019 |
with antd.Col(span=24, md=8):
|
| 1020 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
# macOS ์คํ์ผ ์๋์ฐ ํค๋
|
| 1025 |
header = gr.HTML("""
|
| 1026 |
<div class="window-frame">
|
|
@@ -1046,29 +1039,31 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1046 |
</div>
|
| 1047 |
""".format(get_image_base64('mouse.gif')))
|
| 1048 |
|
| 1049 |
-
# ํ์ผ ์
๋ก๋ ์น์
|
| 1050 |
-
file_upload = gr.File(
|
| 1051 |
-
label="Upload Files (Images/Documents)",
|
| 1052 |
-
file_types=[".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp",
|
| 1053 |
-
".txt", ".pdf", ".docx", ".rtf"],
|
| 1054 |
-
file_count="multiple",
|
| 1055 |
-
elem_classes="file-upload"
|
| 1056 |
-
)
|
| 1057 |
-
|
| 1058 |
-
file_analysis = gr.Textbox(
|
| 1059 |
-
label="File Analysis Result",
|
| 1060 |
-
interactive=False,
|
| 1061 |
-
elem_classes="analysis-result"
|
| 1062 |
-
)
|
| 1063 |
-
|
| 1064 |
-
analyze_btn = antd.Button(
|
| 1065 |
-
"Analyze Files",
|
| 1066 |
-
type="primary",
|
| 1067 |
-
size="large",
|
| 1068 |
-
elem_classes="analyze-btn"
|
| 1069 |
-
)
|
| 1070 |
|
| 1071 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1072 |
input = antd.InputTextarea(
|
| 1073 |
size="large",
|
| 1074 |
allow_clear=True,
|
|
@@ -1076,7 +1071,7 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1076 |
elem_classes="custom-textarea"
|
| 1077 |
)
|
| 1078 |
|
| 1079 |
-
|
| 1080 |
with antd.Flex(gap="small", justify="flex-start"):
|
| 1081 |
btn = antd.Button(
|
| 1082 |
"Generate",
|
|
@@ -1097,68 +1092,14 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1097 |
elem_classes="share-btn"
|
| 1098 |
)
|
| 1099 |
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค์ ํ ๊ณณ์ ๋ชจ์์ ์ ์
|
| 1107 |
-
async def handle_file_upload(files):
|
| 1108 |
-
if not files:
|
| 1109 |
-
return "No files uploaded"
|
| 1110 |
-
|
| 1111 |
-
if len(files) > FileProcessor.MAX_FILES:
|
| 1112 |
-
return f"Maximum {FileProcessor.MAX_FILES} files allowed"
|
| 1113 |
-
|
| 1114 |
-
results = []
|
| 1115 |
-
for file in files:
|
| 1116 |
-
if not FileProcessor.is_allowed_file(file.name):
|
| 1117 |
-
results.append(f"Unsupported file: {file.name}")
|
| 1118 |
-
continue
|
| 1119 |
-
|
| 1120 |
-
if os.path.getsize(file.name) > FileProcessor.MAX_FILE_SIZE:
|
| 1121 |
-
results.append(f"File too large: {file.name}")
|
| 1122 |
-
continue
|
| 1123 |
-
|
| 1124 |
-
result = await FileProcessor.process_file(file)
|
| 1125 |
-
results.append(f"Analysis for {file.name}:\n{result}\n")
|
| 1126 |
-
|
| 1127 |
-
return "\n".join(results)
|
| 1128 |
-
|
| 1129 |
-
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ฐ๊ฒฐ
|
| 1130 |
-
analyze_btn.click(
|
| 1131 |
-
fn=handle_file_upload,
|
| 1132 |
-
inputs=[file_upload],
|
| 1133 |
-
outputs=[file_analysis]
|
| 1134 |
-
)
|
| 1135 |
-
|
| 1136 |
-
btn.click(
|
| 1137 |
-
demo_instance.generation_code,
|
| 1138 |
-
inputs=[input, setting],
|
| 1139 |
-
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 1140 |
-
).then(
|
| 1141 |
-
fn=update_placeholder,
|
| 1142 |
-
inputs=[],
|
| 1143 |
-
outputs=[input]
|
| 1144 |
-
)
|
| 1145 |
-
|
| 1146 |
-
boost_btn.click(
|
| 1147 |
-
fn=handle_boost,
|
| 1148 |
-
inputs=[input],
|
| 1149 |
-
outputs=[input, state_tab]
|
| 1150 |
-
)
|
| 1151 |
-
|
| 1152 |
-
deploy_btn.click(
|
| 1153 |
-
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "No code to share.",
|
| 1154 |
-
inputs=[code_output],
|
| 1155 |
-
outputs=[deploy_result]
|
| 1156 |
-
)
|
| 1157 |
|
| 1158 |
# ์ฐ์ธก ํจ๋
|
| 1159 |
with antd.Col(span=24, md=16):
|
| 1160 |
with ms.Div(elem_classes="right_panel"):
|
| 1161 |
-
# macOS ์คํ์ผ ์๋์ฐ ํค๋
|
| 1162 |
gr.HTML("""
|
| 1163 |
<div class="window-frame">
|
| 1164 |
<div class="window-header">
|
|
@@ -1172,14 +1113,11 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1172 |
</div>
|
| 1173 |
""")
|
| 1174 |
|
| 1175 |
-
# ํญ ์ปจํ
์ธ
|
| 1176 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 1177 |
with antd.Tabs.Item(key="empty"):
|
| 1178 |
empty = antd.Empty(
|
| 1179 |
description="Enter your question to begin",
|
| 1180 |
-
|
| 1181 |
-
elem_classes="right_content empty-content" # style ๋์ class ์ฌ์ฉ
|
| 1182 |
-
|
| 1183 |
)
|
| 1184 |
|
| 1185 |
with antd.Tabs.Item(key="loading"):
|
|
@@ -1192,11 +1130,40 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1192 |
|
| 1193 |
with antd.Tabs.Item(key="render"):
|
| 1194 |
sandbox = gr.HTML(elem_classes="html_content")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1196 |
|
| 1197 |
btn.click(
|
| 1198 |
demo_instance.generation_code,
|
| 1199 |
-
inputs=[input, setting],
|
| 1200 |
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 1201 |
).then(
|
| 1202 |
fn=update_placeholder,
|
|
@@ -1204,7 +1171,6 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1204 |
outputs=[input]
|
| 1205 |
)
|
| 1206 |
|
| 1207 |
-
|
| 1208 |
boost_btn.click(
|
| 1209 |
fn=handle_boost,
|
| 1210 |
inputs=[input],
|
|
@@ -1216,6 +1182,7 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1216 |
inputs=[code_output],
|
| 1217 |
outputs=[deploy_result]
|
| 1218 |
)
|
|
|
|
| 1219 |
|
| 1220 |
gr.HTML("""
|
| 1221 |
<style>
|
|
@@ -1305,6 +1272,9 @@ Use the "Generate" button for basic creation, "Enhance" button for prompt improv
|
|
| 1305 |
|
| 1306 |
return demo
|
| 1307 |
|
|
|
|
|
|
|
|
|
|
| 1308 |
# ๋ฉ์ธ ์คํ ๋ถ๋ถ
|
| 1309 |
if __name__ == "__main__":
|
| 1310 |
try:
|
|
|
|
| 686 |
def update_placeholder():
|
| 687 |
return gr.update(placeholder=get_random_placeholder())
|
| 688 |
|
| 689 |
+
|
| 690 |
+
|
| 691 |
def create_main_interface():
|
| 692 |
"""๋ฉ์ธ ์ธํฐํ์ด์ค ์์ฑ ํจ์"""
|
| 693 |
|
|
|
|
| 854 |
""", theme=theme)
|
| 855 |
|
| 856 |
|
|
|
|
| 857 |
with demo:
|
| 858 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
| 859 |
with gr.Tab("Visual AI Assistant", elem_id="mouse-tab", elem_classes="mouse-tab"):
|
| 860 |
+
setting = gr.State({"system": SystemPrompt})
|
|
|
|
|
|
|
|
|
|
| 861 |
|
| 862 |
with ms.Application() as app:
|
| 863 |
with antd.ConfigProvider():
|
|
|
|
| 864 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 865 |
gr.HTML("""
|
| 866 |
<div class="thinking-container">
|
|
|
|
| 1009 |
""")
|
| 1010 |
code_output = legacy.Markdown(visible=False)
|
| 1011 |
|
|
|
|
|
|
|
| 1012 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 1013 |
# ์ข์ธก ํจ๋
|
| 1014 |
with antd.Col(span=24, md=8):
|
| 1015 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 1016 |
+
# macOS ์คํ์ผ ์๋์ฐ ํค๋
|
|
|
|
|
|
|
| 1017 |
# macOS ์คํ์ผ ์๋์ฐ ํค๋
|
| 1018 |
header = gr.HTML("""
|
| 1019 |
<div class="window-frame">
|
|
|
|
| 1039 |
</div>
|
| 1040 |
""".format(get_image_base64('mouse.gif')))
|
| 1041 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1042 |
|
| 1043 |
+
# ํ์ผ ์
๋ก๋ ์น์
|
| 1044 |
+
with gr.Box(elem_classes="file-upload-section"):
|
| 1045 |
+
file_upload = gr.File(
|
| 1046 |
+
label="Upload Files (Images/Documents)",
|
| 1047 |
+
file_types=[".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp",
|
| 1048 |
+
".txt", ".pdf", ".docx", ".rtf"],
|
| 1049 |
+
file_count="multiple",
|
| 1050 |
+
elem_classes="file-upload"
|
| 1051 |
+
)
|
| 1052 |
+
|
| 1053 |
+
file_analysis = gr.Textbox(
|
| 1054 |
+
label="File Analysis Result",
|
| 1055 |
+
interactive=False,
|
| 1056 |
+
elem_classes="analysis-result"
|
| 1057 |
+
)
|
| 1058 |
+
|
| 1059 |
+
analyze_btn = antd.Button(
|
| 1060 |
+
"Analyze Files",
|
| 1061 |
+
type="primary",
|
| 1062 |
+
size="large",
|
| 1063 |
+
elem_classes="analyze-btn"
|
| 1064 |
+
)
|
| 1065 |
+
|
| 1066 |
+
# ์
๋ ฅ ์์ญ
|
| 1067 |
input = antd.InputTextarea(
|
| 1068 |
size="large",
|
| 1069 |
allow_clear=True,
|
|
|
|
| 1071 |
elem_classes="custom-textarea"
|
| 1072 |
)
|
| 1073 |
|
| 1074 |
+
# ๋ฒํผ ๊ทธ๋ฃน
|
| 1075 |
with antd.Flex(gap="small", justify="flex-start"):
|
| 1076 |
btn = antd.Button(
|
| 1077 |
"Generate",
|
|
|
|
| 1092 |
elem_classes="share-btn"
|
| 1093 |
)
|
| 1094 |
|
| 1095 |
+
deploy_result = gr.HTML(
|
| 1096 |
+
label="Share Result",
|
| 1097 |
+
elem_classes="deploy-result"
|
| 1098 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1099 |
|
| 1100 |
# ์ฐ์ธก ํจ๋
|
| 1101 |
with antd.Col(span=24, md=16):
|
| 1102 |
with ms.Div(elem_classes="right_panel"):
|
|
|
|
| 1103 |
gr.HTML("""
|
| 1104 |
<div class="window-frame">
|
| 1105 |
<div class="window-header">
|
|
|
|
| 1113 |
</div>
|
| 1114 |
""")
|
| 1115 |
|
|
|
|
| 1116 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 1117 |
with antd.Tabs.Item(key="empty"):
|
| 1118 |
empty = antd.Empty(
|
| 1119 |
description="Enter your question to begin",
|
| 1120 |
+
elem_classes="right_content empty-content"
|
|
|
|
|
|
|
| 1121 |
)
|
| 1122 |
|
| 1123 |
with antd.Tabs.Item(key="loading"):
|
|
|
|
| 1130 |
|
| 1131 |
with antd.Tabs.Item(key="render"):
|
| 1132 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 1133 |
+
|
| 1134 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ ์
|
| 1135 |
+
async def handle_file_upload(files):
|
| 1136 |
+
if not files:
|
| 1137 |
+
return "No files uploaded"
|
| 1138 |
|
| 1139 |
+
if len(files) > FileProcessor.MAX_FILES:
|
| 1140 |
+
return f"Maximum {FileProcessor.MAX_FILES} files allowed"
|
| 1141 |
+
|
| 1142 |
+
results = []
|
| 1143 |
+
for file in files:
|
| 1144 |
+
if not FileProcessor.is_allowed_file(file.name):
|
| 1145 |
+
results.append(f"Unsupported file: {file.name}")
|
| 1146 |
+
continue
|
| 1147 |
+
|
| 1148 |
+
if os.path.getsize(file.name) > FileProcessor.MAX_FILE_SIZE:
|
| 1149 |
+
results.append(f"File too large: {file.name}")
|
| 1150 |
+
continue
|
| 1151 |
+
|
| 1152 |
+
result = await FileProcessor.process_file(file)
|
| 1153 |
+
results.append(f"Analysis for {file.name}:\n{result}\n")
|
| 1154 |
+
|
| 1155 |
+
return "\n".join(results)
|
| 1156 |
+
|
| 1157 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ฐ๊ฒฐ
|
| 1158 |
+
analyze_btn.click(
|
| 1159 |
+
fn=handle_file_upload,
|
| 1160 |
+
inputs=[file_upload],
|
| 1161 |
+
outputs=[file_analysis]
|
| 1162 |
+
)
|
| 1163 |
|
| 1164 |
btn.click(
|
| 1165 |
demo_instance.generation_code,
|
| 1166 |
+
inputs=[input, setting],
|
| 1167 |
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 1168 |
).then(
|
| 1169 |
fn=update_placeholder,
|
|
|
|
| 1171 |
outputs=[input]
|
| 1172 |
)
|
| 1173 |
|
|
|
|
| 1174 |
boost_btn.click(
|
| 1175 |
fn=handle_boost,
|
| 1176 |
inputs=[input],
|
|
|
|
| 1182 |
inputs=[code_output],
|
| 1183 |
outputs=[deploy_result]
|
| 1184 |
)
|
| 1185 |
+
|
| 1186 |
|
| 1187 |
gr.HTML("""
|
| 1188 |
<style>
|
|
|
|
| 1272 |
|
| 1273 |
return demo
|
| 1274 |
|
| 1275 |
+
|
| 1276 |
+
|
| 1277 |
+
|
| 1278 |
# ๋ฉ์ธ ์คํ ๋ถ๋ถ
|
| 1279 |
if __name__ == "__main__":
|
| 1280 |
try:
|