Maharshi Gor
commited on
Commit
·
7985347
1
Parent(s):
02f811c
Updated correct link for documentations.
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ from display.utils import AutoEvalColumn, fields
|
|
20 |
# Constants
|
21 |
from envs import (
|
22 |
API,
|
|
|
23 |
EVAL_REQUESTS_PATH,
|
24 |
EVAL_RESULTS_PATH,
|
25 |
LEADERBOARD_REFRESH_INTERVAL,
|
@@ -129,7 +130,7 @@ if __name__ == "__main__":
|
|
129 |
login_btn = gr.LoginButton(scale=1)
|
130 |
gr.Markdown(
|
131 |
"**First time here?** Check out the [❓ Help](#help) tab for a quick introduction and "
|
132 |
-
"[QANTA25 Documentation](
|
133 |
"for detailed examples and tutorials on how to create and compete with your own QuizBowl agents.",
|
134 |
elem_classes="help-text",
|
135 |
)
|
|
|
20 |
# Constants
|
21 |
from envs import (
|
22 |
API,
|
23 |
+
DOCS_REPO_URL,
|
24 |
EVAL_REQUESTS_PATH,
|
25 |
EVAL_RESULTS_PATH,
|
26 |
LEADERBOARD_REFRESH_INTERVAL,
|
|
|
130 |
login_btn = gr.LoginButton(scale=1)
|
131 |
gr.Markdown(
|
132 |
"**First time here?** Check out the [❓ Help](#help) tab for a quick introduction and "
|
133 |
+
f"[QANTA25 Documentation]({DOCS_REPO_URL}) "
|
134 |
"for detailed examples and tutorials on how to create and compete with your own QuizBowl agents.",
|
135 |
elem_classes="help-text",
|
136 |
)
|
src/components/model_pipeline/model_pipeline.py
CHANGED
@@ -6,15 +6,12 @@ from app_configs import UNSELECTED_VAR_NAME
|
|
6 |
from components import commons
|
7 |
from components import typed_dicts as td
|
8 |
from components.model_pipeline.state_manager import (
|
9 |
-
|
10 |
-
PipelineState,
|
11 |
PipelineStateManager,
|
12 |
-
PipelineUIState,
|
13 |
-
PipelineValidator,
|
14 |
-
TossupPipelineState,
|
15 |
TossupPipelineStateManager,
|
16 |
)
|
17 |
from components.model_step.model_step import ModelStepComponent
|
|
|
18 |
from components.utils import make_state
|
19 |
from workflows.structs import ModelStep, TossupWorkflow, Workflow
|
20 |
from workflows.validators import WorkflowValidationError, WorkflowValidator
|
@@ -34,7 +31,7 @@ class PipelineInterface:
|
|
34 |
ui_state: PipelineUIState | None = None,
|
35 |
model_options: list[str] = None,
|
36 |
config: dict = {},
|
37 |
-
validator:
|
38 |
):
|
39 |
self.app = app
|
40 |
self.model_options = model_options
|
|
|
6 |
from components import commons
|
7 |
from components import typed_dicts as td
|
8 |
from components.model_pipeline.state_manager import (
|
9 |
+
BasePipelineValidator,
|
|
|
10 |
PipelineStateManager,
|
|
|
|
|
|
|
11 |
TossupPipelineStateManager,
|
12 |
)
|
13 |
from components.model_step.model_step import ModelStepComponent
|
14 |
+
from components.structs import ModelStepUIState, PipelineState, PipelineUIState, TossupPipelineState
|
15 |
from components.utils import make_state
|
16 |
from workflows.structs import ModelStep, TossupWorkflow, Workflow
|
17 |
from workflows.validators import WorkflowValidationError, WorkflowValidator
|
|
|
31 |
ui_state: PipelineUIState | None = None,
|
32 |
model_options: list[str] = None,
|
33 |
config: dict = {},
|
34 |
+
validator: BasePipelineValidator | None = None,
|
35 |
):
|
36 |
self.app = app
|
37 |
self.model_options = model_options
|
src/components/model_pipeline/state_manager.py
CHANGED
@@ -11,7 +11,8 @@ from pydantic import BaseModel, ValidationError
|
|
11 |
from app_configs import UNSELECTED_VAR_NAME
|
12 |
from components import typed_dicts as td
|
13 |
from components import utils
|
14 |
-
from components.structs import ModelStepUIState, PipelineState,
|
|
|
15 |
from workflows.factory import create_new_llm_step
|
16 |
from workflows.structs import Buzzer, BuzzerMethod, ModelStep, TossupWorkflow, Workflow
|
17 |
|
@@ -41,7 +42,7 @@ def strict_model_validate(model_cls: type[BaseModel], data: dict):
|
|
41 |
return strict_class.model_validate(data)
|
42 |
|
43 |
|
44 |
-
class
|
45 |
"""Abstract base class for pipeline validators."""
|
46 |
|
47 |
@abstractmethod
|
@@ -64,7 +65,7 @@ class PipelineStateManager:
|
|
64 |
pipeline_state_cls = PipelineState
|
65 |
workflow_cls = Workflow
|
66 |
|
67 |
-
def __init__(self, validator:
|
68 |
self.validator = validator
|
69 |
|
70 |
def make_pipeline_state(self, state_dict: td.PipelineStateDict) -> PipelineState:
|
@@ -161,7 +162,7 @@ class PipelineStateManager:
|
|
161 |
)
|
162 |
raise new_exception from e
|
163 |
|
164 |
-
def
|
165 |
"""Format error messages for pipeline parsing errors with consistent styling."""
|
166 |
error_template = """
|
167 |
<div class="md" style='color: #FF0000; background-color: #FFEEEE; padding: 10px; border-radius: 5px; border-left: 4px solid #FF0000;'>
|
@@ -172,19 +173,19 @@ class PipelineStateManager:
|
|
172 |
{help_text}
|
173 |
</div>
|
174 |
"""
|
175 |
-
|
176 |
if isinstance(e, yaml.YAMLError):
|
177 |
error_type = "Invalid YAML Error"
|
178 |
help_text = "Refer to the <a href='https://spacelift.io/blog/yaml#basic-yaml-syntax' target='_blank'>YAML schema</a> for correct formatting."
|
179 |
elif isinstance(e, ValidationError):
|
180 |
error_type = "Pipeline Parsing Error"
|
181 |
-
help_text = "Refer to the <a href='
|
182 |
elif isinstance(e, ValueError):
|
183 |
error_type = "Pipeline Validation Error"
|
184 |
-
help_text = "Refer to the <a href='
|
185 |
else:
|
186 |
error_type = "Unexpected Error"
|
187 |
-
help_text = "Please report this issue to us at <a href='
|
188 |
|
189 |
return error_template.format(error_type=error_type, error_message=str(e), help_text=help_text)
|
190 |
|
@@ -204,7 +205,7 @@ class PipelineStateManager:
|
|
204 |
config_str = json.dumps(config, indent=4, sort_keys=False)
|
205 |
return config_str, gr.update(visible=False)
|
206 |
except Exception as e:
|
207 |
-
error_message = self.
|
208 |
return gr.skip(), gr.update(value=error_message, visible=True)
|
209 |
|
210 |
def update_workflow_from_code(self, yaml_str: str, change_state: bool) -> tuple[td.PipelineStateDict, bool, dict]:
|
@@ -215,7 +216,7 @@ class PipelineStateManager:
|
|
215 |
state = self.pipeline_state_cls.from_workflow(workflow)
|
216 |
return state.model_dump(), not change_state, gr.update(visible=False)
|
217 |
except Exception as e:
|
218 |
-
error_message = self.
|
219 |
return gr.skip(), gr.skip(), gr.update(value=error_message, visible=True)
|
220 |
|
221 |
|
|
|
11 |
from app_configs import UNSELECTED_VAR_NAME
|
12 |
from components import typed_dicts as td
|
13 |
from components import utils
|
14 |
+
from components.structs import ModelStepUIState, PipelineState, TossupPipelineState
|
15 |
+
from envs import DOCS_REPO_BRANCH, DOCS_REPO_URL
|
16 |
from workflows.factory import create_new_llm_step
|
17 |
from workflows.structs import Buzzer, BuzzerMethod, ModelStep, TossupWorkflow, Workflow
|
18 |
|
|
|
42 |
return strict_class.model_validate(data)
|
43 |
|
44 |
|
45 |
+
class BasePipelineValidator(ABC):
|
46 |
"""Abstract base class for pipeline validators."""
|
47 |
|
48 |
@abstractmethod
|
|
|
65 |
pipeline_state_cls = PipelineState
|
66 |
workflow_cls = Workflow
|
67 |
|
68 |
+
def __init__(self, validator: BasePipelineValidator | None = None):
|
69 |
self.validator = validator
|
70 |
|
71 |
def make_pipeline_state(self, state_dict: td.PipelineStateDict) -> PipelineState:
|
|
|
162 |
)
|
163 |
raise new_exception from e
|
164 |
|
165 |
+
def create_pipeline_error_response(self, e: Exception) -> str:
|
166 |
"""Format error messages for pipeline parsing errors with consistent styling."""
|
167 |
error_template = """
|
168 |
<div class="md" style='color: #FF0000; background-color: #FFEEEE; padding: 10px; border-radius: 5px; border-left: 4px solid #FF0000;'>
|
|
|
173 |
{help_text}
|
174 |
</div>
|
175 |
"""
|
176 |
+
repo_files_url = f"{DOCS_REPO_URL}/tree/{DOCS_REPO_BRANCH}"
|
177 |
if isinstance(e, yaml.YAMLError):
|
178 |
error_type = "Invalid YAML Error"
|
179 |
help_text = "Refer to the <a href='https://spacelift.io/blog/yaml#basic-yaml-syntax' target='_blank'>YAML schema</a> for correct formatting."
|
180 |
elif isinstance(e, ValidationError):
|
181 |
error_type = "Pipeline Parsing Error"
|
182 |
+
help_text = f"Refer to the <a href='{repo_files_url}/pipeline-schema.md' target='_blank'>documentation</a> for the correct pipeline schema."
|
183 |
elif isinstance(e, ValueError):
|
184 |
error_type = "Pipeline Validation Error"
|
185 |
+
help_text = f"Refer to the <a href='{repo_files_url}/pipeline-schema.md' target='_blank'>documentation</a> for the correct pipeline schema."
|
186 |
else:
|
187 |
error_type = "Unexpected Error"
|
188 |
+
help_text = f"Please report this issue to us at <a href='{DOCS_REPO_URL}/issues' target='_blank'>GitHub Issues</a>."
|
189 |
|
190 |
return error_template.format(error_type=error_type, error_message=str(e), help_text=help_text)
|
191 |
|
|
|
205 |
config_str = json.dumps(config, indent=4, sort_keys=False)
|
206 |
return config_str, gr.update(visible=False)
|
207 |
except Exception as e:
|
208 |
+
error_message = self.create_pipeline_error_response(e)
|
209 |
return gr.skip(), gr.update(value=error_message, visible=True)
|
210 |
|
211 |
def update_workflow_from_code(self, yaml_str: str, change_state: bool) -> tuple[td.PipelineStateDict, bool, dict]:
|
|
|
216 |
state = self.pipeline_state_cls.from_workflow(workflow)
|
217 |
return state.model_dump(), not change_state, gr.update(visible=False)
|
218 |
except Exception as e:
|
219 |
+
error_message = self.create_pipeline_error_response(e)
|
220 |
return gr.skip(), gr.skip(), gr.update(value=error_message, visible=True)
|
221 |
|
222 |
|
src/components/model_pipeline/tossup_pipeline.py
CHANGED
@@ -3,13 +3,13 @@ from loguru import logger
|
|
3 |
|
4 |
from app_configs import AVAILABLE_MODELS, UNSELECTED_VAR_NAME
|
5 |
from components import commons
|
6 |
-
from components.structs import TossupPipelineState
|
7 |
from components.typed_dicts import TossupPipelineStateDict
|
8 |
from display.formatting import tiny_styled_warning
|
9 |
from workflows.structs import Buzzer, TossupWorkflow
|
10 |
|
11 |
from .model_pipeline import PipelineInterface
|
12 |
-
from .state_manager import
|
13 |
|
14 |
|
15 |
def toggleable_slider(
|
@@ -40,7 +40,7 @@ class TossupPipelineInterface(PipelineInterface):
|
|
40 |
ui_state: PipelineUIState | None = None,
|
41 |
model_options: list[str] = None,
|
42 |
config: dict = {},
|
43 |
-
validator:
|
44 |
):
|
45 |
super().__init__(app, workflow, ui_state, model_options, config, validator)
|
46 |
|
|
|
3 |
|
4 |
from app_configs import AVAILABLE_MODELS, UNSELECTED_VAR_NAME
|
5 |
from components import commons
|
6 |
+
from components.structs import PipelineUIState, TossupPipelineState
|
7 |
from components.typed_dicts import TossupPipelineStateDict
|
8 |
from display.formatting import tiny_styled_warning
|
9 |
from workflows.structs import Buzzer, TossupWorkflow
|
10 |
|
11 |
from .model_pipeline import PipelineInterface
|
12 |
+
from .state_manager import BasePipelineValidator
|
13 |
|
14 |
|
15 |
def toggleable_slider(
|
|
|
40 |
ui_state: PipelineUIState | None = None,
|
41 |
model_options: list[str] = None,
|
42 |
config: dict = {},
|
43 |
+
validator: BasePipelineValidator | None = None,
|
44 |
):
|
45 |
super().__init__(app, workflow, ui_state, model_options, config, validator)
|
46 |
|
src/envs.py
CHANGED
@@ -17,6 +17,10 @@ QUEUE_REPO = f"{OWNER}/advcal-requests"
|
|
17 |
RESULTS_REPO = f"{OWNER}/model-results" # TODO: change to advcal-results after testing is done
|
18 |
LLM_CACHE_REPO = f"{OWNER}/advcal-llm-cache"
|
19 |
|
|
|
|
|
|
|
|
|
20 |
EXAMPLES_PATH = "examples"
|
21 |
|
22 |
PLAYGROUND_DATASET_NAMES = {
|
|
|
17 |
RESULTS_REPO = f"{OWNER}/model-results" # TODO: change to advcal-results after testing is done
|
18 |
LLM_CACHE_REPO = f"{OWNER}/advcal-llm-cache"
|
19 |
|
20 |
+
DOCS_REPO_URL = "https://github.com/qanta-challenge/QANTA25"
|
21 |
+
DOCS_REPO_BRANCH = "main"
|
22 |
+
|
23 |
+
|
24 |
EXAMPLES_PATH = "examples"
|
25 |
|
26 |
PLAYGROUND_DATASET_NAMES = {
|