ginipick commited on
Commit
5c58372
Β·
verified Β·
1 Parent(s): ef3113e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -26
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