Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -78,26 +78,26 @@ def analyze_space(url: str, progress=gr.Progress()):
|
|
78 |
if not re.match(r'^[\w.-]+/[\w.-]+$', space_id):
|
79 |
raise ValueError(f"Invalid Space ID format: {space_id}")
|
80 |
|
81 |
-
progress(0.1, desc="νμΌ κ΅¬μ‘° λΆμ μ€...")
|
82 |
tree_structure = get_space_structure(space_id)
|
83 |
if "error" in tree_structure:
|
84 |
raise ValueError(tree_structure["error"])
|
85 |
tree_view = format_tree_structure(tree_structure)
|
86 |
|
87 |
-
progress(0.3, desc="app.py λ΄μ© κ°μ Έμ€λ μ€...")
|
88 |
app_content = get_file_content(space_id, "app.py")
|
89 |
|
90 |
-
progress(0.5, desc="μ½λ μμ½ μ€...")
|
91 |
summary = summarize_code(app_content)
|
92 |
|
93 |
-
progress(0.7, desc="μ½λ λΆμ μ€...")
|
94 |
analysis = analyze_code(app_content)
|
95 |
|
96 |
-
progress(0.9, desc="μ¬μ©λ² μ€λͺ
μμ± μ€...")
|
97 |
usage = explain_usage(app_content)
|
98 |
|
99 |
lines_for_app_py = adjust_lines_for_code(app_content)
|
100 |
-
progress(1.0, desc="μλ£")
|
101 |
|
102 |
return app_content, tree_view, tree_structure, space_id, summary, analysis, usage, lines_for_app_py
|
103 |
|
@@ -299,23 +299,37 @@ def respond_wrapper(message: str, conversation_state: List[ChatMessage], max_tok
|
|
299 |
def create_ui():
|
300 |
try:
|
301 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
footer {visibility: hidden;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
"""
|
304 |
-
|
305 |
with gr.Blocks(css=css) as demo:
|
306 |
-
gr.Markdown("# MOUSE: Space Research Thinking")
|
307 |
-
|
308 |
with gr.Tabs():
|
309 |
-
with gr.TabItem("λΆμ"):
|
310 |
with gr.Row():
|
311 |
with gr.Column():
|
312 |
-
url_input = gr.Textbox(label="HuggingFace Space URL")
|
313 |
-
analyze_button = gr.Button("λΆμ")
|
314 |
|
315 |
-
summary_output = gr.Markdown(label="μμ½")
|
316 |
-
analysis_output = gr.Markdown(label="λΆμ")
|
317 |
-
usage_output = gr.Markdown(label="μ¬μ©λ²")
|
318 |
-
tree_view_output = gr.Textbox(label="νμΌ κ΅¬μ‘°", lines=20)
|
319 |
|
320 |
with gr.Column():
|
321 |
code_tabs = gr.Tabs()
|
@@ -332,21 +346,17 @@ def create_ui():
|
|
332 |
lines=50
|
333 |
)
|
334 |
|
335 |
-
with gr.TabItem("AI μ½λμ±"):
|
336 |
-
gr.Markdown("## μμ λ₯Ό
|
337 |
-
|
338 |
-
# Chatbot: type="messages"
|
339 |
chatbot = gr.Chatbot(
|
340 |
-
label="
|
341 |
height=400,
|
342 |
type="messages"
|
343 |
)
|
344 |
-
|
345 |
msg = gr.Textbox(
|
346 |
-
label="λ©μμ§",
|
347 |
placeholder="λ©μμ§λ₯Ό μ
λ ₯νμΈμ..."
|
348 |
)
|
349 |
-
|
350 |
max_tokens = gr.Slider(
|
351 |
minimum=1, maximum=8000,
|
352 |
value=4000, label="Max Tokens",
|
@@ -386,7 +396,7 @@ def create_ui():
|
|
386 |
outputs=[msg, chatbot],
|
387 |
)
|
388 |
|
389 |
-
with gr.TabItem("Recommended Best"):
|
390 |
gr.Markdown(
|
391 |
"Discover recommended HuggingFace Spaces [here](https://huggingface.co/spaces/openfree/Korean-Leaderboard)."
|
392 |
)
|
@@ -447,4 +457,4 @@ if __name__ == "__main__":
|
|
447 |
print(f"Error in main: {str(e)}")
|
448 |
print("Detailed error information:")
|
449 |
print(traceback.format_exc())
|
450 |
-
raise
|
|
|
78 |
if not re.match(r'^[\w.-]+/[\w.-]+$', space_id):
|
79 |
raise ValueError(f"Invalid Space ID format: {space_id}")
|
80 |
|
81 |
+
progress(0.1, desc="π νμΌ κ΅¬μ‘° λΆμ μ€...")
|
82 |
tree_structure = get_space_structure(space_id)
|
83 |
if "error" in tree_structure:
|
84 |
raise ValueError(tree_structure["error"])
|
85 |
tree_view = format_tree_structure(tree_structure)
|
86 |
|
87 |
+
progress(0.3, desc="π app.py λ΄μ© κ°μ Έμ€λ μ€...")
|
88 |
app_content = get_file_content(space_id, "app.py")
|
89 |
|
90 |
+
progress(0.5, desc="βοΈ μ½λ μμ½ μ€...")
|
91 |
summary = summarize_code(app_content)
|
92 |
|
93 |
+
progress(0.7, desc="π μ½λ λΆμ μ€...")
|
94 |
analysis = analyze_code(app_content)
|
95 |
|
96 |
+
progress(0.9, desc="π μ¬μ©λ² μ€λͺ
μμ± μ€...")
|
97 |
usage = explain_usage(app_content)
|
98 |
|
99 |
lines_for_app_py = adjust_lines_for_code(app_content)
|
100 |
+
progress(1.0, desc="β
μλ£")
|
101 |
|
102 |
return app_content, tree_view, tree_structure, space_id, summary, analysis, usage, lines_for_app_py
|
103 |
|
|
|
299 |
def create_ui():
|
300 |
try:
|
301 |
css = """
|
302 |
+
body {
|
303 |
+
background: linear-gradient(to right, #f0f2f5, #ffffff);
|
304 |
+
font-family: 'Segoe UI', sans-serif;
|
305 |
+
}
|
306 |
+
.gradio-container {
|
307 |
+
border-radius: 15px;
|
308 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
309 |
+
}
|
310 |
footer {visibility: hidden;}
|
311 |
+
.tabitem-header {
|
312 |
+
font-weight: bold;
|
313 |
+
color: #3b3b3b;
|
314 |
+
}
|
315 |
+
.gradio-markdown h1 {
|
316 |
+
color: #ff6f61;
|
317 |
+
}
|
318 |
"""
|
|
|
319 |
with gr.Blocks(css=css) as demo:
|
320 |
+
gr.Markdown("# π MOUSE: Space Research Thinking")
|
321 |
+
|
322 |
with gr.Tabs():
|
323 |
+
with gr.TabItem("π λΆμ"):
|
324 |
with gr.Row():
|
325 |
with gr.Column():
|
326 |
+
url_input = gr.Textbox(label="π HuggingFace Space URL", placeholder="μ: https://huggingface.co/spaces/username/space-name")
|
327 |
+
analyze_button = gr.Button("λΆμ μμ π", variant="primary")
|
328 |
|
329 |
+
summary_output = gr.Markdown(label="π μ½λ μμ½")
|
330 |
+
analysis_output = gr.Markdown(label="π μ½λ λΆμ")
|
331 |
+
usage_output = gr.Markdown(label="π μ¬μ©λ² μλ΄")
|
332 |
+
tree_view_output = gr.Textbox(label="π νμΌ κ΅¬μ‘°", lines=20)
|
333 |
|
334 |
with gr.Column():
|
335 |
code_tabs = gr.Tabs()
|
|
|
346 |
lines=50
|
347 |
)
|
348 |
|
349 |
+
with gr.TabItem("π€ AI μ½λμ±"):
|
350 |
+
gr.Markdown("## π¬ μμ λ₯Ό μ
λ ₯νκ±°λ μμ€ μ½λλ₯Ό λΆμ¬λ£κ³ μ§λ¬Έν΄λ³΄μΈμ!")
|
|
|
|
|
351 |
chatbot = gr.Chatbot(
|
352 |
+
label="λνμ°½",
|
353 |
height=400,
|
354 |
type="messages"
|
355 |
)
|
|
|
356 |
msg = gr.Textbox(
|
357 |
+
label="λ©μμ§ μ
λ ₯",
|
358 |
placeholder="λ©μμ§λ₯Ό μ
λ ₯νμΈμ..."
|
359 |
)
|
|
|
360 |
max_tokens = gr.Slider(
|
361 |
minimum=1, maximum=8000,
|
362 |
value=4000, label="Max Tokens",
|
|
|
396 |
outputs=[msg, chatbot],
|
397 |
)
|
398 |
|
399 |
+
with gr.TabItem("β Recommended Best"):
|
400 |
gr.Markdown(
|
401 |
"Discover recommended HuggingFace Spaces [here](https://huggingface.co/spaces/openfree/Korean-Leaderboard)."
|
402 |
)
|
|
|
457 |
print(f"Error in main: {str(e)}")
|
458 |
print("Detailed error information:")
|
459 |
print(traceback.format_exc())
|
460 |
+
raise
|