-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ModelConfig type as a temporary solution. (#2836)
# Description In this PR we are removing types from the evaluator constructors as a temporary solution, before AzureOpenAIModelConfiguration type in the evaluator constructor will be officially supported. # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [x] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [x] Pull request includes test coverage for the included changes.
- Loading branch information
Showing
13 changed files
with
57 additions
and
27 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
4 changes: 1 addition & 3 deletions
4
src/promptflow-evals/promptflow/evals/evaluators/content_safety/hate_unfairness.py
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
4 changes: 1 addition & 3 deletions
4
src/promptflow-evals/promptflow/evals/evaluators/content_safety/self_harm.py
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
4 changes: 1 addition & 3 deletions
4
src/promptflow-evals/promptflow/evals/evaluators/content_safety/sexual.py
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
4 changes: 1 addition & 3 deletions
4
src/promptflow-evals/promptflow/evals/evaluators/content_safety/violence.py
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
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
38 changes: 38 additions & 0 deletions
38
src/promptflow-evals/tests/evals/unittests/test_save_eval.py
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,38 @@ | ||
from typing import Any, List, Optional, Type | ||
|
||
import inspect | ||
import os | ||
import pytest | ||
|
||
from promptflow.evals import evaluators | ||
from promptflow.evals.evaluators import content_safety | ||
|
||
|
||
def get_evaluators_from_module(namespace: Any, exceptions: Optional[List[str]] = None) -> List[Type]: | ||
evaluators = [] | ||
for name, obj in inspect.getmembers(namespace): | ||
if inspect.isclass(obj): | ||
if exceptions and name in exceptions: | ||
continue | ||
evaluators.append(obj) | ||
return evaluators | ||
|
||
|
||
@pytest.mark.unittest | ||
class TestSaveEval: | ||
"""Test saving evaluators.""" | ||
|
||
EVALUATORS = get_evaluators_from_module(evaluators) | ||
RAI_EVALUATORS = get_evaluators_from_module(content_safety) | ||
|
||
@pytest.mark.parametrize('evaluator', EVALUATORS) | ||
def test_save_evaluators(self, tmpdir, pf_client, evaluator) -> None: | ||
"""Test regular evaluator saving.""" | ||
pf_client.flows.save(evaluator, path=tmpdir) | ||
assert os.path.isfile(os.path.join(tmpdir, 'flow.flex.yaml')) | ||
|
||
@pytest.mark.parametrize('rai_evaluator', RAI_EVALUATORS) | ||
def test_save_rai_evaluators(self, tmpdir, pf_client, rai_evaluator): | ||
"""Test saving of RAI evaluators""" | ||
pf_client.flows.save(rai_evaluator, path=tmpdir) | ||
assert os.path.isfile(os.path.join(tmpdir, 'flow.flex.yaml')) |