Skip to content

Commit 4a50187

Browse files
Copilotsingankit
andcommitted
Move user_agent parameter from public interface to kwargs
Co-authored-by: singankit <[email protected]>
1 parent 5cc642a commit 4a50187

File tree

3 files changed

+6
-92
lines changed

3 files changed

+6
-92
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluate/_evaluate.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ def evaluate(
697697
azure_ai_project: Optional[Union[str, AzureAIProject]] = None,
698698
output_path: Optional[Union[str, os.PathLike]] = None,
699699
fail_on_evaluator_errors: bool = False,
700-
user_agent: Optional[str] = None,
701700
**kwargs,
702701
) -> EvaluationResult:
703702
"""Evaluates target or data with built-in or custom evaluators. If both target and data are provided,
@@ -729,9 +728,6 @@ def evaluate(
729728
Defaults to false, which means that evaluations will continue regardless of failures.
730729
If such failures occur, metrics may be missing, and evidence of failures can be found in the evaluation's logs.
731730
:paramtype fail_on_evaluator_errors: bool
732-
:keyword user_agent: Custom user agent string to append to the default user agent for HTTP requests.
733-
If provided, the final user agent will be: 'azure-ai-evaluation/<version> <user_agent>'.
734-
:paramtype user_agent: Optional[str]
735731
:return: Evaluation results.
736732
:rtype: ~azure.ai.evaluation.EvaluationResult
737733
@@ -753,24 +749,10 @@ def evaluate(
753749
:dedent: 8
754750
:caption: Run an evaluation on local data with one or more evaluators using Azure AI Project URL in following format
755751
https://{resource_name}.services.ai.azure.com/api/projects/{project_name}
756-
757-
.. admonition:: Example with custom user agent:
758-
759-
.. code-block:: python
760-
761-
from azure.ai.evaluation import evaluate
762-
from azure.identity import DefaultAzureCredential
763-
764-
# Run evaluation with custom user agent
765-
result = evaluate(
766-
data="path/to/data.jsonl",
767-
evaluators={
768-
"groundedness": GroundednessEvaluator(azure_ai_project=azure_ai_project, credential=credential)
769-
},
770-
azure_ai_project=azure_ai_project,
771-
user_agent="MyApp/1.0.0" # Custom user agent to append to default
772-
)
773752
"""
753+
# Extract user_agent from kwargs if provided
754+
user_agent = kwargs.pop('user_agent', None)
755+
774756
try:
775757
return _evaluate(
776758
evaluation_name=evaluation_name,

sdk/evaluation/azure-ai-evaluation/samples/evaluation_custom_user_agent.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

sdk/evaluation/azure-ai-evaluation/tests/unittests/test_evaluate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ def test_name_map_conversion(self):
966966
assert len(result) == 1
967967

968968

969-
def test_evaluate_user_agent_parameter():
970-
"""Test that the user_agent parameter is accepted by the evaluate function."""
969+
def test_evaluate_user_agent_via_kwargs():
970+
"""Test that the user_agent parameter is accepted via kwargs by the evaluate function."""
971971
import tempfile
972972
import json
973973
from unittest.mock import patch, MagicMock
@@ -1010,7 +1010,7 @@ def mock_evaluator(query, response):
10101010
{}
10111011
)
10121012

1013-
# Test that user_agent parameter is accepted and doesn't cause errors
1013+
# Test that user_agent parameter is accepted via kwargs and doesn't cause errors
10141014
result = evaluate(
10151015
data=temp_file,
10161016
evaluators={"test_evaluator": mock_evaluator},

0 commit comments

Comments
 (0)