LangSmith를 사용하면 trace에 피드백을 쉽게 첨부할 수 있습니다. 이 피드백은 사용자, 주석자, 자동화된 평가자 등으로부터 제공될 수 있으며, 애플리케이션을 모니터링하고 평가하는 데 매우 중요합니다.

create_feedback() / createFeedback() 사용하기

여기서는 SDK를 사용하여 피드백을 로깅하는 방법을 안내합니다.
Child run trace(root run) 자체뿐만 아니라 trace의 모든 child run에 사용자 피드백을 첨부할 수 있습니다. 이는 RAG 파이프라인의 retrieval 단계나 generation 단계와 같은 LLM 애플리케이션의 특정 단계를 평가하는 데 유용합니다.
논블로킹 생성 (Python 전용) Python client는 create_feedback()trace_id=를 전달하면 자동으로 피드백 생성을 백그라운드에서 처리합니다. 이는 애플리케이션이 피드백 생성으로 인해 차단되지 않도록 하려는 저지연 환경에서 필수적입니다.
from langsmith import trace, traceable, Client

    @traceable
    def foo(x):
        return {"y": x * 2}

    @traceable
    def bar(y):
        return {"z": y - 1}

    client = Client()

    inputs = {"x": 1}
    with trace(name="foobar", inputs=inputs) as root_run:
        result = foo(**inputs)
        result = bar(**result)
        root_run.outputs = result
        trace_id = root_run.id
        child_runs = root_run.child_runs

    # Provide feedback for a trace (a.k.a. a root run)
    client.create_feedback(
        key="user_feedback",
        score=1,
        trace_id=trace_id,
        comment="the user said that ..."
    )

# Provide feedback for a child run
foo_run_id = [run for run in child_runs if run.name == "foo"][0].id
client.create_feedback(
    key="correctness",
    score=0,
    run_id=foo_run_id,
    # trace_id= is optional but recommended to enable batched and backgrounded
    # feedback ingestion.
    trace_id=trace_id,
)
create_feedback() / createFeedback()을 사용하여 진행 중인 run에 대한 피드백도 로깅할 수 있습니다. 진행 중인 run의 run ID를 가져오는 방법은 이 가이드를 참조하세요. 사용자 피드백을 포함한 다양한 속성을 기반으로 trace를 필터링하는 방법에 대해 자세히 알아보려면 이 가이드를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I