From b2ca07a5e30a48e0175fee696021002a50027db4 Mon Sep 17 00:00:00 2001 From: Alex Kira Date: Mon, 28 Oct 2024 13:37:53 -0700 Subject: [PATCH] Add trace_id param --- python/langsmith/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/langsmith/client.py b/python/langsmith/client.py index c6f2fa00d..389db09d9 100644 --- a/python/langsmith/client.py +++ b/python/langsmith/client.py @@ -4150,6 +4150,7 @@ def _submit_feedback(**kwargs): ), feedback_source_type=ls_schemas.FeedbackSourceType.MODEL, project_id=project_id, + trace_id=run.trace_id if run else None, ) return results @@ -4220,6 +4221,7 @@ def create_feedback( project_id: Optional[ID_TYPE] = None, comparative_experiment_id: Optional[ID_TYPE] = None, feedback_group_id: Optional[ID_TYPE] = None, + trace_id: Optional[ID_TYPE] = None, **kwargs: Any, ) -> ls_schemas.Feedback: """Create a feedback in the LangSmith API. @@ -4313,7 +4315,7 @@ def create_feedback( # If run_id is None, this is interpreted as session-level # feedback. run_id=_ensure_uuid(run_id, accept_null=True), - trace_id=_ensure_uuid(run_id, accept_null=True), + trace_id=_ensure_uuid(trace_id, accept_null=True), key=key, score=score, value=value, @@ -4335,7 +4337,11 @@ def create_feedback( "use_multipart_endpoint", False ) - if use_multipart and self.tracing_queue is not None: + if ( + use_multipart + and self.tracing_queue is not None + and feedback.trace_id is not None + ): self.tracing_queue.put( TracingQueueItem(str(feedback.id), "feedback", feedback) )