EunsuKim commited on
Commit
1a67d0f
·
verified ·
1 Parent(s): 63c6341

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -7,7 +7,7 @@ DATA_DIR = "submissions"
7
  os.makedirs(DATA_DIR, exist_ok=True)
8
 
9
  # Predefined task types
10
- TASK_TYPES = ["Classification", "Regression", "Translation", "Custom"]
11
 
12
  # Function to handle task submission
13
  def submit_task(task_type, description, yaml_text):
@@ -36,6 +36,13 @@ def get_tasks_by_type(task_type):
36
  tasks.append(data)
37
  return tasks
38
 
 
 
 
 
 
 
 
39
  # Function to switch tabs
40
  def switch_tab(tab_name):
41
  return gr.Tabs.update(visible_tab=tab_name)
@@ -52,9 +59,17 @@ with gr.Blocks() as app:
52
  task_type_input = gr.Dropdown(
53
  label="Task Type",
54
  choices=TASK_TYPES,
55
- value="Classification",
 
 
 
 
 
56
  interactive=True
57
  )
 
 
 
58
  description_input = gr.Textbox(
59
  label="Task Description",
60
  placeholder="Provide a brief description of the task.",
@@ -69,6 +84,13 @@ with gr.Blocks() as app:
69
  go_to_view_tab = gr.Button("Go to View Tasks")
70
  submission_status = gr.Textbox(label="Status", interactive=False)
71
 
 
 
 
 
 
 
 
72
  # Handle task submission
73
  submit_button.click(
74
  submit_task,
@@ -83,14 +105,13 @@ with gr.Blocks() as app:
83
  outputs=[tabs]
84
  )
85
 
86
-
87
  with gr.Tab("View Tasks"):
88
  gr.Markdown("## View Submitted Tasks")
89
 
90
  task_type_filter = gr.Dropdown(
91
  label="Filter by Task Type",
92
  choices=TASK_TYPES,
93
- value="Classification",
94
  interactive=True
95
  )
96
  view_button = gr.Button("View Tasks")
@@ -116,5 +137,4 @@ with gr.Blocks() as app:
116
  outputs=[tabs]
117
  )
118
 
119
-
120
- app.launch()
 
7
  os.makedirs(DATA_DIR, exist_ok=True)
8
 
9
  # Predefined task types
10
+ TASK_TYPES = ["math", "Open-Ended", "Custom"]
11
 
12
  # Function to handle task submission
13
  def submit_task(task_type, description, yaml_text):
 
36
  tasks.append(data)
37
  return tasks
38
 
39
+ # Function to dynamically add a new task type
40
+ def add_new_task_type(new_type):
41
+ if new_type and new_type not in TASK_TYPES:
42
+ TASK_TYPES.append(new_type)
43
+ return gr.Dropdown.update(choices=TASK_TYPES), f"Task type '{new_type}' added successfully!"
44
+ return gr.Dropdown.update(choices=TASK_TYPES), "Task type already exists or invalid input."
45
+
46
  # Function to switch tabs
47
  def switch_tab(tab_name):
48
  return gr.Tabs.update(visible_tab=tab_name)
 
59
  task_type_input = gr.Dropdown(
60
  label="Task Type",
61
  choices=TASK_TYPES,
62
+ value="math",
63
+ interactive=True
64
+ )
65
+ new_task_input = gr.Textbox(
66
+ label="Add New Task Type",
67
+ placeholder="Enter a new task type",
68
  interactive=True
69
  )
70
+ add_task_button = gr.Button("Add Task Type")
71
+ add_task_status = gr.Textbox(label="Status", interactive=False)
72
+
73
  description_input = gr.Textbox(
74
  label="Task Description",
75
  placeholder="Provide a brief description of the task.",
 
84
  go_to_view_tab = gr.Button("Go to View Tasks")
85
  submission_status = gr.Textbox(label="Status", interactive=False)
86
 
87
+ # Handle adding new task type
88
+ add_task_button.click(
89
+ add_new_task_type,
90
+ inputs=[new_task_input],
91
+ outputs=[task_type_input, add_task_status]
92
+ )
93
+
94
  # Handle task submission
95
  submit_button.click(
96
  submit_task,
 
105
  outputs=[tabs]
106
  )
107
 
 
108
  with gr.Tab("View Tasks"):
109
  gr.Markdown("## View Submitted Tasks")
110
 
111
  task_type_filter = gr.Dropdown(
112
  label="Filter by Task Type",
113
  choices=TASK_TYPES,
114
+ value="math",
115
  interactive=True
116
  )
117
  view_button = gr.Button("View Tasks")
 
137
  outputs=[tabs]
138
  )
139
 
140
+ app.launch()