NLPAlhuzali commited on
Commit
c57e262
ยท
verified ยท
1 Parent(s): 3107413

Trying to fix the tasklist aligment 2

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -3,7 +3,7 @@ from models.space_a import summarize_question
3
  from models.space_b import generate_mentalqa_answer
4
  from models.space_er import extract_entities
5
 
6
- # CSS styling
7
  css = """
8
  .rtl {
9
  direction: rtl;
@@ -15,19 +15,18 @@ css = """
15
  border-radius: 8px;
16
  }
17
 
18
- /* Desktop: move sidebar to the right */
19
  @media (min-width: 769px) {
20
- .gr-row {
21
  flex-direction: row-reverse !important;
22
  }
23
  }
24
  """
25
 
26
-
27
  with gr.Blocks(css=css) as demo:
28
 
29
- with gr.Row():
30
- # Sidebar (moved above main content in mobile)
31
  with gr.Column(scale=1):
32
  with gr.Group(elem_classes="sidebar-box rtl"):
33
  gr.Markdown("### ุงู„ู‚ุงุฆู…ุฉ ุงู„ุฌุงู†ุจูŠุฉ", elem_classes="rtl")
@@ -59,7 +58,7 @@ with gr.Blocks(css=css) as demo:
59
  analyze_btn = gr.Button("ุงุจุฏุฃ ุงู„ุชุญู„ูŠู„", elem_classes="rtl")
60
  output = gr.Textbox(label="ุงู„ู†ุชูŠุฌุฉ", elem_classes="rtl")
61
 
62
- # Toggle logic for classification box
63
  def toggle_classification(task_choice):
64
  return gr.update(visible=(task_choice == "classification"))
65
 
@@ -69,7 +68,7 @@ with gr.Blocks(css=css) as demo:
69
  outputs=classify_box
70
  )
71
 
72
- # Unified processing function
73
  def analyze(text, task, classify=None):
74
  if not text.strip():
75
  return "โ— ุงู„ุฑุฌุงุก ุฅุฏุฎุงู„ ู†ุต ู„ู„ุชุญู„ูŠู„."
@@ -85,7 +84,7 @@ with gr.Blocks(css=css) as demo:
85
  return generate_mentalqa_answer(text)
86
 
87
  elif task == "classification":
88
- return "โŒ ู†ู…ูˆุฐุฌ ุชุตู†ูŠู ุงู„ุฃุณุฆู„ุฉ ูˆุงู„ุฅุฌุงุจุงุช ุบูŠุฑ ู…ุชุงุญ ุญุงู„ูŠุงู‹."
89
 
90
  elif task in ["adverse_drug_reaction", "relation_extraction"]:
91
  return "โŒ ู‡ุฐุง ุงู„ู†ู…ูˆุฐุฌ ุบูŠุฑ ู…ุชุงุญ ุญุงู„ูŠุงู‹. ุณูŠุชู… ุฅุถุงูุชู‡ ู„ุงุญู‚ุงู‹."
 
3
  from models.space_b import generate_mentalqa_answer
4
  from models.space_er import extract_entities
5
 
6
+ # CSS styling with layout control
7
  css = """
8
  .rtl {
9
  direction: rtl;
 
15
  border-radius: 8px;
16
  }
17
 
18
+ /* Desktop: move sidebar to right */
19
  @media (min-width: 769px) {
20
+ #main-layout {
21
  flex-direction: row-reverse !important;
22
  }
23
  }
24
  """
25
 
 
26
  with gr.Blocks(css=css) as demo:
27
 
28
+ with gr.Row(elem_id="main-layout"): # <- Used for layout targeting
29
+ # Sidebar (comes first in code for mobile top placement)
30
  with gr.Column(scale=1):
31
  with gr.Group(elem_classes="sidebar-box rtl"):
32
  gr.Markdown("### ุงู„ู‚ุงุฆู…ุฉ ุงู„ุฌุงู†ุจูŠุฉ", elem_classes="rtl")
 
58
  analyze_btn = gr.Button("ุงุจุฏุฃ ุงู„ุชุญู„ูŠู„", elem_classes="rtl")
59
  output = gr.Textbox(label="ุงู„ู†ุชูŠุฌุฉ", elem_classes="rtl")
60
 
61
+ # Toggle logic for classification visibility
62
  def toggle_classification(task_choice):
63
  return gr.update(visible=(task_choice == "classification"))
64
 
 
68
  outputs=classify_box
69
  )
70
 
71
+ # Processing function
72
  def analyze(text, task, classify=None):
73
  if not text.strip():
74
  return "โ— ุงู„ุฑุฌุงุก ุฅุฏุฎุงู„ ู†ุต ู„ู„ุชุญู„ูŠู„."
 
84
  return generate_mentalqa_answer(text)
85
 
86
  elif task == "classification":
87
+ return f"โŒ ู†ู…ูˆุฐุฌ ุชุตู†ูŠู ุงู„ุฃุณุฆู„ุฉ ูˆุงู„ุฅุฌุงุจุงุช ุบูŠุฑ ู…ุชุงุญ ุญุงู„ูŠุงู‹."
88
 
89
  elif task in ["adverse_drug_reaction", "relation_extraction"]:
90
  return "โŒ ู‡ุฐุง ุงู„ู†ู…ูˆุฐุฌ ุบูŠุฑ ู…ุชุงุญ ุญุงู„ูŠุงู‹. ุณูŠุชู… ุฅุถุงูุชู‡ ู„ุงุญู‚ุงู‹."