Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
analysis
  • Loading branch information
MilesHolland committed Oct 25, 2024
commit 8ee553491c9e5522dfc330c01beb7e1e183b73a8
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
version = "unknown"
USER_AGENT = "{}/{}".format("azure-ai-evaluation", version)

USER_TEXT_TEMPLATE_DICT = {
USER_TEXT_TEMPLATE_DICT: Dict[str, Template] = {
"DEFAULT": Template("<Human>{$query}</><System>{$response}</>"),
Tasks.GROUNDEDNESS: Template('{"question": "$query", "answer": "$response", "context": "$context"}'),
}
Expand Down Expand Up @@ -104,7 +104,7 @@ async def ensure_service_availability(rai_svc_url: str, token: str, capability:
)


def generate_payload(normalized_user_text: str, metric: str, annotation_task: Tasks) -> Dict:
def generate_payload(normalized_user_text: str, metric: str, annotation_task: str) -> Dict:
"""Generate the payload for the annotation request

:param normalized_user_text: The normalized user text to be entered as the "UserTextList" in the payload.
Expand Down Expand Up @@ -432,7 +432,7 @@ async def evaluate_with_rai_service(
metric_name: str,
project_scope: AzureAIProject,
credential: TokenCredential,
annotation_task: Tasks = Tasks.CONTENT_HARM,
annotation_task: str = Tasks.CONTENT_HARM,
metric_display_name=None,
) -> Dict[str, Union[str, float]]:
""" "Evaluate the content safety of the response using Responsible AI service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Dict, Optional, TypeVar, Union
from typing import Dict, Optional, Union

from typing_extensions import override

Expand All @@ -18,7 +18,7 @@

from . import EvaluatorBase

T = TypeVar("T")
T = Union[str, float]


class RaiServiceEvaluatorBase(EvaluatorBase[T]):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -11,7 +11,7 @@


@experimental
class HateUnfairnessEvaluator(RaiServiceEvaluatorBase[Union[str, float]]):
class HateUnfairnessEvaluator(RaiServiceEvaluatorBase):
"""
Initialize a hate-unfairness evaluator for hate unfairness score.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -11,7 +11,7 @@


@experimental
class SelfHarmEvaluator(RaiServiceEvaluatorBase[Union[str, float]]):
class SelfHarmEvaluator(RaiServiceEvaluatorBase):
"""
Initialize a self harm evaluator for self harm score.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -11,7 +11,7 @@


@experimental
class SexualEvaluator(RaiServiceEvaluatorBase[Union[str, float]]):
class SexualEvaluator(RaiServiceEvaluatorBase):
"""
Initialize a sexual evaluator for sexual score.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -11,7 +11,7 @@


@experimental
class ViolenceEvaluator(RaiServiceEvaluatorBase[Union[str, float]]):
class ViolenceEvaluator(RaiServiceEvaluatorBase):
"""
Initialize a violence evaluator for violence score.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@experimental
class ECIEvaluator(RaiServiceEvaluatorBase[str]):
class ECIEvaluator(RaiServiceEvaluatorBase):
"""
Initialize an ECI evaluator to evaluate ECI based on the following guidelines:
Detects whether ECI is present without a disclaimer in the AI system’s response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -12,7 +12,7 @@


@experimental
class ProtectedMaterialEvaluator(RaiServiceEvaluatorBase[Union[str, bool]]):
class ProtectedMaterialEvaluator(RaiServiceEvaluatorBase):
"""
Initialize a protected material evaluator to detect whether protected material
is present in your AI system's response. Outputs True or False with AI-generated reasoning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
import logging
from typing import Optional, Union
from typing import Optional

from typing_extensions import override

Expand All @@ -14,7 +14,7 @@


@experimental
class IndirectAttackEvaluator(RaiServiceEvaluatorBase[Union[str, bool]]):
class IndirectAttackEvaluator(RaiServiceEvaluatorBase):
"""A Cross-Domain Prompt Injection Attack (XPIA) jailbreak evaluator.

Detect whether cross domain injected attacks are present in your AI system's response.
Expand Down