azure-ai-evaluation 1.0.0b2__py3-none-any.whl → 1.13.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of azure-ai-evaluation might be problematic. Click here for more details.
- azure/ai/evaluation/__init__.py +100 -5
- azure/ai/evaluation/{_evaluators/_chat → _aoai}/__init__.py +3 -2
- azure/ai/evaluation/_aoai/aoai_grader.py +140 -0
- azure/ai/evaluation/_aoai/label_grader.py +68 -0
- azure/ai/evaluation/_aoai/python_grader.py +86 -0
- azure/ai/evaluation/_aoai/score_model_grader.py +94 -0
- azure/ai/evaluation/_aoai/string_check_grader.py +66 -0
- azure/ai/evaluation/_aoai/text_similarity_grader.py +80 -0
- azure/ai/evaluation/_azure/__init__.py +3 -0
- azure/ai/evaluation/_azure/_clients.py +204 -0
- azure/ai/evaluation/_azure/_envs.py +207 -0
- azure/ai/evaluation/_azure/_models.py +227 -0
- azure/ai/evaluation/_azure/_token_manager.py +129 -0
- azure/ai/evaluation/_common/__init__.py +9 -1
- azure/ai/evaluation/{simulator/_helpers → _common}/_experimental.py +24 -9
- azure/ai/evaluation/_common/constants.py +131 -2
- azure/ai/evaluation/_common/evaluation_onedp_client.py +169 -0
- azure/ai/evaluation/_common/math.py +89 -0
- azure/ai/evaluation/_common/onedp/__init__.py +32 -0
- azure/ai/evaluation/_common/onedp/_client.py +166 -0
- azure/ai/evaluation/_common/onedp/_configuration.py +72 -0
- azure/ai/evaluation/_common/onedp/_model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/_serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_types.py +21 -0
- azure/ai/evaluation/_common/onedp/_utils/__init__.py +6 -0
- azure/ai/evaluation/_common/onedp/_utils/model_base.py +1232 -0
- azure/ai/evaluation/_common/onedp/_utils/serialization.py +2032 -0
- azure/ai/evaluation/_common/onedp/_validation.py +66 -0
- azure/ai/evaluation/_common/onedp/_vendor.py +50 -0
- azure/ai/evaluation/_common/onedp/_version.py +9 -0
- azure/ai/evaluation/_common/onedp/aio/__init__.py +29 -0
- azure/ai/evaluation/_common/onedp/aio/_client.py +168 -0
- azure/ai/evaluation/_common/onedp/aio/_configuration.py +72 -0
- azure/ai/evaluation/_common/onedp/aio/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/aio/operations/__init__.py +49 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_operations.py +7143 -0
- azure/ai/evaluation/_common/onedp/aio/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/models/__init__.py +358 -0
- azure/ai/evaluation/_common/onedp/models/_enums.py +447 -0
- azure/ai/evaluation/_common/onedp/models/_models.py +5963 -0
- azure/ai/evaluation/_common/onedp/models/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/operations/__init__.py +49 -0
- azure/ai/evaluation/_common/onedp/operations/_operations.py +8951 -0
- azure/ai/evaluation/_common/onedp/operations/_patch.py +21 -0
- azure/ai/evaluation/_common/onedp/py.typed +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/__init__.py +1 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/__init__.py +22 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_operations.py +29 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/buildingblocks/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_operations.py +34 -0
- azure/ai/evaluation/_common/onedp/servicepatterns/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/rai_service.py +831 -142
- azure/ai/evaluation/_common/raiclient/__init__.py +34 -0
- azure/ai/evaluation/_common/raiclient/_client.py +128 -0
- azure/ai/evaluation/_common/raiclient/_configuration.py +87 -0
- azure/ai/evaluation/_common/raiclient/_model_base.py +1235 -0
- azure/ai/evaluation/_common/raiclient/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/_serialization.py +2050 -0
- azure/ai/evaluation/_common/raiclient/_version.py +9 -0
- azure/ai/evaluation/_common/raiclient/aio/__init__.py +29 -0
- azure/ai/evaluation/_common/raiclient/aio/_client.py +130 -0
- azure/ai/evaluation/_common/raiclient/aio/_configuration.py +87 -0
- azure/ai/evaluation/_common/raiclient/aio/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/_operations.py +981 -0
- azure/ai/evaluation/_common/raiclient/aio/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/models/__init__.py +60 -0
- azure/ai/evaluation/_common/raiclient/models/_enums.py +18 -0
- azure/ai/evaluation/_common/raiclient/models/_models.py +651 -0
- azure/ai/evaluation/_common/raiclient/models/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/operations/__init__.py +25 -0
- azure/ai/evaluation/_common/raiclient/operations/_operations.py +1238 -0
- azure/ai/evaluation/_common/raiclient/operations/_patch.py +20 -0
- azure/ai/evaluation/_common/raiclient/py.typed +1 -0
- azure/ai/evaluation/_common/utils.py +870 -34
- azure/ai/evaluation/_constants.py +167 -6
- azure/ai/evaluation/_converters/__init__.py +3 -0
- azure/ai/evaluation/_converters/_ai_services.py +899 -0
- azure/ai/evaluation/_converters/_models.py +467 -0
- azure/ai/evaluation/_converters/_sk_services.py +495 -0
- azure/ai/evaluation/_eval_mapping.py +83 -0
- azure/ai/evaluation/_evaluate/_batch_run/__init__.py +17 -0
- azure/ai/evaluation/_evaluate/_batch_run/_run_submitter_client.py +176 -0
- azure/ai/evaluation/_evaluate/_batch_run/batch_clients.py +82 -0
- azure/ai/evaluation/_evaluate/{_batch_run_client → _batch_run}/code_client.py +47 -25
- azure/ai/evaluation/_evaluate/{_batch_run_client/batch_run_context.py → _batch_run/eval_run_context.py} +42 -13
- azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +124 -0
- azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +62 -0
- azure/ai/evaluation/_evaluate/_eval_run.py +102 -59
- azure/ai/evaluation/_evaluate/_evaluate.py +2134 -311
- azure/ai/evaluation/_evaluate/_evaluate_aoai.py +992 -0
- azure/ai/evaluation/_evaluate/_telemetry/__init__.py +14 -99
- azure/ai/evaluation/_evaluate/_utils.py +289 -40
- azure/ai/evaluation/_evaluator_definition.py +76 -0
- azure/ai/evaluation/_evaluators/_bleu/_bleu.py +93 -42
- azure/ai/evaluation/_evaluators/_code_vulnerability/__init__.py +5 -0
- azure/ai/evaluation/_evaluators/_code_vulnerability/_code_vulnerability.py +119 -0
- azure/ai/evaluation/_evaluators/_coherence/_coherence.py +117 -91
- azure/ai/evaluation/_evaluators/_coherence/coherence.prompty +76 -39
- azure/ai/evaluation/_evaluators/_common/__init__.py +15 -0
- azure/ai/evaluation/_evaluators/_common/_base_eval.py +742 -0
- azure/ai/evaluation/_evaluators/_common/_base_multi_eval.py +63 -0
- azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +345 -0
- azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +198 -0
- azure/ai/evaluation/_evaluators/_common/_conversation_aggregators.py +49 -0
- azure/ai/evaluation/_evaluators/_content_safety/__init__.py +0 -4
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +144 -86
- azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +138 -57
- azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +123 -55
- azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +133 -54
- azure/ai/evaluation/_evaluators/_content_safety/_violence.py +134 -54
- azure/ai/evaluation/_evaluators/_document_retrieval/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_document_retrieval/_document_retrieval.py +442 -0
- azure/ai/evaluation/_evaluators/_eci/_eci.py +49 -56
- azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +102 -60
- azure/ai/evaluation/_evaluators/_fluency/_fluency.py +115 -92
- azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +66 -41
- azure/ai/evaluation/_evaluators/_gleu/_gleu.py +90 -37
- azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +318 -82
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +114 -0
- azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +104 -0
- azure/ai/evaluation/{_evaluate/_batch_run_client → _evaluators/_intent_resolution}/__init__.py +3 -4
- azure/ai/evaluation/_evaluators/_intent_resolution/_intent_resolution.py +196 -0
- azure/ai/evaluation/_evaluators/_intent_resolution/intent_resolution.prompty +275 -0
- azure/ai/evaluation/_evaluators/_meteor/_meteor.py +107 -61
- azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +104 -77
- azure/ai/evaluation/_evaluators/_qa/_qa.py +115 -63
- azure/ai/evaluation/_evaluators/_relevance/_relevance.py +182 -98
- azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +178 -49
- azure/ai/evaluation/_evaluators/_response_completeness/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_response_completeness/_response_completeness.py +202 -0
- azure/ai/evaluation/_evaluators/_response_completeness/response_completeness.prompty +84 -0
- azure/ai/evaluation/_evaluators/{_chat/retrieval → _retrieval}/__init__.py +2 -2
- azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +148 -0
- azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +93 -0
- azure/ai/evaluation/_evaluators/_rouge/_rouge.py +189 -50
- azure/ai/evaluation/_evaluators/_service_groundedness/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +179 -0
- azure/ai/evaluation/_evaluators/_similarity/_similarity.py +102 -91
- azure/ai/evaluation/_evaluators/_similarity/similarity.prompty +0 -5
- azure/ai/evaluation/_evaluators/_task_adherence/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_adherence/_task_adherence.py +226 -0
- azure/ai/evaluation/_evaluators/_task_adherence/task_adherence.prompty +101 -0
- azure/ai/evaluation/_evaluators/_task_completion/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_completion/_task_completion.py +177 -0
- azure/ai/evaluation/_evaluators/_task_completion/task_completion.prompty +220 -0
- azure/ai/evaluation/_evaluators/_task_navigation_efficiency/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_task_navigation_efficiency/_task_navigation_efficiency.py +384 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/_tool_call_accuracy.py +298 -0
- azure/ai/evaluation/_evaluators/_tool_call_accuracy/tool_call_accuracy.prompty +166 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/_tool_input_accuracy.py +263 -0
- azure/ai/evaluation/_evaluators/_tool_input_accuracy/tool_input_accuracy.prompty +76 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/_tool_output_utilization.py +225 -0
- azure/ai/evaluation/_evaluators/_tool_output_utilization/tool_output_utilization.prompty +221 -0
- azure/ai/evaluation/_evaluators/_tool_selection/__init__.py +9 -0
- azure/ai/evaluation/_evaluators/_tool_selection/_tool_selection.py +266 -0
- azure/ai/evaluation/_evaluators/_tool_selection/tool_selection.prompty +104 -0
- azure/ai/evaluation/_evaluators/_tool_success/__init__.py +7 -0
- azure/ai/evaluation/_evaluators/_tool_success/_tool_success.py +301 -0
- azure/ai/evaluation/_evaluators/_tool_success/tool_success.prompty +321 -0
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/__init__.py +5 -0
- azure/ai/evaluation/_evaluators/_ungrounded_attributes/_ungrounded_attributes.py +102 -0
- azure/ai/evaluation/_evaluators/_xpia/xpia.py +109 -107
- azure/ai/evaluation/_exceptions.py +51 -7
- azure/ai/evaluation/_http_utils.py +210 -137
- azure/ai/evaluation/_legacy/__init__.py +3 -0
- azure/ai/evaluation/_legacy/_adapters/__init__.py +7 -0
- azure/ai/evaluation/_legacy/_adapters/_check.py +17 -0
- azure/ai/evaluation/_legacy/_adapters/_configuration.py +45 -0
- azure/ai/evaluation/_legacy/_adapters/_constants.py +10 -0
- azure/ai/evaluation/_legacy/_adapters/_errors.py +29 -0
- azure/ai/evaluation/_legacy/_adapters/_flows.py +28 -0
- azure/ai/evaluation/_legacy/_adapters/_service.py +16 -0
- azure/ai/evaluation/_legacy/_adapters/client.py +51 -0
- azure/ai/evaluation/_legacy/_adapters/entities.py +26 -0
- azure/ai/evaluation/_legacy/_adapters/tracing.py +28 -0
- azure/ai/evaluation/_legacy/_adapters/types.py +15 -0
- azure/ai/evaluation/_legacy/_adapters/utils.py +31 -0
- azure/ai/evaluation/_legacy/_batch_engine/__init__.py +9 -0
- azure/ai/evaluation/_legacy/_batch_engine/_config.py +48 -0
- azure/ai/evaluation/_legacy/_batch_engine/_engine.py +477 -0
- azure/ai/evaluation/_legacy/_batch_engine/_exceptions.py +88 -0
- azure/ai/evaluation/_legacy/_batch_engine/_openai_injector.py +132 -0
- azure/ai/evaluation/_legacy/_batch_engine/_result.py +107 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run.py +127 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run_storage.py +128 -0
- azure/ai/evaluation/_legacy/_batch_engine/_run_submitter.py +262 -0
- azure/ai/evaluation/_legacy/_batch_engine/_status.py +25 -0
- azure/ai/evaluation/_legacy/_batch_engine/_trace.py +97 -0
- azure/ai/evaluation/_legacy/_batch_engine/_utils.py +97 -0
- azure/ai/evaluation/_legacy/_batch_engine/_utils_deprecated.py +131 -0
- azure/ai/evaluation/_legacy/_common/__init__.py +3 -0
- azure/ai/evaluation/_legacy/_common/_async_token_provider.py +117 -0
- azure/ai/evaluation/_legacy/_common/_logging.py +292 -0
- azure/ai/evaluation/_legacy/_common/_thread_pool_executor_with_context.py +17 -0
- azure/ai/evaluation/_legacy/prompty/__init__.py +36 -0
- azure/ai/evaluation/_legacy/prompty/_connection.py +119 -0
- azure/ai/evaluation/_legacy/prompty/_exceptions.py +139 -0
- azure/ai/evaluation/_legacy/prompty/_prompty.py +430 -0
- azure/ai/evaluation/_legacy/prompty/_utils.py +663 -0
- azure/ai/evaluation/_legacy/prompty/_yaml_utils.py +99 -0
- azure/ai/evaluation/_model_configurations.py +130 -8
- azure/ai/evaluation/_safety_evaluation/__init__.py +3 -0
- azure/ai/evaluation/_safety_evaluation/_generated_rai_client.py +0 -0
- azure/ai/evaluation/_safety_evaluation/_safety_evaluation.py +917 -0
- azure/ai/evaluation/_user_agent.py +32 -1
- azure/ai/evaluation/_vendor/__init__.py +3 -0
- azure/ai/evaluation/_vendor/rouge_score/__init__.py +14 -0
- azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +324 -0
- azure/ai/evaluation/_vendor/rouge_score/scoring.py +59 -0
- azure/ai/evaluation/_vendor/rouge_score/tokenize.py +59 -0
- azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +53 -0
- azure/ai/evaluation/_version.py +2 -1
- azure/ai/evaluation/red_team/__init__.py +22 -0
- azure/ai/evaluation/red_team/_agent/__init__.py +3 -0
- azure/ai/evaluation/red_team/_agent/_agent_functions.py +261 -0
- azure/ai/evaluation/red_team/_agent/_agent_tools.py +461 -0
- azure/ai/evaluation/red_team/_agent/_agent_utils.py +89 -0
- azure/ai/evaluation/red_team/_agent/_semantic_kernel_plugin.py +228 -0
- azure/ai/evaluation/red_team/_attack_objective_generator.py +268 -0
- azure/ai/evaluation/red_team/_attack_strategy.py +49 -0
- azure/ai/evaluation/red_team/_callback_chat_target.py +115 -0
- azure/ai/evaluation/red_team/_default_converter.py +21 -0
- azure/ai/evaluation/red_team/_evaluation_processor.py +505 -0
- azure/ai/evaluation/red_team/_mlflow_integration.py +430 -0
- azure/ai/evaluation/red_team/_orchestrator_manager.py +803 -0
- azure/ai/evaluation/red_team/_red_team.py +1717 -0
- azure/ai/evaluation/red_team/_red_team_result.py +661 -0
- azure/ai/evaluation/red_team/_result_processor.py +1708 -0
- azure/ai/evaluation/red_team/_utils/__init__.py +37 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_eval_chat_target.py +128 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_target.py +601 -0
- azure/ai/evaluation/red_team/_utils/_rai_service_true_false_scorer.py +114 -0
- azure/ai/evaluation/red_team/_utils/constants.py +72 -0
- azure/ai/evaluation/red_team/_utils/exception_utils.py +345 -0
- azure/ai/evaluation/red_team/_utils/file_utils.py +266 -0
- azure/ai/evaluation/red_team/_utils/formatting_utils.py +365 -0
- azure/ai/evaluation/red_team/_utils/logging_utils.py +139 -0
- azure/ai/evaluation/red_team/_utils/metric_mapping.py +73 -0
- azure/ai/evaluation/red_team/_utils/objective_utils.py +46 -0
- azure/ai/evaluation/red_team/_utils/progress_utils.py +252 -0
- azure/ai/evaluation/red_team/_utils/retry_utils.py +218 -0
- azure/ai/evaluation/red_team/_utils/strategy_utils.py +218 -0
- azure/ai/evaluation/simulator/__init__.py +2 -1
- azure/ai/evaluation/simulator/_adversarial_scenario.py +26 -1
- azure/ai/evaluation/simulator/_adversarial_simulator.py +270 -144
- azure/ai/evaluation/simulator/_constants.py +12 -1
- azure/ai/evaluation/simulator/_conversation/__init__.py +151 -23
- azure/ai/evaluation/simulator/_conversation/_conversation.py +10 -6
- azure/ai/evaluation/simulator/_conversation/constants.py +1 -1
- azure/ai/evaluation/simulator/_data_sources/__init__.py +3 -0
- azure/ai/evaluation/simulator/_data_sources/grounding.json +1150 -0
- azure/ai/evaluation/simulator/_direct_attack_simulator.py +54 -75
- azure/ai/evaluation/simulator/_helpers/__init__.py +1 -2
- azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py +1 -0
- azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +26 -5
- azure/ai/evaluation/simulator/_indirect_attack_simulator.py +145 -104
- azure/ai/evaluation/simulator/_model_tools/__init__.py +2 -1
- azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py +225 -0
- azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +80 -30
- azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +117 -45
- azure/ai/evaluation/simulator/_model_tools/_rai_client.py +109 -7
- azure/ai/evaluation/simulator/_model_tools/_template_handler.py +97 -33
- azure/ai/evaluation/simulator/_model_tools/models.py +30 -27
- azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +6 -10
- azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +6 -5
- azure/ai/evaluation/simulator/_simulator.py +302 -208
- azure/ai/evaluation/simulator/_utils.py +31 -13
- azure_ai_evaluation-1.13.3.dist-info/METADATA +939 -0
- azure_ai_evaluation-1.13.3.dist-info/RECORD +305 -0
- {azure_ai_evaluation-1.0.0b2.dist-info → azure_ai_evaluation-1.13.3.dist-info}/WHEEL +1 -1
- azure_ai_evaluation-1.13.3.dist-info/licenses/NOTICE.txt +70 -0
- azure/ai/evaluation/_evaluate/_batch_run_client/proxy_client.py +0 -71
- azure/ai/evaluation/_evaluators/_chat/_chat.py +0 -357
- azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py +0 -157
- azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty +0 -48
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety_base.py +0 -65
- azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +0 -301
- azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +0 -54
- azure/ai/evaluation/_evaluators/_protected_materials/__init__.py +0 -5
- azure/ai/evaluation/_evaluators/_protected_materials/_protected_materials.py +0 -104
- azure/ai/evaluation/simulator/_tracing.py +0 -89
- azure_ai_evaluation-1.0.0b2.dist-info/METADATA +0 -449
- azure_ai_evaluation-1.0.0b2.dist-info/RECORD +0 -99
- {azure_ai_evaluation-1.0.0b2.dist-info → azure_ai_evaluation-1.13.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Groundedness
|
|
3
|
+
description: Evaluates groundedness score for RAG scenario
|
|
4
|
+
model:
|
|
5
|
+
api: chat
|
|
6
|
+
parameters:
|
|
7
|
+
temperature: 0.0
|
|
8
|
+
max_tokens: 800
|
|
9
|
+
top_p: 1.0
|
|
10
|
+
presence_penalty: 0
|
|
11
|
+
frequency_penalty: 0
|
|
12
|
+
response_format:
|
|
13
|
+
type: text
|
|
14
|
+
|
|
15
|
+
inputs:
|
|
16
|
+
query:
|
|
17
|
+
type: string
|
|
18
|
+
response:
|
|
19
|
+
type: string
|
|
20
|
+
context:
|
|
21
|
+
type: string
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
system:
|
|
26
|
+
# Instruction
|
|
27
|
+
## Goal
|
|
28
|
+
### You are an expert in evaluating the quality of a RESPONSE from an intelligent system based on provided definition and data. Your goal will involve answering the questions below using the information provided.
|
|
29
|
+
- **Definition**: You are given a definition of the communication trait that is being evaluated to help guide your Score.
|
|
30
|
+
- **Data**: Your input data include CONTEXT, QUERY, and RESPONSE.
|
|
31
|
+
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
|
|
32
|
+
|
|
33
|
+
user:
|
|
34
|
+
# Definition
|
|
35
|
+
**Groundedness** refers to how well an answer is anchored in the provided context, evaluating its relevance, accuracy, and completeness based exclusively on that context. It assesses the extent to which the answer directly and fully addresses the question without introducing unrelated or incorrect information.
|
|
36
|
+
|
|
37
|
+
> Context is the source of truth for evaluating the response. If it's empty, rely on the tool results in the response and query.
|
|
38
|
+
> Evaluate the groundedness of the response message, not the chat history.
|
|
39
|
+
|
|
40
|
+
# Ratings
|
|
41
|
+
## [Groundedness: 1] (Completely Unrelated Response)
|
|
42
|
+
**Definition:** An answer that does not relate to the question or the context in any way.
|
|
43
|
+
- Does not relate to the question or context at all.
|
|
44
|
+
- Talks about the general topic but does not respond to the query.
|
|
45
|
+
|
|
46
|
+
**Examples:**
|
|
47
|
+
**Context:** The company's annual meeting will be held next Thursday.
|
|
48
|
+
**Query:** When is the company's annual meeting?
|
|
49
|
+
**Response:** I enjoy hiking in the mountains during summer.
|
|
50
|
+
|
|
51
|
+
**Context:** The museum will exhibit modern art pieces from various local artists.
|
|
52
|
+
**Query:** What kind of art will be exhibited at the museum?
|
|
53
|
+
**Response:** Museums are important cultural institutions.
|
|
54
|
+
|
|
55
|
+
## [Groundedness: 2] (Attempts to Respond but Contains Incorrect Information)
|
|
56
|
+
**Definition:** An answer that attempts to respond to the question but includes incorrect information not supported by the context. It may misstate facts, misinterpret the context, or provide erroneous details. Even if some points are correct, the presence of inaccuracies makes the response unreliable.
|
|
57
|
+
|
|
58
|
+
**Examples:**
|
|
59
|
+
**Context:** - The festival starts on June 5th and features international musicians.
|
|
60
|
+
**Query:** When does the festival start?
|
|
61
|
+
**Response:** The festival starts on July 5th and features local artists.
|
|
62
|
+
|
|
63
|
+
**Context:** bakery_menu.txt: - Croissant au Beurre — flaky, buttery croissant
|
|
64
|
+
**Query:** [{"role":"user","content":"Are there croissants?"}]
|
|
65
|
+
**Response:** [{"role":"assistant","content":"Yes, Croissant au Beurre is on the menu, served with jam."}]
|
|
66
|
+
|
|
67
|
+
## [Groundedness: 3] (Nothing to be Grounded)
|
|
68
|
+
Definition: An answer that does not provide any information that can be evaluated against the context. This includes responses that are asking for clarification, providing polite fillers, or follow-up questions.
|
|
69
|
+
|
|
70
|
+
**Examples:**
|
|
71
|
+
**Context:**
|
|
72
|
+
**Query:** [{"role":"user","content":"How many eggs are needed for the recipe?"}, {"role":"tool","content":"tool_result": [{"file_name": "recipe.txt", "content": "The recipe requires two eggs and one cup of milk."}]}, {"role":"assistant","content":"You need three eggs for the recipe."}, {"role":"user","content":"Thank you."}]
|
|
73
|
+
**Response:** [{"role":"assistant","content":"You're welcome, anything else I can help with?"}]
|
|
74
|
+
|
|
75
|
+
## [Groundedness: 4] (Partially Correct Response)
|
|
76
|
+
**Definition:** An answer that provides a correct response to the question but is incomplete or lacks specific details mentioned in the context. It captures some of the necessary information but omits key elements needed for a full understanding.
|
|
77
|
+
|
|
78
|
+
**Examples:**
|
|
79
|
+
**Context:** - store_details.txt: The bookstore offers a 15% discount to students and a 10% discount to senior citizens.
|
|
80
|
+
**Query:** [{"role":"user","content":"What discount does the bookstore offer to students, if any?"}]
|
|
81
|
+
**Response:** [{"role":"assistant","content":"Yes, students get a discount at the bookstore."}]
|
|
82
|
+
|
|
83
|
+
**Context:** The company's headquarters are located in Berlin, Germany.
|
|
84
|
+
**Query:** Where are the company's headquarters?
|
|
85
|
+
**Response:** The company's headquarters are in Germany.
|
|
86
|
+
|
|
87
|
+
## [Groundedness: 5] (Fully Correct and Complete Response)
|
|
88
|
+
**Definition:** An answer that thoroughly and accurately responds to the question, including all relevant details from the context. It directly addresses the question with precise information, demonstrating complete understanding without adding extraneous information.
|
|
89
|
+
|
|
90
|
+
**Examples:**
|
|
91
|
+
**CONTEXT:** The author released her latest novel, 'The Silent Echo', on September 1st.
|
|
92
|
+
**QUERY:** [{"role":"user","content":"When was 'The Silent Echo' released?"}]
|
|
93
|
+
**RESPONSE:** [{"role":"assistant","content":"The 'Silent Echo' was released on September 1st."}]
|
|
94
|
+
|
|
95
|
+
**Context:**
|
|
96
|
+
**Query:** By what date must participants register to receive early bird pricing?
|
|
97
|
+
**Response:** [{"role":"tool","content":"tool_result": [{"file_name": "store_guidelines.txt", "content": "Participants registering before and including May 31st will be eligible for early bird pricing."}]}, {"role":"assistant","content":"Participants must register by May 31st to receive early bird pricing."}]
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Data
|
|
101
|
+
CONTEXT: {{context}}
|
|
102
|
+
QUERY: {{query}}
|
|
103
|
+
RESPONSE: {{response}}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Tasks
|
|
107
|
+
## Please provide your assessment Score for the previous RESPONSE message in relation to the CONTEXT, QUERY and RESPONSE tools based on the Definitions above. Your output should include the following information:
|
|
108
|
+
- **ThoughtChain**: To improve the reasoning process, think step by step and include a step-by-step explanation of your thought process as you analyze the data based on the definitions. Keep it brief and start your ThoughtChain with "Let's think step by step:".
|
|
109
|
+
- **Explanation**: a very short explanation of why you think the input Data should get that Score.
|
|
110
|
+
- **Score**: based on your previous analysis, provide your Score. The Score you give MUST be a integer score (i.e., "1", "2"...) based on the levels of the definitions.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Please provide your answers between the tags: <S0>your chain of thoughts</S0>, <S1>your explanation</S1>, <S2>your Score</S2>.
|
|
114
|
+
# Output
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Groundedness
|
|
3
|
+
description: Evaluates groundedness score for RAG scenario
|
|
4
|
+
model:
|
|
5
|
+
api: chat
|
|
6
|
+
parameters:
|
|
7
|
+
temperature: 0.0
|
|
8
|
+
max_tokens: 800
|
|
9
|
+
top_p: 1.0
|
|
10
|
+
presence_penalty: 0
|
|
11
|
+
frequency_penalty: 0
|
|
12
|
+
response_format:
|
|
13
|
+
type: text
|
|
14
|
+
|
|
15
|
+
inputs:
|
|
16
|
+
response:
|
|
17
|
+
type: string
|
|
18
|
+
context:
|
|
19
|
+
type: string
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
system:
|
|
23
|
+
# Instruction
|
|
24
|
+
## Goal
|
|
25
|
+
### You are an expert in evaluating the quality of a RESPONSE from an intelligent system based on provided definition and data. Your goal will involve answering the questions below using the information provided.
|
|
26
|
+
- **Definition**: You are given a definition of the communication trait that is being evaluated to help guide your Score.
|
|
27
|
+
- **Data**: Your input data include CONTEXT and RESPONSE.
|
|
28
|
+
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
|
|
29
|
+
|
|
30
|
+
user:
|
|
31
|
+
# Definition
|
|
32
|
+
**Groundedness** refers to how well a response is anchored in the provided context, evaluating its relevance, accuracy, and completeness based exclusively on that context. It assesses the extent to which the response directly and fully addresses the information without introducing unrelated or incorrect information.
|
|
33
|
+
|
|
34
|
+
> Context is the source of truth for evaluating the response.
|
|
35
|
+
> Evaluate the groundedness of the response message based on the provided context.
|
|
36
|
+
|
|
37
|
+
# Ratings
|
|
38
|
+
## [Groundedness: 1] (Completely Unrelated Response)
|
|
39
|
+
**Definition:** A response that does not relate to the context in any way.
|
|
40
|
+
- Does not relate to the context at all.
|
|
41
|
+
- Talks about the general topic but does not respond to the context.
|
|
42
|
+
|
|
43
|
+
**Examples:**
|
|
44
|
+
**Context:** The company's profits increased by 20% in the last quarter.
|
|
45
|
+
**Response:** I enjoy playing soccer on weekends with my friends.
|
|
46
|
+
|
|
47
|
+
**Context:** The new smartphone model features a larger display and improved battery life.
|
|
48
|
+
**Response:** The history of ancient Egypt is fascinating and full of mysteries.
|
|
49
|
+
|
|
50
|
+
## [Groundedness: 2] (Attempts to Respond but Contains Incorrect Information)
|
|
51
|
+
**Definition:** A response that attempts to relate to the context but includes incorrect information not supported by the context. It may misstate facts, misinterpret the context, or provide erroneous details. Even if some points are correct, the presence of inaccuracies makes the response unreliable.
|
|
52
|
+
|
|
53
|
+
**Examples:**
|
|
54
|
+
**Context:** The company's profits increased by 20% in the last quarter.
|
|
55
|
+
**Response:** The company's profits decreased by 20% in the last quarter.
|
|
56
|
+
|
|
57
|
+
**Context:** The new smartphone model features a larger display and improved battery life.
|
|
58
|
+
**Response:** The new smartphone model has a smaller display and shorter battery life.
|
|
59
|
+
|
|
60
|
+
## [Groundedness: 3] (Accurate but Vague Response)
|
|
61
|
+
**Definition:** A response that provides accurate information from the context but is overly generic or vague, not meaningfully engaging with the specific details in the context. The information is correct but lacks specificity and detail.
|
|
62
|
+
|
|
63
|
+
**Examples:**
|
|
64
|
+
**Context:** The company's profits increased by 20% in the last quarter, marking the highest growth rate in its history.
|
|
65
|
+
**Response:** The company is doing well financially.
|
|
66
|
+
|
|
67
|
+
**Context:** The new smartphone model features a larger display, improved battery life, and an upgraded camera system.
|
|
68
|
+
**Response:** The smartphone has some nice features.
|
|
69
|
+
|
|
70
|
+
## [Groundedness: 4] (Partially Correct Response)
|
|
71
|
+
**Definition:** A response that provides correct information from the context but is incomplete or lacks specific details mentioned in the context. It captures some of the necessary information but omits key elements needed for a full understanding.
|
|
72
|
+
|
|
73
|
+
**Examples:**
|
|
74
|
+
**Context:** The company's profits increased by 20% in the last quarter, marking the highest growth rate in its history.
|
|
75
|
+
**Response:** The company's profits increased by 20% in the last quarter.
|
|
76
|
+
|
|
77
|
+
**Context:** The new smartphone model features a larger display, improved battery life, and an upgraded camera system.
|
|
78
|
+
**Response:** The new smartphone model features a larger display and improved battery life.
|
|
79
|
+
|
|
80
|
+
## [Groundedness: 5] (Fully Grounded and Complete Response)
|
|
81
|
+
**Definition:** A response that thoroughly and accurately conveys information from the context, including all relevant details. It directly addresses the context with precise information, demonstrating complete understanding without adding extraneous information.
|
|
82
|
+
|
|
83
|
+
**Examples:**
|
|
84
|
+
**Context:** The company's profits increased by 20% in the last quarter, marking the highest growth rate in its history.
|
|
85
|
+
**Response:** The company's profits increased by 20% in the last quarter, marking the highest growth rate in its history.
|
|
86
|
+
|
|
87
|
+
**Context:** The new smartphone model features a larger display, improved battery life, and an upgraded camera system.
|
|
88
|
+
**Response:** The new smartphone model features a larger display, improved battery life, and an upgraded camera system.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# Data
|
|
92
|
+
CONTEXT: {{context}}
|
|
93
|
+
RESPONSE: {{response}}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# Tasks
|
|
97
|
+
## Please provide your assessment Score for the previous RESPONSE in relation to the CONTEXT based on the Definitions above. Your output should include the following information:
|
|
98
|
+
- **ThoughtChain**: To improve the reasoning process, think step by step and include a step-by-step explanation of your thought process as you analyze the data based on the definitions. Keep it brief and start your ThoughtChain with "Let's think step by step:".
|
|
99
|
+
- **Explanation**: a very short explanation of why you think the input Data should get that Score.
|
|
100
|
+
- **Score**: based on your previous analysis, provide your Score. The Score you give MUST be a integer score (i.e., "1", "2"...) based on the levels of the definitions.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
## Please provide your answers between the tags: <S0>your chain of thoughts</S0>, <S1>your explanation</S1>, <S2>your Score</S2>.
|
|
104
|
+
# Output
|
azure/ai/evaluation/{_evaluate/_batch_run_client → _evaluators/_intent_resolution}/__init__.py
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# ---------------------------------------------------------
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# ---------------------------------------------------------
|
|
4
|
-
from .batch_run_context import BatchRunContext
|
|
5
|
-
from .code_client import CodeClient
|
|
6
|
-
from .proxy_client import ProxyClient
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
from ._intent_resolution import IntentResolutionEvaluator
|
|
6
|
+
|
|
7
|
+
__all__ = ["IntentResolutionEvaluator"]
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# ---------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# ---------------------------------------------------------
|
|
4
|
+
import os
|
|
5
|
+
import math
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Dict, Union, List, Optional
|
|
8
|
+
|
|
9
|
+
from typing_extensions import overload, override
|
|
10
|
+
|
|
11
|
+
from azure.ai.evaluation._exceptions import EvaluationException, ErrorBlame, ErrorCategory, ErrorTarget
|
|
12
|
+
from azure.ai.evaluation._evaluators._common import PromptyEvaluatorBase
|
|
13
|
+
from azure.ai.evaluation._model_configurations import Conversation, Message
|
|
14
|
+
from ..._common.utils import check_score_is_valid, reformat_conversation_history, reformat_agent_response
|
|
15
|
+
from azure.ai.evaluation._common._experimental import experimental
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@experimental
|
|
21
|
+
class IntentResolutionEvaluator(PromptyEvaluatorBase[Union[str, float]]):
|
|
22
|
+
"""
|
|
23
|
+
Evaluates intent resolution for a given query and response or a multi-turn conversation, including reasoning.
|
|
24
|
+
|
|
25
|
+
The intent resolution evaluator assesses whether the user intent was correctly identified and resolved.
|
|
26
|
+
|
|
27
|
+
:param model_config: Configuration for the Azure OpenAI model.
|
|
28
|
+
:type model_config: Union[~azure.ai.evaluation.AzureOpenAIModelConfiguration,
|
|
29
|
+
~azure.ai.evaluation.OpenAIModelConfiguration]
|
|
30
|
+
|
|
31
|
+
.. admonition:: Example:
|
|
32
|
+
|
|
33
|
+
.. literalinclude:: ../samples/evaluation_samples_evaluate.py
|
|
34
|
+
:start-after: [START intent_resolution_evaluator]
|
|
35
|
+
:end-before: [END intent_resolution_evaluator]
|
|
36
|
+
:language: python
|
|
37
|
+
:dedent: 8
|
|
38
|
+
:caption: Initialize and call an IntentResolutionEvaluator with a query and response.
|
|
39
|
+
|
|
40
|
+
.. admonition:: Example using Azure AI Project URL:
|
|
41
|
+
|
|
42
|
+
.. literalinclude:: ../samples/evaluation_samples_evaluate_fdp.py
|
|
43
|
+
:start-after: [START intent_resolution_evaluator]
|
|
44
|
+
:end-before: [END intent_resolution_evaluator]
|
|
45
|
+
:language: python
|
|
46
|
+
:dedent: 8
|
|
47
|
+
:caption: Initialize and call IntentResolutionEvaluator using Azure AI Project URL in the following format
|
|
48
|
+
https://{resource_name}.services.ai.azure.com/api/projects/{project_name}
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
_PROMPTY_FILE = "intent_resolution.prompty"
|
|
53
|
+
_RESULT_KEY = "intent_resolution"
|
|
54
|
+
_OPTIONAL_PARAMS = ["tool_definitions"]
|
|
55
|
+
|
|
56
|
+
_MIN_INTENT_RESOLUTION_SCORE = 1
|
|
57
|
+
_MAX_INTENT_RESOLUTION_SCORE = 5
|
|
58
|
+
_DEFAULT_INTENT_RESOLUTION_THRESHOLD = 3
|
|
59
|
+
|
|
60
|
+
id = "azureai://built-in/evaluators/intent_resolution"
|
|
61
|
+
"""Evaluator identifier, experimental and to be used only with evaluation in cloud."""
|
|
62
|
+
|
|
63
|
+
@override
|
|
64
|
+
def __init__(self, model_config, *, threshold=_DEFAULT_INTENT_RESOLUTION_THRESHOLD, credential=None, **kwargs):
|
|
65
|
+
current_dir = os.path.dirname(__file__)
|
|
66
|
+
prompty_path = os.path.join(current_dir, self._PROMPTY_FILE)
|
|
67
|
+
self.threshold = threshold
|
|
68
|
+
super().__init__(
|
|
69
|
+
model_config=model_config,
|
|
70
|
+
prompty_file=prompty_path,
|
|
71
|
+
result_key=self._RESULT_KEY,
|
|
72
|
+
threshold=threshold,
|
|
73
|
+
credential=credential,
|
|
74
|
+
_higher_is_better=True,
|
|
75
|
+
**kwargs,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
@overload
|
|
79
|
+
def __call__(
|
|
80
|
+
self,
|
|
81
|
+
*,
|
|
82
|
+
query: Union[str, List[dict]],
|
|
83
|
+
response: Union[str, List[dict]],
|
|
84
|
+
tool_definitions: Optional[Union[dict, List[dict]]] = None,
|
|
85
|
+
) -> Dict[str, Union[str, float]]:
|
|
86
|
+
"""Evaluate intent resolution for a given query, response and optional tool definitions.
|
|
87
|
+
The query and response can be either a string or a list of messages.
|
|
88
|
+
|
|
89
|
+
Example with string inputs and no tools:
|
|
90
|
+
evaluator = IntentResolutionEvaluator(model_config)
|
|
91
|
+
query = "What is the weather today?"
|
|
92
|
+
response = "The weather is sunny."
|
|
93
|
+
|
|
94
|
+
result = evaluator(query=query, response=response)
|
|
95
|
+
|
|
96
|
+
Example with list of messages:
|
|
97
|
+
evaluator = IntentResolutionEvaluator(model_config)
|
|
98
|
+
query: [{'role': 'system', 'content': 'You are a friendly and helpful customer service agent.'}, {'createdAt': 1700000060, 'role': 'user', 'content': [{'type': 'text', 'text': 'Hi, I need help with the last 2 orders on my account #888. Could you please update me on their status?'}]}]
|
|
99
|
+
response: [{'createdAt': 1700000070, 'run_id': '0', 'role': 'assistant', 'content': [{'type': 'text', 'text': 'Hello! Let me quickly look up your account details.'}]}, {'createdAt': 1700000075, 'run_id': '0', 'role': 'assistant', 'content': [{'type': 'tool_call', 'tool_call': {'id': 'tool_call_20250310_001', 'type': 'function', 'function': {'name': 'get_orders', 'arguments': {'account_number': '888'}}}}]}, {'createdAt': 1700000080, 'run_id': '0', 'tool_call_id': 'tool_call_20250310_001', 'role': 'tool', 'content': [{'type': 'tool_result', 'tool_result': '[{ "order_id": "123" }, { "order_id": "124" }]'}]}, {'createdAt': 1700000085, 'run_id': '0', 'role': 'assistant', 'content': [{'type': 'text', 'text': 'Thanks for your patience. I see two orders on your account. Let me fetch the details for both.'}]}, {'createdAt': 1700000090, 'run_id': '0', 'role': 'assistant', 'content': [{'type': 'tool_call', 'tool_call': {'id': 'tool_call_20250310_002', 'type': 'function', 'function': {'name': 'get_order', 'arguments': {'order_id': '123'}}}}, {'type': 'tool_call', 'tool_call': {'id': 'tool_call_20250310_003', 'type': 'function', 'function': {'name': 'get_order', 'arguments': {'order_id': '124'}}}}]}, {'createdAt': 1700000095, 'run_id': '0', 'tool_call_id': 'tool_call_20250310_002', 'role': 'tool', 'content': [{'type': 'tool_result', 'tool_result': '{ "order": { "id": "123", "status": "shipped", "delivery_date": "2025-03-15" } }'}]}, {'createdAt': 1700000100, 'run_id': '0', 'tool_call_id': 'tool_call_20250310_003', 'role': 'tool', 'content': [{'type': 'tool_result', 'tool_result': '{ "order": { "id": "124", "status": "delayed", "expected_delivery": "2025-03-20" } }'}]}, {'createdAt': 1700000105, 'run_id': '0', 'role': 'assistant', 'content': [{'type': 'text', 'text': 'The order with ID 123 has been shipped and is expected to be delivered on March 15, 2025. However, the order with ID 124 is delayed and should now arrive by March 20, 2025. Is there anything else I can help you with?'}]}]
|
|
100
|
+
tool_definitions: [{'name': 'get_orders', 'description': 'Get the list of orders for a given account number.', 'parameters': {'type': 'object', 'properties': {'account_number': {'type': 'string', 'description': 'The account number to get the orders for.'}}}}, {'name': 'get_order', 'description': 'Get the details of a specific order.', 'parameters': {'type': 'object', 'properties': {'order_id': {'type': 'string', 'description': 'The order ID to get the details for.'}}}}, {'name': 'initiate_return', 'description': 'Initiate the return process for an order.', 'parameters': {'type': 'object', 'properties': {'order_id': {'type': 'string', 'description': 'The order ID for the return process.'}}}}, {'name': 'update_shipping_address', 'description': 'Update the shipping address for a given account.', 'parameters': {'type': 'object', 'properties': {'account_number': {'type': 'string', 'description': 'The account number to update.'}, 'new_address': {'type': 'string', 'description': 'The new shipping address.'}}}}]
|
|
101
|
+
|
|
102
|
+
result = evaluator(query=query, response=response, tool_definitions=tool_definitions)
|
|
103
|
+
|
|
104
|
+
:keyword query: The query to be evaluated which is either a string or a list of messages.
|
|
105
|
+
The list of messages is the previous conversation history of the user and agent, including system messages and tool calls.
|
|
106
|
+
:paramtype query: Union[str, List[dict]]
|
|
107
|
+
:keyword response: The response to be evaluated, which is either a string or a list of messages (full agent response potentially including tool calls)
|
|
108
|
+
:paramtype response: Union[str, List[dict]]
|
|
109
|
+
:keyword tool_definitions: An optional list of messages containing the tool definitions the agent is aware of.
|
|
110
|
+
:paramtype tool_definitions: Optional[Union[dict, List[dict]]]
|
|
111
|
+
:return: A dictionary with the intent resolution evaluation
|
|
112
|
+
:rtype: Dict[str, Union[str, float]]
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
@override
|
|
116
|
+
def __call__( # pylint: disable=docstring-missing-param
|
|
117
|
+
self,
|
|
118
|
+
*args,
|
|
119
|
+
**kwargs,
|
|
120
|
+
):
|
|
121
|
+
"""
|
|
122
|
+
Invokes the instance using the overloaded __call__ signature.
|
|
123
|
+
|
|
124
|
+
For detailed parameter types and return value documentation, see the overloaded __call__ definition.
|
|
125
|
+
"""
|
|
126
|
+
return super().__call__(*args, **kwargs)
|
|
127
|
+
|
|
128
|
+
@override
|
|
129
|
+
async def _do_eval(self, eval_input: Dict) -> Dict[str, Union[float, str]]: # type: ignore[override]
|
|
130
|
+
"""Do intent resolution evaluation.
|
|
131
|
+
|
|
132
|
+
:param eval_input: The input to the evaluator. Expected to contain whatever inputs are needed for the _flow method
|
|
133
|
+
:type eval_input: Dict
|
|
134
|
+
:return: The evaluation result.
|
|
135
|
+
:rtype: Dict
|
|
136
|
+
"""
|
|
137
|
+
# we override the _do_eval method as we want the output to be a dictionary, which is a different schema than _base_prompty_eval.py
|
|
138
|
+
if "query" not in eval_input and "response" not in eval_input:
|
|
139
|
+
raise EvaluationException(
|
|
140
|
+
message=f"Both query and response must be provided as input to the intent resolution evaluator.",
|
|
141
|
+
internal_message=f"Both query and response must be provided as input to the intent resolution evaluator.",
|
|
142
|
+
blame=ErrorBlame.USER_ERROR,
|
|
143
|
+
category=ErrorCategory.MISSING_FIELD,
|
|
144
|
+
target=ErrorTarget.INTENT_RESOLUTION_EVALUATOR,
|
|
145
|
+
)
|
|
146
|
+
# reformat query and response to the format expected by the prompty flow
|
|
147
|
+
eval_input["query"] = reformat_conversation_history(eval_input["query"], logger)
|
|
148
|
+
eval_input["response"] = reformat_agent_response(eval_input["response"], logger)
|
|
149
|
+
|
|
150
|
+
prompty_output_dict = await self._flow(timeout=self._LLM_CALL_TIMEOUT, **eval_input)
|
|
151
|
+
llm_output = prompty_output_dict["llm_output"]
|
|
152
|
+
# llm_output should always be a dictionary because the response_format of prompty is set to json_object, but checking anyway
|
|
153
|
+
score = math.nan
|
|
154
|
+
if isinstance(llm_output, dict):
|
|
155
|
+
score = llm_output.get("score", math.nan)
|
|
156
|
+
if not check_score_is_valid(
|
|
157
|
+
score,
|
|
158
|
+
IntentResolutionEvaluator._MIN_INTENT_RESOLUTION_SCORE,
|
|
159
|
+
IntentResolutionEvaluator._MAX_INTENT_RESOLUTION_SCORE,
|
|
160
|
+
):
|
|
161
|
+
raise EvaluationException(
|
|
162
|
+
message=f"Invalid score value: {score}. Expected a number in range [{IntentResolutionEvaluator._MIN_INTENT_RESOLUTION_SCORE}, {IntentResolutionEvaluator._MAX_INTENT_RESOLUTION_SCORE}].",
|
|
163
|
+
internal_message="Invalid score value.",
|
|
164
|
+
category=ErrorCategory.FAILED_EXECUTION,
|
|
165
|
+
blame=ErrorBlame.SYSTEM_ERROR,
|
|
166
|
+
)
|
|
167
|
+
reason = llm_output.get("explanation", "")
|
|
168
|
+
score = float(score)
|
|
169
|
+
score_result = "pass" if score >= self._threshold else "fail"
|
|
170
|
+
|
|
171
|
+
response_dict = {
|
|
172
|
+
f"{self._result_key}": score,
|
|
173
|
+
f"gpt_{self._result_key}": score,
|
|
174
|
+
f"{self._result_key}_result": score_result,
|
|
175
|
+
f"{self._result_key}_threshold": self._threshold,
|
|
176
|
+
f"{self._result_key}_reason": reason,
|
|
177
|
+
f"{self._result_key}_prompt_tokens": prompty_output_dict.get("input_token_count", 0),
|
|
178
|
+
f"{self._result_key}_completion_tokens": prompty_output_dict.get("output_token_count", 0),
|
|
179
|
+
f"{self._result_key}_total_tokens": prompty_output_dict.get("total_token_count", 0),
|
|
180
|
+
f"{self._result_key}_finish_reason": prompty_output_dict.get("finish_reason", ""),
|
|
181
|
+
f"{self._result_key}_model": prompty_output_dict.get("model_id", ""),
|
|
182
|
+
f"{self._result_key}_sample_input": prompty_output_dict.get("sample_input", ""),
|
|
183
|
+
f"{self._result_key}_sample_output": prompty_output_dict.get("sample_output", ""),
|
|
184
|
+
}
|
|
185
|
+
return response_dict
|
|
186
|
+
# If llm_output is not a dictionary, return NaN for the score. This should never happen
|
|
187
|
+
if logger:
|
|
188
|
+
logger.warning("LLM output is not a dictionary, returning NaN for the score.")
|
|
189
|
+
|
|
190
|
+
binary_result = self._get_binary_result(score)
|
|
191
|
+
return {
|
|
192
|
+
self._result_key: float(score),
|
|
193
|
+
f"gpt_{self._result_key}": float(score),
|
|
194
|
+
f"{self._result_key}_result": binary_result,
|
|
195
|
+
f"{self._result_key}_threshold": self._threshold,
|
|
196
|
+
}
|