Sdm0 commited on
Commit
4b111f0
·
verified ·
1 Parent(s): 96a6d29

Deploy eb22ba2a

Browse files
Files changed (1) hide show
  1. observability.py +7 -7
observability.py CHANGED
@@ -72,24 +72,24 @@ def get_langfuse_handler():
72
  """Return a Langfuse ``CallbackHandler`` if keys are configured, else None.
73
 
74
  Reads ``LANGFUSE_PUBLIC_KEY``, ``LANGFUSE_SECRET_KEY``, and optionally
75
- ``LANGFUSE_HOST`` from environment variables.
 
 
 
76
  """
77
  public_key = os.environ.get("LANGFUSE_PUBLIC_KEY", "").strip()
78
  secret_key = os.environ.get("LANGFUSE_SECRET_KEY", "").strip()
79
- host = os.environ.get(
80
- "LANGFUSE_HOST", "https://cloud.langfuse.com"
81
- ).strip()
82
 
83
  if not public_key or not secret_key:
84
  return None
85
 
86
  try:
87
- from langfuse.callback import CallbackHandler
88
 
 
 
89
  return CallbackHandler(
90
  public_key=public_key,
91
- secret_key=secret_key,
92
- host=host,
93
  )
94
  except ImportError:
95
  logger.warning(
 
72
  """Return a Langfuse ``CallbackHandler`` if keys are configured, else None.
73
 
74
  Reads ``LANGFUSE_PUBLIC_KEY``, ``LANGFUSE_SECRET_KEY``, and optionally
75
+ ``LANGFUSE_HOST`` from environment variables. In langfuse v4+ the
76
+ ``CallbackHandler`` only needs ``public_key``; the SDK reads
77
+ ``LANGFUSE_SECRET_KEY`` and ``LANGFUSE_HOST`` from the environment
78
+ automatically.
79
  """
80
  public_key = os.environ.get("LANGFUSE_PUBLIC_KEY", "").strip()
81
  secret_key = os.environ.get("LANGFUSE_SECRET_KEY", "").strip()
 
 
 
82
 
83
  if not public_key or not secret_key:
84
  return None
85
 
86
  try:
87
+ from langfuse.langchain import CallbackHandler
88
 
89
+ # In langfuse v4+, CallbackHandler only needs public_key;
90
+ # the secret key is read automatically from LANGFUSE_SECRET_KEY env var
91
  return CallbackHandler(
92
  public_key=public_key,
 
 
93
  )
94
  except ImportError:
95
  logger.warning(