Spaces:
Runtime error
Runtime error
Trying to fix the tasklist aligment 2
Browse files
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
|
| 19 |
@media (min-width: 769px) {
|
| 20 |
-
|
| 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 (
|
| 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
|
| 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 |
-
#
|
| 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 "โ ูุฐุง ุงููู
ูุฐุฌ ุบูุฑ ู
ุชุงุญ ุญุงููุงู. ุณูุชู
ุฅุถุงูุชู ูุงุญูุงู."
|