Skip to content

Commit f4f006e

Browse files
committed
Revert "Revert "Centralized the model option for evaluators by creating EvaluatorSettings in base_evaluator.py, added a couple of default=None fixes to avoid type check complaints""
This reverts commit 993963b.
1 parent 993963b commit f4f006e

File tree

36 files changed

+560
-407
lines changed

36 files changed

+560
-407
lines changed

evaluators/aws/langevals_aws/comprehend_pii_detection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from langevals_core.base_evaluator import (
55
BaseEvaluator,
66
EvaluatorEntry,
7+
EvaluatorSettings,
78
SingleEvaluationResult,
89
EvaluationResult,
910
EvaluationResultSkipped,
@@ -56,7 +57,7 @@ class AWSComprehendEntityTypes(BaseModel):
5657
IN_VOTER_NUMBER: bool = True
5758

5859

59-
class AWSComprehendPIIDetectionSettings(BaseModel):
60+
class AWSComprehendPIIDetectionSettings(EvaluatorSettings):
6061
entity_types: AWSComprehendEntityTypes = Field(
6162
default=AWSComprehendEntityTypes(),
6263
description="The types of PII to check for in the input.",
@@ -148,7 +149,7 @@ class AWSPIIEntityResults(TypedDict):
148149
class AWSComprehendPIIDetectionResult(EvaluationResult):
149150
score: float = Field(description="Amount of PII detected, 0 means no PII detected")
150151
passed: Optional[bool] = Field(
151-
description="If true then no PII was detected, if false then at least one PII was detected"
152+
description="If true then no PII was detected, if false then at least one PII was detected", default=None
152153
)
153154
raw_response: AWSPIIEntityResults
154155

evaluators/aws/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evaluators/azure/langevals_azure/content_safety.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from langevals_core.base_evaluator import (
77
BaseEvaluator,
88
EvaluationResult,
9+
EvaluatorSettings,
910
SingleEvaluationResult,
1011
EvaluatorEntry,
1112
EvaluationResultSkipped,
@@ -25,7 +26,7 @@ class AzureContentSafetyCategories(BaseModel):
2526
Violence: bool = True
2627

2728

28-
class AzureContentSafetySettings(BaseModel):
29+
class AzureContentSafetySettings(EvaluatorSettings):
2930
severity_threshold: Literal[1, 2, 3, 4, 5, 6, 7] = Field(
3031
default=1,
3132
description="The minimum severity level to consider content as unsafe, from 1 to 7.",

evaluators/azure/langevals_azure/jailbreak.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
from langevals_core.base_evaluator import (
44
BaseEvaluator,
55
EvaluationResult,
6+
EvaluatorSettings,
67
SingleEvaluationResult,
78
EvaluatorEntry,
89
EvaluationResultSkipped,
910
)
10-
from pydantic import BaseModel, Field
11+
from pydantic import Field
1112

1213

1314
class AzureJailbreakEntry(EvaluatorEntry):
1415
input: str
1516

1617

17-
class AzureJailbreakSettings(BaseModel):
18+
class AzureJailbreakSettings(EvaluatorSettings):
1819
pass
1920

2021

evaluators/azure/langevals_azure/prompt_injection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from langevals_core.base_evaluator import (
44
BaseEvaluator,
55
EvaluationResult,
6+
EvaluatorSettings,
67
SingleEvaluationResult,
78
EvaluatorEntry,
89
EvaluationResultSkipped,
910
)
10-
from pydantic import BaseModel, Field
11+
from pydantic import Field
1112
import math
1213

1314

@@ -16,7 +17,7 @@ class AzurePromptShieldEntry(EvaluatorEntry):
1617
contexts: Optional[List[str]] = None
1718

1819

19-
class AzurePromptShieldSettings(BaseModel):
20+
class AzurePromptShieldSettings(EvaluatorSettings):
2021
pass
2122

2223

evaluators/azure/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evaluators/example/langevals_example/word_count.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
BaseEvaluator,
33
EvaluatorEntry,
44
EvaluationResult,
5+
EvaluatorSettings,
56
SingleEvaluationResult,
67
)
7-
from pydantic import BaseModel, Field
8+
from pydantic import Field
89

910

1011
# Type definition of what keys are necessary for each entry to have for the evaluator to process it, in this example
@@ -14,7 +15,7 @@ class ExampleWordCountEntry(EvaluatorEntry):
1415

1516

1617
# Generic settings for the evaluator, in this example we don't need any settings, but any fields can be added here
17-
class ExampleWordCountSettings(BaseModel):
18+
class ExampleWordCountSettings(EvaluatorSettings):
1819
pass
1920

2021

evaluators/example/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evaluators/google_cloud/langevals_google_cloud/dlp_pii_detection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from langevals_core.base_evaluator import (
44
BaseEvaluator,
55
EvaluatorEntry,
6+
EvaluatorSettings,
67
SingleEvaluationResult,
78
EvaluationResult,
89
EvaluationResultSkipped,
@@ -29,7 +30,7 @@ class GoogleCloudDLPInfoTypes(BaseModel):
2930
medical_record_number: bool = True
3031

3132

32-
class GoogleCloudDLPPIIDetectionSettings(BaseModel):
33+
class GoogleCloudDLPPIIDetectionSettings(EvaluatorSettings):
3334
info_types: GoogleCloudDLPInfoTypes = Field(
3435
default=GoogleCloudDLPInfoTypes(),
3536
description="The types of PII to check for in the input.",
@@ -45,7 +46,7 @@ class GoogleCloudDLPPIIDetectionSettings(BaseModel):
4546
class GoogleCloudDLPPIIDetectionResult(EvaluationResult):
4647
score: float = Field(description="Amount of PII detected, 0 means no PII detected")
4748
passed: Optional[bool] = Field(
48-
description="If true then no PII was detected, if false then at least one PII was detected"
49+
description="If true then no PII was detected, if false then at least one PII was detected", default=None
4950
)
5051
raw_response: dict[str, Any]
5152

evaluators/google_cloud/poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)