-
Notifications
You must be signed in to change notification settings - Fork 605
feat: add ART MCP-RL taskset adapter #2003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frvade
wants to merge
3
commits into
PrimeIntellect-ai:main
Choose a base branch
from
frvade:feat/art-mcp-taskset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| """ART MCP-RL scenario taskset adapter.""" | ||
|
|
||
| from verifiers.v1.tasksets.art_mcp.taskset import ( | ||
| ArtMCPTask, | ||
| ArtMCPTaskData, | ||
| ArtMCPTaskset, | ||
| ArtMCPTasksetConfig, | ||
| art_rows_from_tasks, | ||
| load_art_rows, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "ArtMCPTask", | ||
| "ArtMCPTaskData", | ||
| "ArtMCPTaskset", | ||
| "ArtMCPTasksetConfig", | ||
| "art_rows_from_tasks", | ||
| "load_art_rows", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| """Taskset adapter for OpenPipe ART MCP-RL scenario files. | ||
|
|
||
| ART MCP-RL stores generated scenarios as JSON/JSONL rows with a natural-language | ||
| ``task`` and optional metadata such as ``difficulty``. This module maps those | ||
| rows into native verifiers v1 tasks while preserving enough structured data to | ||
| export them back to ART-style rows. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from typing import Any, Iterable | ||
|
|
||
| from pydantic import Field | ||
|
|
||
| import verifiers.v1 as vf | ||
|
|
||
|
|
||
| class ArtMCPTaskData(vf.TaskData): | ||
| source_task: str | ||
| difficulty: int = 1 | ||
| art_metadata: dict[str, Any] = Field(default_factory=dict) | ||
|
|
||
|
|
||
| class ArtMCPTask(vf.Task[ArtMCPTaskData]): | ||
| pass | ||
|
|
||
|
|
||
| class ArtMCPTasksetConfig(vf.TasksetConfig): | ||
| path: str | ||
| system_prompt: str | None = None | ||
|
|
||
|
|
||
| def _read_rows(path: Path) -> Iterable[dict[str, Any]]: | ||
| if path.suffix == ".jsonl": | ||
| for line in path.read_text().splitlines(): | ||
| if line.strip(): | ||
| yield json.loads(line) | ||
| return | ||
|
|
||
| data = json.loads(path.read_text()) | ||
| if isinstance(data, list): | ||
| yield from data | ||
| return | ||
| if isinstance(data, dict): | ||
| rows = data.get("scenarios") | ||
| if not isinstance(rows, list): | ||
| rows = data.get("tasks") | ||
| if isinstance(rows, list): | ||
| yield from rows | ||
| return | ||
| raise ValueError(f"unsupported ART scenario file shape: {path}") | ||
|
|
||
|
|
||
| def load_art_rows(path: str | Path) -> list[dict[str, Any]]: | ||
| rows = list(_read_rows(Path(path))) | ||
| for idx, row in enumerate(rows): | ||
| if not isinstance(row, dict): | ||
| raise ValueError(f"row {idx} must be a JSON object") | ||
| task = row.get("task") | ||
| if not isinstance(task, str) or not task.strip(): | ||
| raise ValueError(f"row {idx} missing non-empty 'task'") | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| difficulty = row.get("difficulty", 1) | ||
| if not isinstance(difficulty, int) or difficulty < 1: | ||
| raise ValueError(f"row {idx} has invalid difficulty: {difficulty!r}") | ||
| return rows | ||
|
|
||
|
|
||
| def art_rows_from_tasks(tasks: Iterable[ArtMCPTask]) -> list[dict[str, Any]]: | ||
| rows: list[dict[str, Any]] = [] | ||
| for task in tasks: | ||
| row = dict(task.data.art_metadata) | ||
| row["task"] = task.data.source_task | ||
| row["difficulty"] = task.data.difficulty | ||
| rows.append(row) | ||
| return rows | ||
|
|
||
|
|
||
| class ArtMCPTaskset(vf.Taskset[ArtMCPTask, ArtMCPTasksetConfig]): | ||
| def load(self) -> list[ArtMCPTask]: | ||
| return [ | ||
| ArtMCPTask( | ||
| ArtMCPTaskData( | ||
| idx=i, | ||
| prompt=row["task"], | ||
| system_prompt=self.config.system_prompt, | ||
| source_task=row["task"], | ||
| difficulty=row.get("difficulty", 1), | ||
| art_metadata={ | ||
| key: value | ||
| for key, value in row.items() | ||
| if key not in {"task", "difficulty"} | ||
| }, | ||
| ), | ||
| self.config.task, | ||
| ) | ||
| for i, row in enumerate(load_art_rows(self.config.path)) | ||
| ] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.