Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan committed Dec 23, 2024
1 parent 696e4bf commit a558981
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
18 changes: 10 additions & 8 deletions python/langsmith/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,17 @@ async def awrapper(
"example": example,
"inputs": example.inputs if example else {},
"outputs": run.outputs or {},
"attachments": {
name: {
"presigned_url": value["presigned_url"],
"reader": io.BytesIO(value["reader"].getvalue()),
"attachments": (
{
name: {
"presigned_url": value["presigned_url"],
"reader": io.BytesIO(value["reader"].getvalue()),
}
for name, value in (example.attachments or {}).items()
}
for name, value in (example.attachments or {}).items()
}
if example
else {},
if example
else {}
),
"reference_outputs": example.outputs or {} if example else {},
}
args = (arg_map[arg] for arg in positional_args)
Expand Down
14 changes: 7 additions & 7 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,10 @@ async def test_aevaluate_with_attachments(langchain_client: Client) -> None:

examples = [
ExampleUploadWithAttachments(
inputs={"question": "What is shown in the image?"},
inputs={"question": "What is shown in the image?", "index": i},
outputs={"answer": "test image"},
attachments={
"image": ("image/png", b"fake image data for testing"),
"image": ("text/plain", bytes(f"data: {i}", "utf-8")),
},
)
for i in range(10)
Expand All @@ -1508,29 +1508,29 @@ async def target(
assert "image" in attachments
assert "presigned_url" in attachments["image"]
image_data = attachments["image"]["reader"]
assert image_data.read() == b"fake image data for testing"
assert image_data.read() == bytes(f"data: {inputs['index']}", "utf-8")
return {"answer": "test image"}

async def evaluator_1(
outputs: dict, reference_outputs: dict, attachments: dict
inputs: dict, outputs: dict, reference_outputs: dict, attachments: dict
) -> Dict[str, Any]:
assert "image" in attachments
assert "presigned_url" in attachments["image"]
image_data = attachments["image"]["reader"]
assert image_data.read() == b"fake image data for testing"
assert image_data.read() == bytes(f"data: {inputs['index']}", "utf-8")
return {
"score": float(
reference_outputs.get("answer") == outputs.get("answer") # type: ignore
)
}

async def evaluator_2(
outputs: dict, reference_outputs: dict, attachments: dict
inputs: dict, outputs: dict, reference_outputs: dict, attachments: dict
) -> Dict[str, Any]:
assert "image" in attachments
assert "presigned_url" in attachments["image"]
image_data = attachments["image"]["reader"]
assert image_data.read() == b"fake image data for testing"
assert image_data.read() == bytes(f"data: {inputs['index']}", "utf-8")
return {
"score": float(
reference_outputs.get("answer") == outputs.get("answer") # type: ignore
Expand Down

0 comments on commit a558981

Please sign in to comment.