fix: don't init langwatch if not configure (#6749)

* fix: don't init langwatch if not configure;

* feat: return langfuse callback for tracing

* fix: move condition to setup_langwatch

* fix: typo

---------

Co-authored-by: tianzhipeng-jk <tianzhipeng-jk@360shuke.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
tianzhipeng 2025-02-22 02:48:04 +08:00 committed by GitHub
commit 4ef4c93bac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -133,7 +133,7 @@ class LangFuseTracer(BaseTracer):
def get_langchain_callback(self) -> BaseCallbackHandler | None:
if not self._ready:
return None
return None # self._callback
return self._callback
@staticmethod
def _get_config() -> dict:

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import os
from typing import TYPE_CHECKING, Any, cast
import nanoid
@ -31,7 +32,7 @@ class LangWatchTracer(BaseTracer):
self.flow_id = trace_name.split(" - ")[-1]
try:
self._ready = self.setup_langwatch()
self._ready: bool = self.setup_langwatch()
if not self._ready:
return
@ -58,6 +59,8 @@ class LangWatchTracer(BaseTracer):
return self._ready
def setup_langwatch(self) -> bool:
if "LANGWATCH_API_KEY" not in os.environ:
return False
try:
import langwatch