Spaces:
Running
Running
Yacine Jernite
commited on
Commit
·
0fea185
1
Parent(s):
36b410a
default vals
Browse files- ui/tab_dataset.py +6 -2
- ui/tab_policy.py +1 -1
- ui/tab_testing.py +1 -1
- utils/dataset.py +3 -3
ui/tab_dataset.py
CHANGED
|
@@ -34,7 +34,7 @@ def format_preview_markdown(example: dict) -> str:
|
|
| 34 |
label_text = "⚠️ Unable to determine label"
|
| 35 |
|
| 36 |
# Truncate policy preview
|
| 37 |
-
policy_preview = policy[:
|
| 38 |
|
| 39 |
markdown = f"""## Example Preview
|
| 40 |
|
|
@@ -44,11 +44,15 @@ def format_preview_markdown(example: dict) -> str:
|
|
| 44 |
### Model
|
| 45 |
{model_name}
|
| 46 |
|
|
|
|
|
|
|
| 47 |
### Prediction
|
| 48 |
**{label_text}**
|
| 49 |
|
| 50 |
{categories_and_reasoning}
|
| 51 |
|
|
|
|
|
|
|
| 52 |
### Policy Preview
|
| 53 |
{policy_preview}
|
| 54 |
"""
|
|
@@ -57,7 +61,7 @@ def format_preview_markdown(example: dict) -> str:
|
|
| 57 |
|
| 58 |
def build_dataset_tab() -> dict:
|
| 59 |
"""Build the dataset tab UI."""
|
| 60 |
-
with gr.Tab("📊
|
| 61 |
gr.Markdown(
|
| 62 |
"Browse saved test results. Select an example to load it back into the app "
|
| 63 |
"with all original settings for reproducibility."
|
|
|
|
| 34 |
label_text = "⚠️ Unable to determine label"
|
| 35 |
|
| 36 |
# Truncate policy preview
|
| 37 |
+
policy_preview = policy # [:512] + "..." if len(policy) > 512 else policy
|
| 38 |
|
| 39 |
markdown = f"""## Example Preview
|
| 40 |
|
|
|
|
| 44 |
### Model
|
| 45 |
{model_name}
|
| 46 |
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
### Prediction
|
| 50 |
**{label_text}**
|
| 51 |
|
| 52 |
{categories_and_reasoning}
|
| 53 |
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
### Policy Preview
|
| 57 |
{policy_preview}
|
| 58 |
"""
|
|
|
|
| 61 |
|
| 62 |
def build_dataset_tab() -> dict:
|
| 63 |
"""Build the dataset tab UI."""
|
| 64 |
+
with gr.Tab("📊 Saved Examples"):
|
| 65 |
gr.Markdown(
|
| 66 |
"Browse saved test results. Select an example to load it back into the app "
|
| 67 |
"with all original settings for reproducibility."
|
ui/tab_policy.py
CHANGED
|
@@ -31,7 +31,7 @@ def build_policy_tab(base_dir: str) -> dict:
|
|
| 31 |
upload_file = gr.File(label="Upload Markdown File", file_types=[".md"])
|
| 32 |
|
| 33 |
# Manual Edition Accordion
|
| 34 |
-
with gr.Accordion("✏️ Manual
|
| 35 |
manual_text = gr.Textbox(
|
| 36 |
label="Policy Text",
|
| 37 |
placeholder="Enter or edit policy markdown...",
|
|
|
|
| 31 |
upload_file = gr.File(label="Upload Markdown File", file_types=[".md"])
|
| 32 |
|
| 33 |
# Manual Edition Accordion
|
| 34 |
+
with gr.Accordion("✏️ Manual Editing", open=False):
|
| 35 |
manual_text = gr.Textbox(
|
| 36 |
label="Policy Text",
|
| 37 |
placeholder="Enter or edit policy markdown...",
|
ui/tab_testing.py
CHANGED
|
@@ -133,7 +133,7 @@ def build_testing_tab() -> dict:
|
|
| 133 |
gr.Markdown("### Input")
|
| 134 |
with gr.Group():
|
| 135 |
test_input = gr.Textbox(label="Test Content", placeholder="Enter content to test...", lines=5)
|
| 136 |
-
example_dropdown = gr.Dropdown(label="Load Example", choices=list(TEST_EXAMPLES.keys()))
|
| 137 |
load_example_btn = gr.Button("Load Example", variant="secondary")
|
| 138 |
run_test_btn = gr.Button("Run Test", variant="primary")
|
| 139 |
save_mode = gr.Radio(
|
|
|
|
| 133 |
gr.Markdown("### Input")
|
| 134 |
with gr.Group():
|
| 135 |
test_input = gr.Textbox(label="Test Content", placeholder="Enter content to test...", lines=5)
|
| 136 |
+
example_dropdown = gr.Dropdown(label="Load Example", choices=list(TEST_EXAMPLES.keys()), value=None)
|
| 137 |
load_example_btn = gr.Button("Load Example", variant="secondary")
|
| 138 |
run_test_btn = gr.Button("Run Test", variant="primary")
|
| 139 |
save_mode = gr.Radio(
|
utils/dataset.py
CHANGED
|
@@ -128,15 +128,15 @@ def save_to_dataset(token: str | None, data: dict) -> tuple[bool, str]:
|
|
| 128 |
# Create new dataset with all examples
|
| 129 |
dataset = Dataset.from_list(examples)
|
| 130 |
|
| 131 |
-
# Push to hub
|
| 132 |
-
dataset.push_to_hub(repo_id, token=token)
|
| 133 |
return True, f"Saved to {repo_id}"
|
| 134 |
except FileNotFoundError:
|
| 135 |
# Dataset doesn't exist yet, create new one
|
| 136 |
try:
|
| 137 |
repo_id = get_dataset_repo_id(token)
|
| 138 |
dataset = Dataset.from_list([data])
|
| 139 |
-
dataset.push_to_hub(repo_id, token=token)
|
| 140 |
return True, f"Saved to {repo_id}"
|
| 141 |
except Exception as e:
|
| 142 |
return False, f"Failed to create new dataset: {str(e)}"
|
|
|
|
| 128 |
# Create new dataset with all examples
|
| 129 |
dataset = Dataset.from_list(examples)
|
| 130 |
|
| 131 |
+
# Push to hub (private by default)
|
| 132 |
+
dataset.push_to_hub(repo_id, token=token, private=True)
|
| 133 |
return True, f"Saved to {repo_id}"
|
| 134 |
except FileNotFoundError:
|
| 135 |
# Dataset doesn't exist yet, create new one
|
| 136 |
try:
|
| 137 |
repo_id = get_dataset_repo_id(token)
|
| 138 |
dataset = Dataset.from_list([data])
|
| 139 |
+
dataset.push_to_hub(repo_id, token=token, private=True)
|
| 140 |
return True, f"Saved to {repo_id}"
|
| 141 |
except Exception as e:
|
| 142 |
return False, f"Failed to create new dataset: {str(e)}"
|