fix: Refactor run_link access to avoid unnecessary external call (#8126)

refactor: Replace direct access to run_link with a property for better encapsulation
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-05-19 18:04:21 -03:00 committed by GitHub
commit 5829bc1029
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,7 +140,6 @@ class LangSmithTracer(BaseTracer):
child.patch()
else:
child.post()
self._child_link[trace_name] = child.get_url()
@staticmethod
def _error_to_string(error: Exception | None):
@ -164,7 +163,12 @@ class LangSmithTracer(BaseTracer):
self._run_tree.add_metadata(serialize(metadata))
self._run_tree.end(outputs=serialize(outputs), error=self._error_to_string(error))
self._run_tree.post()
self._run_link = self._run_tree.get_url()
@property
def run_link(self):
if not self._ready or not self._run_tree:
return None
return self._run_tree.get_url()
@override
def get_langchain_callback(self) -> BaseCallbackHandler | None: