Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions sdk/evaluation/azure-ai-evaluation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Fixed `_get_metric_result` prefix matching where shorter metric names (e.g., `xpia`) could match before longer, more-specific ones (e.g., `xpia_manipulated_content`). Now sorts by length descending for correct longest-prefix matching.
- Fixed non-dict `_properties` values from evaluators causing downstream issues. Values that are not dicts are now logged and dropped gracefully.
- Fixed filename length error in `_inline_image` by catching OSError/ValueError during local path resolution and fall back to returning a text chunk instead of throwing.
- Fixed `format_llm_response` raising `UnboundLocalError` when `inputs` was not provided by ensuring `sample_input` is always initialized.

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ async def format_stream(llm_response: AsyncStream[ChatCompletionChunk]) -> Async
)
sample_output = json.dumps(sample_output_list)
input_str = f"{json.dumps(inputs)}" if inputs else ""
sample_input = ""
if inputs and len(inputs) > 0:
sample_input_json = []
msg = ChatCompletionUserMessageParam(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

import asyncio
from types import SimpleNamespace

import pytest

from azure.ai.evaluation._legacy.prompty._utils import format_llm_response


class _FakeResponse:
def __init__(self):
self.usage = SimpleNamespace(prompt_tokens=1, completion_tokens=2, total_tokens=3)
self.choices = [
SimpleNamespace(
finish_reason="stop",
message=SimpleNamespace(role="assistant", content="test-output"),
)
]
self.model = "test-model"

def model_dump(self):
return {
"choices": [
{
"message": {
"role": "assistant",
"content": "test-output",
}
}
]
}


@pytest.mark.unittest
def test_format_llm_response_with_no_inputs_sets_empty_sample_input():
response = _FakeResponse()

result = asyncio.run(
format_llm_response(
response=response,
is_first_choice=True,
response_format={"type": "text"},
outputs=None,
inputs=None,
)
)
Comment thread
posaninagendra marked this conversation as resolved.

assert result["llm_output"] == "test-output"
assert result["sample_input"] == ""
Loading