-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from awslabs/add-hooks
Add hooks
- Loading branch information
Showing
18 changed files
with
262 additions
and
59 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
::: src.agenteval.hook |
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
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from agenteval.test import Test | ||
from agenteval.test_result import TestResult | ||
from agenteval.trace_handler import TraceHandler | ||
|
||
|
||
class Hook: | ||
"""An evaluation hook.""" | ||
|
||
def pre_evaluate(test: Test, trace: TraceHandler) -> None: | ||
""" | ||
Method called before evaluation. Can be used to perform any setup tasks. | ||
Args: | ||
test (Test): The test case. | ||
trace (TraceHandler): Trace handler for capturing steps during evaluation. | ||
""" | ||
pass | ||
|
||
def post_evaluate(test: Test, test_result: TestResult, trace: TraceHandler) -> None: | ||
""" | ||
Method called after evaluation. This may be used to perform integration testing | ||
or clean up tasks. | ||
Args: | ||
test (Test): The test case. | ||
test_result (TestResult): The result of the test, which can be overriden | ||
by updating the attributes of this object. | ||
trace (TraceHandler): Trace handler for capturing steps during evaluation. | ||
""" | ||
pass |
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .imports import import_class, validate_subclass | ||
|
||
__all__ = ["import_class", "validate_subclass"] |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from importlib import import_module | ||
|
||
|
||
def import_class(module_path: str) -> type: | ||
name, class_name = module_path.rsplit(".", 1) | ||
|
||
return getattr(import_module(name), class_name) | ||
|
||
|
||
def validate_subclass(child_class: type, parent_class: type) -> None: | ||
if not issubclass(child_class, parent_class): | ||
raise TypeError( | ||
f"{child_class.__name__} is not a {parent_class.__name__} subclass" | ||
) |
Oops, something went wrong.