log_feedback#

langsmith.testing._internal.log_feedback(feedback: dict | list[dict] | None = None, /, *, key: str, score: int | bool | float | None = None, value: str | int | float | bool | None = None, **kwargs: Any) None[source]#

Log run feedback from within a pytest test run.

Warning

This API is in beta and might change in future versions.

Should only be used in pytest tests decorated with @pytest.mark.langsmith.

Parameters:
  • key (str) – Feedback name.

  • score (int | bool | float | None) – Numerical feedback value.

  • value (str | int | float | bool | None) – Categorical feedback value

  • kwargs (Any) – Any other Client.create_feedback args.

  • feedback (dict | list[dict] | None)

Return type:

None

Example

import pytest
from langsmith import testing as t


@pytest.mark.langsmith
def test_foo() -> None:
    x = 0
    y = 1
    expected = 2
    result = foo(x, y)
    t.log_feedback(key="right_type", score=isinstance(result, int))
    assert result == expected