Function bodies 14 total
list_datasets function · python · L17-L23 (7 LOC)src/aumai_alignment/api.py
def list_datasets(
query: str = "",
category: str | None = None,
min_quality: float = 0.0,
) -> list[MarketplaceListing]:
"""List and search alignment datasets."""
return _registry.search(query=query, category=category, min_quality=min_quality)get_dataset function · python · L27-L32 (6 LOC)src/aumai_alignment/api.py
def get_dataset(dataset_id: str) -> AlignmentDataset:
"""Retrieve a single dataset by ID."""
try:
return _registry.get(dataset_id)
except DatasetNotFoundError as exc:
raise HTTPException(status_code=404, detail=f"Dataset '{dataset_id}' not found") from excget_evaluations function · python · L43-L49 (7 LOC)src/aumai_alignment/api.py
def get_evaluations(dataset_id: str) -> list[EvaluationResult]:
"""Get all evaluation results for a dataset."""
try:
_registry.get(dataset_id)
except DatasetNotFoundError as exc:
raise HTTPException(status_code=404, detail=f"Dataset '{dataset_id}' not found") from exc
return _runner.get_results(dataset_id)search function · python · L28-L39 (12 LOC)src/aumai_alignment/cli.py
def search(query: str, category: str | None, min_quality: float) -> None:
"""Search for alignment datasets in the registry."""
results = _registry.search(query=query, category=category, min_quality=min_quality)
if not results:
click.echo("No datasets found matching your criteria.")
return
for listing in results:
ds = listing.dataset
click.echo(
f"[{ds.dataset_id}] {ds.name} quality={ds.quality_score:.2f}"
f" downloads={listing.downloads} tags={','.join(ds.tags)}"
)register function · python · L49-L61 (13 LOC)src/aumai_alignment/cli.py
def register(config: Path) -> None:
"""Register a dataset from a YAML or JSON config file."""
import yaml # type: ignore[import-untyped]
raw = config.read_text(encoding="utf-8")
if config.suffix in {".yaml", ".yml"}:
data: dict[str, object] = yaml.safe_load(raw)
else:
data = json.loads(raw)
dataset = AlignmentDataset.model_validate(data)
_registry.register(dataset)
click.echo(f"Registered dataset '{dataset.name}' with ID '{dataset.dataset_id}'.")serve function · python · L67-L76 (10 LOC)src/aumai_alignment/cli.py
def serve(port: int, host: str) -> None:
"""Start the alignment marketplace API server."""
try:
import uvicorn # type: ignore[import-untyped]
except ImportError:
click.echo("uvicorn is required to run the server. Install it with: pip install uvicorn", err=True)
sys.exit(1)
click.echo(f"Starting aumai-alignment API on http://{host}:{port}")
uvicorn.run("aumai_alignment.api:app", host=host, port=port, reload=False)DatasetRegistry.register method · python · L29-L45 (17 LOC)src/aumai_alignment/core.py
def register(self, dataset: AlignmentDataset) -> None:
"""Register a dataset and create a marketplace listing for it.
Args:
dataset: The alignment dataset to register.
"""
self._datasets[dataset.dataset_id] = dataset
if dataset.dataset_id not in self._listings:
self._listings[dataset.dataset_id] = MarketplaceListing(dataset=dataset)
else:
existing = self._listings[dataset.dataset_id]
self._listings[dataset.dataset_id] = MarketplaceListing(
dataset=dataset,
downloads=existing.downloads,
rating=existing.rating,
reviews=existing.reviews,
)Repobility · open methodology · https://repobility.com/research/
DatasetRegistry.search method · python · L47-L81 (35 LOC)src/aumai_alignment/core.py
def search(
self,
query: str,
category: str | None = None,
min_quality: float = 0.0,
) -> list[MarketplaceListing]:
"""Search and filter marketplace listings.
Args:
query: Text query matched against name, description, and tags.
category: Optional category filter.
min_quality: Minimum quality score threshold (0.0–1.0).
Returns:
Sorted list of matching marketplace listings (descending quality).
"""
query_lower = query.lower().strip()
results: list[MarketplaceListing] = []
for listing in self._listings.values():
dataset = listing.dataset
if dataset.quality_score < min_quality:
continue
if category is not None and dataset.category.lower() != category.lower():
continue
if query_lower:
searchable = " ".join(
[dataset.name, dataset.deDatasetRegistry.get method · python · L83-L98 (16 LOC)src/aumai_alignment/core.py
def get(self, dataset_id: str) -> AlignmentDataset:
"""Retrieve a dataset by ID.
Args:
dataset_id: The unique dataset identifier.
Returns:
The AlignmentDataset.
Raises:
DatasetNotFoundError: If the dataset is not found.
"""
try:
return self._datasets[dataset_id]
except KeyError as exc:
raise DatasetNotFoundError(dataset_id) from excDatasetRegistry.increment_downloads method · python · L100-L113 (14 LOC)src/aumai_alignment/core.py
def increment_downloads(self, dataset_id: str) -> None:
"""Increment the download counter for a dataset.
Args:
dataset_id: The unique dataset identifier.
"""
if dataset_id in self._listings:
listing = self._listings[dataset_id]
self._listings[dataset_id] = MarketplaceListing(
dataset=listing.dataset,
downloads=listing.downloads + 1,
rating=listing.rating,
reviews=listing.reviews,
)_default_scorer function · python · L119-L124 (6 LOC)src/aumai_alignment/core.py
def _default_scorer(output: dict[str, str | float | bool]) -> float:
"""Default scoring: check presence of 'score' key or return 0.5."""
raw = output.get("score", 0.5)
if isinstance(raw, (int, float)):
return max(0.0, min(1.0, float(raw)))
return 0.5EvaluationRunner.__init__ method · python · L130-L137 (8 LOC)src/aumai_alignment/core.py
def __init__(
self,
registry: DatasetRegistry,
scoring_fn: ScoringFunction | None = None,
) -> None:
self._registry = registry
self._scoring_fn: ScoringFunction = scoring_fn or _default_scorer
self._results: dict[str, list[EvaluationResult]] = {}EvaluationRunner.evaluate method · python · L139-L183 (45 LOC)src/aumai_alignment/core.py
def evaluate(
self,
dataset_id: str,
model_outputs: list[dict[str, str | float | bool]],
model_name: str = "unknown",
) -> EvaluationResult:
"""Evaluate model outputs against a dataset.
Args:
dataset_id: The dataset to evaluate against.
model_outputs: List of output dicts from the model.
model_name: Name of the model being evaluated.
Returns:
An EvaluationResult with aggregate score and per-metric breakdowns.
Raises:
DatasetNotFoundError: If dataset_id is not registered.
"""
self._registry.get(dataset_id) # validates existence
if not model_outputs:
scores: list[float] = []
else:
scores = [self._scoring_fn(output) for output in model_outputs]
aggregate_score = sum(scores) / len(scores) if scores else 0.0
metrics: dict[str, float] = {
"mean_score": aggregate_score,
EvaluationRunner.get_results method · python · L185-L194 (10 LOC)src/aumai_alignment/core.py
def get_results(self, dataset_id: str) -> list[EvaluationResult]:
"""Retrieve all evaluation results for a dataset.
Args:
dataset_id: The dataset identifier.
Returns:
List of EvaluationResult objects (may be empty).
"""
return self._results.get(dataset_id, [])