-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
from abc import ABC, abstractmethod | ||
from aact import NodeFactory, Node | ||
from .logs import EpisodeLog | ||
from .datamodels import AgentAction, Observation | ||
|
||
|
||
class BaseEvaluator(ABC): | ||
def __init__(self): | ||
pass | ||
@NodeFactory.register("evaluator") | ||
class Evaluator(Node[AgentAction, Observation]): | ||
def __init__( | ||
self, | ||
node_name: str, | ||
input_channels: list[str], | ||
output_channels: list[str], | ||
redis_url: str, | ||
): | ||
super().__init__( | ||
input_channel_types=[ | ||
(input_channel, AgentAction) for input_channel in input_channels | ||
], | ||
output_channel_types=[ | ||
(output_channel, Observation) for output_channel in output_channels | ||
], | ||
node_name=node_name, | ||
redis_url=redis_url, | ||
) | ||
|
||
@abstractmethod | ||
def evaluate(self, epilog: EpisodeLog) -> tuple[float, str]: | ||
""" | ||
evaluate an episode, returns the score and reward prompt | ||
""" | ||
async def aevaluate(self, episode: EpisodeLog) -> AgentAction | None: | ||
raise NotImplementedError | ||
|
||
|
||
class DummyEvaluator(BaseEvaluator): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def evaluate(self, epilog: EpisodeLog) -> tuple[float, str]: | ||
""" | ||
evaluate an episode, returns the score and reward prompt | ||
""" | ||
return 0.0, "No evaluation implemented" |
This file contains 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