Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -211,76 +211,92 @@ def respond(
|
|
211 |
def create_ui():
|
212 |
try:
|
213 |
css = """
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
.output-group {
|
216 |
-
border: 1px solid #
|
217 |
-
border-radius:
|
218 |
-
padding:
|
219 |
margin-bottom: 20px;
|
|
|
|
|
220 |
}
|
|
|
221 |
.scroll-lock {
|
222 |
overflow-y: auto !important;
|
223 |
-
max-height:
|
224 |
}
|
225 |
.tree-view-scroll {
|
226 |
overflow-y: auto !important;
|
227 |
-
max-height:
|
228 |
}
|
229 |
.full-height {
|
230 |
-
height:
|
231 |
overflow-y: auto !important;
|
232 |
}
|
|
|
233 |
.code-box {
|
234 |
overflow-x: auto !important;
|
235 |
overflow-y: auto !important;
|
236 |
white-space: pre !important;
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
min-width: 100% !important;
|
242 |
}
|
|
|
243 |
.code-box > div > textarea {
|
244 |
word-break: normal !important;
|
245 |
overflow-wrap: normal !important;
|
246 |
}
|
|
|
247 |
.tab-nav {
|
248 |
-
background-color: #
|
249 |
-
border-
|
250 |
-
|
251 |
}
|
252 |
.tab-nav button {
|
253 |
-
|
254 |
-
background-color: #34495e;
|
255 |
border: none;
|
256 |
padding: 10px 20px;
|
257 |
margin: 0;
|
258 |
-
|
259 |
font-size: 16px;
|
260 |
-
|
261 |
-
|
262 |
-
.tab-nav button:hover {
|
263 |
-
background-color: #2980b9;
|
264 |
}
|
|
|
265 |
.tab-nav button.selected {
|
266 |
-
color: #
|
267 |
-
|
268 |
}
|
|
|
269 |
input[type="text"], textarea {
|
270 |
-
color: #
|
271 |
-
background-color: #
|
|
|
|
|
|
|
272 |
}
|
273 |
"""
|
274 |
|
275 |
-
with gr.Blocks(theme="
|
276 |
-
gr.Markdown("# Mouse: HuggingFace")
|
277 |
|
278 |
with gr.Tabs() as tabs:
|
279 |
with gr.TabItem("๋ถ์"):
|
280 |
with gr.Row():
|
281 |
-
with gr.Column(scale=6): # ์ผ์ชฝ
|
282 |
-
url_input = gr.Textbox(label="HuggingFace Space URL")
|
283 |
-
analyze_button = gr.Button("๋ถ์")
|
284 |
|
285 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
286 |
summary_output = gr.Markdown(label="์์ฝ (3์ค ์ด๋ด)")
|
@@ -291,23 +307,21 @@ def create_ui():
|
|
291 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
292 |
usage_output = gr.Markdown(label="์ฌ์ฉ๋ฒ")
|
293 |
|
294 |
-
with gr.Group(elem_classes="output-group tree-view-scroll"):
|
295 |
tree_view_output = gr.Textbox(label="ํ์ผ ๊ตฌ์กฐ (Tree View)", lines=30)
|
296 |
|
297 |
-
with gr.Column(scale=4): # ์ค๋ฅธ์ชฝ
|
298 |
with gr.Group(elem_classes="output-group full-height"):
|
299 |
code_tabs = gr.Tabs()
|
300 |
with code_tabs:
|
301 |
-
|
302 |
-
with app_py_tab:
|
303 |
app_py_content = gr.Code(
|
304 |
language="python",
|
305 |
label="app.py",
|
306 |
lines=200,
|
307 |
elem_classes="full-height code-box"
|
308 |
)
|
309 |
-
|
310 |
-
with requirements_tab:
|
311 |
requirements_content = gr.Textbox(
|
312 |
label="requirements.txt",
|
313 |
lines=200,
|
@@ -315,11 +329,11 @@ def create_ui():
|
|
315 |
)
|
316 |
|
317 |
with gr.TabItem("AI ์ฝ๋ฉ"):
|
318 |
-
chatbot = gr.Chatbot(label="๋ํ")
|
319 |
|
320 |
-
msg = gr.Textbox(label="๋ฉ์์ง")
|
321 |
|
322 |
-
# ์จ๊ฒจ์ง
|
323 |
max_tokens = gr.Slider(minimum=1, maximum=8000, value=4000, label="Max Tokens", visible=False)
|
324 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, label="Temperature", visible=False)
|
325 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P", visible=False)
|
@@ -328,26 +342,24 @@ def create_ui():
|
|
328 |
["์์ธํ ์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ง์น ํ๋ฉด์ ๋ณด๋ฉด์ ์ค๋ช
ํ๋ฏ์ด 4000 ํ ํฐ ์ด์ ์์ธํ ์ค๋ช
ํ๋ผ"],
|
329 |
["FAQ 20๊ฑด์ ์์ธํ๊ฒ ์์ฑํ๋ผ. 4000ํ ํฐ ์ด์ ์ฌ์ฉํ๋ผ."],
|
330 |
["์ฌ์ฉ ๋ฐฉ๋ฒ๊ณผ ์ฐจ๋ณ์ , ํน์ง, ๊ฐ์ ์ ์ค์ฌ์ผ๋ก 4000 ํ ํฐ ์ด์ ์ ํ๋ธ ์์ ์คํฌ๋ฆฝํธ ํํ๋ก ์์ฑํ๋ผ"],
|
331 |
-
["๋ณธ ์๋น์ค๋ฅผ SEO ์ต์ ํํ์ฌ ๋ธ๋ก๊ทธ
|
332 |
-
["ํนํ ์ถ์์ ํ์ฉํ
|
333 |
["๊ณ์ ์ด์ด์ ๋ต๋ณํ๋ผ"],
|
334 |
]
|
335 |
-
|
336 |
gr.Examples(examples, inputs=msg)
|
337 |
|
338 |
def respond_wrapper(message, chat_history, max_tokens, temperature, top_p):
|
339 |
bot_message = ""
|
340 |
for response in respond(message, chat_history, max_tokens=max_tokens, temperature=temperature, top_p=top_p):
|
341 |
-
bot_message = response # ๋ง์ง๋ง
|
342 |
yield "", chat_history + [(message, bot_message)]
|
343 |
|
344 |
chat_history.append((message, bot_message))
|
345 |
return "", chat_history
|
346 |
|
347 |
-
|
348 |
-
|
349 |
msg.submit(respond_wrapper, [msg, chatbot, max_tokens, temperature, top_p], [msg, chatbot])
|
350 |
|
|
|
351 |
space_id_state = gr.State()
|
352 |
tree_structure_state = gr.State()
|
353 |
app_py_content_lines = gr.State()
|
@@ -362,7 +374,7 @@ def create_ui():
|
|
362 |
outputs=[requirements_content]
|
363 |
)
|
364 |
|
365 |
-
#
|
366 |
app_py_content.change(lambda lines: gr.update(lines=lines), inputs=[app_py_content_lines], outputs=[app_py_content])
|
367 |
|
368 |
return demo
|
@@ -371,29 +383,3 @@ def create_ui():
|
|
371 |
print(f"Error in create_ui: {str(e)}")
|
372 |
print(traceback.format_exc())
|
373 |
raise
|
374 |
-
|
375 |
-
|
376 |
-
if __name__ == "__main__":
|
377 |
-
try:
|
378 |
-
print("Starting HuggingFace Space Analyzer...")
|
379 |
-
demo = create_ui()
|
380 |
-
print("UI created successfully.")
|
381 |
-
|
382 |
-
print("Configuring Gradio queue...")
|
383 |
-
demo.queue()
|
384 |
-
print("Gradio queue configured.")
|
385 |
-
|
386 |
-
print("Launching Gradio app...")
|
387 |
-
demo.launch(
|
388 |
-
server_name="0.0.0.0",
|
389 |
-
server_port=7860,
|
390 |
-
share=False,
|
391 |
-
debug=True,
|
392 |
-
show_api=False
|
393 |
-
)
|
394 |
-
print("Gradio app launched successfully.")
|
395 |
-
except Exception as e:
|
396 |
-
print(f"Error in main: {str(e)}")
|
397 |
-
print("Detailed error information:")
|
398 |
-
print(traceback.format_exc())
|
399 |
-
raise
|
|
|
211 |
def create_ui():
|
212 |
try:
|
213 |
css = """
|
214 |
+
/* ์ ์ฒด ๋ฐฐ๊ฒฝ ๋ฐ ๊ธฐ๋ณธ ๊ธ๊ผด ์ค์ */
|
215 |
+
body {
|
216 |
+
background-color: #f9f9f9;
|
217 |
+
font-family: 'Helvetica Neue', Arial, sans-serif;
|
218 |
+
color: #333;
|
219 |
+
}
|
220 |
+
/* ํ๋จ ํธํฐ ์จ๊น */
|
221 |
+
footer { visibility: hidden; }
|
222 |
+
|
223 |
+
/* ์ถ๋ ฅ ๊ทธ๋ฃน ์คํ์ผ: ๋ฐ์ ๋ฐฐ๊ฒฝ, ๋ถ๋๋ฌ์ด ํ
๋๋ฆฌ์ ๊ทธ๋ฆผ์ */
|
224 |
.output-group {
|
225 |
+
border: 1px solid #ccc;
|
226 |
+
border-radius: 8px;
|
227 |
+
padding: 15px;
|
228 |
margin-bottom: 20px;
|
229 |
+
background-color: #ffffff;
|
230 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
231 |
}
|
232 |
+
/* ์คํฌ๋กค ์์ญ ์ค์ */
|
233 |
.scroll-lock {
|
234 |
overflow-y: auto !important;
|
235 |
+
max-height: 300px !important;
|
236 |
}
|
237 |
.tree-view-scroll {
|
238 |
overflow-y: auto !important;
|
239 |
+
max-height: 400px !important;
|
240 |
}
|
241 |
.full-height {
|
242 |
+
height: 80vh !important;
|
243 |
overflow-y: auto !important;
|
244 |
}
|
245 |
+
/* ์ฝ๋ ๋ฐ์ค ์คํ์ผ: ๋ชจ๋
ธ์คํ์ด์ค ํฐํธ์ ๋ฐ์ ๋ฐฐ๊ฒฝ */
|
246 |
.code-box {
|
247 |
overflow-x: auto !important;
|
248 |
overflow-y: auto !important;
|
249 |
white-space: pre !important;
|
250 |
+
background-color: #f5f5f5;
|
251 |
+
border-radius: 4px;
|
252 |
+
padding: 10px;
|
253 |
+
font-family: 'Courier New', Courier, monospace;
|
|
|
254 |
}
|
255 |
+
.code-box > div { min-width: 100% !important; }
|
256 |
.code-box > div > textarea {
|
257 |
word-break: normal !important;
|
258 |
overflow-wrap: normal !important;
|
259 |
}
|
260 |
+
/* ํญ ๋ด๋น๊ฒ์ด์
์คํ์ผ: ๋จ์ํ๊ณ ๊น๋ํ ๋์์ธ */
|
261 |
.tab-nav {
|
262 |
+
background-color: #ffffff;
|
263 |
+
border-bottom: 1px solid #ccc;
|
264 |
+
display: flex;
|
265 |
}
|
266 |
.tab-nav button {
|
267 |
+
background: none;
|
|
|
268 |
border: none;
|
269 |
padding: 10px 20px;
|
270 |
margin: 0;
|
271 |
+
cursor: pointer;
|
272 |
font-size: 16px;
|
273 |
+
color: #555;
|
274 |
+
transition: color 0.3s, border-bottom 0.3s;
|
|
|
|
|
275 |
}
|
276 |
+
.tab-nav button:hover,
|
277 |
.tab-nav button.selected {
|
278 |
+
color: #000;
|
279 |
+
border-bottom: 2px solid #007BFF;
|
280 |
}
|
281 |
+
/* ์
๋ ฅ์ฐฝ ๋ฐ ํ
์คํธ ์์ญ ์คํ์ผ */
|
282 |
input[type="text"], textarea {
|
283 |
+
color: #333;
|
284 |
+
background-color: #fff;
|
285 |
+
border: 1px solid #ccc;
|
286 |
+
border-radius: 4px;
|
287 |
+
padding: 8px;
|
288 |
}
|
289 |
"""
|
290 |
|
291 |
+
with gr.Blocks(theme="default", css=css) as demo:
|
292 |
+
gr.Markdown("# Mouse: HuggingFace", elem_classes="header-markdown")
|
293 |
|
294 |
with gr.Tabs() as tabs:
|
295 |
with gr.TabItem("๋ถ์"):
|
296 |
with gr.Row():
|
297 |
+
with gr.Column(scale=6): # ์ผ์ชฝ ์์ญ
|
298 |
+
url_input = gr.Textbox(label="HuggingFace Space URL", placeholder="์: https://huggingface.co/spaces/username/space_name")
|
299 |
+
analyze_button = gr.Button("๋ถ์", variant="primary")
|
300 |
|
301 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
302 |
summary_output = gr.Markdown(label="์์ฝ (3์ค ์ด๋ด)")
|
|
|
307 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
308 |
usage_output = gr.Markdown(label="์ฌ์ฉ๋ฒ")
|
309 |
|
310 |
+
with gr.Group(elem_classes="output-group tree-view-scroll"):
|
311 |
tree_view_output = gr.Textbox(label="ํ์ผ ๊ตฌ์กฐ (Tree View)", lines=30)
|
312 |
|
313 |
+
with gr.Column(scale=4): # ์ค๋ฅธ์ชฝ ์์ญ
|
314 |
with gr.Group(elem_classes="output-group full-height"):
|
315 |
code_tabs = gr.Tabs()
|
316 |
with code_tabs:
|
317 |
+
with gr.TabItem("app.py"):
|
|
|
318 |
app_py_content = gr.Code(
|
319 |
language="python",
|
320 |
label="app.py",
|
321 |
lines=200,
|
322 |
elem_classes="full-height code-box"
|
323 |
)
|
324 |
+
with gr.TabItem("requirements.txt"):
|
|
|
325 |
requirements_content = gr.Textbox(
|
326 |
label="requirements.txt",
|
327 |
lines=200,
|
|
|
329 |
)
|
330 |
|
331 |
with gr.TabItem("AI ์ฝ๋ฉ"):
|
332 |
+
chatbot = gr.Chatbot(label="๋ํ", elem_classes="output-group full-height")
|
333 |
|
334 |
+
msg = gr.Textbox(label="๋ฉ์์ง", placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์...")
|
335 |
|
336 |
+
# ์จ๊ฒจ์ง ํ๋ผ๋ฏธํฐ
|
337 |
max_tokens = gr.Slider(minimum=1, maximum=8000, value=4000, label="Max Tokens", visible=False)
|
338 |
temperature = gr.Slider(minimum=0, maximum=1, value=0.7, label="Temperature", visible=False)
|
339 |
top_p = gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P", visible=False)
|
|
|
342 |
["์์ธํ ์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ง์น ํ๋ฉด์ ๋ณด๋ฉด์ ์ค๋ช
ํ๋ฏ์ด 4000 ํ ํฐ ์ด์ ์์ธํ ์ค๋ช
ํ๋ผ"],
|
343 |
["FAQ 20๊ฑด์ ์์ธํ๊ฒ ์์ฑํ๋ผ. 4000ํ ํฐ ์ด์ ์ฌ์ฉํ๋ผ."],
|
344 |
["์ฌ์ฉ ๋ฐฉ๋ฒ๊ณผ ์ฐจ๋ณ์ , ํน์ง, ๊ฐ์ ์ ์ค์ฌ์ผ๋ก 4000 ํ ํฐ ์ด์ ์ ํ๋ธ ์์ ์คํฌ๋ฆฝํธ ํํ๋ก ์์ฑํ๋ผ"],
|
345 |
+
["๋ณธ ์๋น์ค๋ฅผ SEO ์ต์ ํํ์ฌ ๋ธ๋ก๊ทธ ํฌ์คํธ๋ก 4000 ํ ํฐ ์ด์ ์์ฑํ๋ผ"],
|
346 |
+
["ํนํ ์ถ์์ ํ์ฉํ ํ์ ์ ์ธ ์ฐฝ์ ๋ฐ๋ช
๋ด์ฉ์ ์ค์ฌ์ผ๋ก 4000 ํ ํฐ ์ด์ ์์ฑํ๋ผ."],
|
347 |
["๊ณ์ ์ด์ด์ ๋ต๋ณํ๋ผ"],
|
348 |
]
|
|
|
349 |
gr.Examples(examples, inputs=msg)
|
350 |
|
351 |
def respond_wrapper(message, chat_history, max_tokens, temperature, top_p):
|
352 |
bot_message = ""
|
353 |
for response in respond(message, chat_history, max_tokens=max_tokens, temperature=temperature, top_p=top_p):
|
354 |
+
bot_message = response # ๋ง์ง๋ง ์๋ต ์ ์ฅ
|
355 |
yield "", chat_history + [(message, bot_message)]
|
356 |
|
357 |
chat_history.append((message, bot_message))
|
358 |
return "", chat_history
|
359 |
|
|
|
|
|
360 |
msg.submit(respond_wrapper, [msg, chatbot, max_tokens, temperature, top_p], [msg, chatbot])
|
361 |
|
362 |
+
# ์ํ ์ ์ฅ์ฉ ๋ณ์
|
363 |
space_id_state = gr.State()
|
364 |
tree_structure_state = gr.State()
|
365 |
app_py_content_lines = gr.State()
|
|
|
374 |
outputs=[requirements_content]
|
375 |
)
|
376 |
|
377 |
+
# ๋์ ์ผ๋ก app.py์ ์ค ์ ์กฐ์
|
378 |
app_py_content.change(lambda lines: gr.update(lines=lines), inputs=[app_py_content_lines], outputs=[app_py_content])
|
379 |
|
380 |
return demo
|
|
|
383 |
print(f"Error in create_ui: {str(e)}")
|
384 |
print(traceback.format_exc())
|
385 |
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|