mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-08 19:10:56 +00:00
registry refactor
This commit is contained in:
parent
78cb88c3c4
commit
18fe966e96
9 changed files with 60 additions and 106 deletions
|
|
@ -4,3 +4,10 @@
|
|||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
# TODO: make these import config based
|
||||
from llama_stack.apis.evals import * # noqa: F403
|
||||
|
||||
from ..registry import Registry
|
||||
|
||||
|
||||
class ScorerRegistry(Registry[BaseScorer]):
|
||||
_REGISTRY: Dict[str, BaseScorer] = {}
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
from typing import AbstractSet, Dict
|
||||
|
||||
from llama_stack.apis.evals import BaseScorer
|
||||
|
||||
|
||||
class ScorerRegistry:
|
||||
_REGISTRY: Dict[str, BaseScorer] = {}
|
||||
|
||||
@staticmethod
|
||||
def names() -> AbstractSet[str]:
|
||||
return ScorerRegistry._REGISTRY.keys()
|
||||
|
||||
@staticmethod
|
||||
def register(name: str, scorer: BaseScorer) -> None:
|
||||
if name in ScorerRegistry._REGISTRY:
|
||||
raise ValueError(f"Task {name} already exists.")
|
||||
ScorerRegistry._REGISTRY[name] = task
|
||||
|
||||
@staticmethod
|
||||
def get_scorer(name: str) -> BaseScorer:
|
||||
if name not in ScorerRegistry._REGISTRY:
|
||||
raise ValueError(f"Task {name} not found.")
|
||||
return ScorerRegistry._REGISTRY[name]
|
||||
|
||||
@staticmethod
|
||||
def reset() -> None:
|
||||
ScorerRegistry._REGISTRY = {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue