AnatoliiG commited on
Commit
5ef649a
·
1 Parent(s): 70bc007

Update components.py

Browse files
Files changed (1) hide show
  1. src/ui/components.py +14 -4
src/ui/components.py CHANGED
@@ -11,7 +11,7 @@ from src.ui.styles import CSS
11
  def get_system_status():
12
  cpu = psutil.cpu_percent()
13
  ram = psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024
14
- return f"### 🖥️ Status\n**CPU:** {cpu}% | **RAM:** {ram:.1f}MB"
15
 
16
 
17
  def create_ui():
@@ -20,7 +20,14 @@ def create_ui():
20
 
21
  with gr.Row(elem_id="main-row"):
22
  with gr.Sidebar():
23
- status = gr.Markdown(get_system_status())
 
 
 
 
 
 
 
24
  sys_pt = gr.Textbox(
25
  label="System Prompt", value="Вы программист.", lines=3
26
  )
@@ -36,8 +43,11 @@ def create_ui():
36
  msg = gr.Textbox(show_label=False, scale=9, autofocus=True)
37
  submit = gr.Button("Run ➤", variant="primary", scale=1)
38
 
39
- # Events
40
- timer.tick(get_system_status, outputs=status, show_progress="hidden")
 
 
 
41
 
42
  input_args = [msg, chatbot]
43
  output_args = [msg, chatbot]
 
11
  def get_system_status():
12
  cpu = psutil.cpu_percent()
13
  ram = psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024
14
+ return cpu, round(ram, 1)
15
 
16
 
17
  def create_ui():
 
20
 
21
  with gr.Row(elem_id="main-row"):
22
  with gr.Sidebar():
23
+ cpu_val, ram_val = get_system_status()
24
+ gr.Markdown("### 🖥️ Status")
25
+ cpu_display = gr.Number(
26
+ value=cpu_val, label="CPU %", precision=1, interactive=False
27
+ )
28
+ ram_display = gr.Number(
29
+ value=ram_val, label="RAM MB", precision=1, interactive=False
30
+ )
31
  sys_pt = gr.Textbox(
32
  label="System Prompt", value="Вы программист.", lines=3
33
  )
 
43
  msg = gr.Textbox(show_label=False, scale=9, autofocus=True)
44
  submit = gr.Button("Run ➤", variant="primary", scale=1)
45
 
46
+ timer.tick(
47
+ get_system_status,
48
+ outputs=[cpu_display, ram_display],
49
+ show_progress="hidden",
50
+ )
51
 
52
  input_args = [msg, chatbot]
53
  output_args = [msg, chatbot]