Skip to content

Commit

Permalink
docs: add deprecation warning to legacy callback handler methods (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcklingen committed Jul 4, 2024
1 parent 9090718 commit f04d8e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions langfuse/callback/langchain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import httpx
import logging
import typing
import warnings

import pydantic

Expand Down Expand Up @@ -110,6 +111,10 @@ def __init__(
self.runs[stateful_client.id] = stateful_client

def setNextSpan(self, id: str):
warnings.warn(
"setNextSpan is deprecated, use span.get_langchain_handler() instead",
DeprecationWarning,
)
self.next_span_id = id

def on_llm_new_token(
Expand Down
9 changes: 9 additions & 0 deletions langfuse/utils/base_callback_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import httpx
import logging
import os
import warnings

from langfuse.client import Langfuse, StatefulTraceClient, StatefulSpanClient, StateType

Expand Down Expand Up @@ -110,6 +111,10 @@ def get_trace_id(self):
Returns:
The ID of the current/last trace or None if no trace is available.
"""
warnings.warn(
"get_trace_id is deprecated, create a trace for this handler instead. See interop documentation of this integration for more information.",
DeprecationWarning,
)
return self.trace.id if self.trace else None

def get_trace_url(self):
Expand All @@ -119,6 +124,10 @@ def get_trace_url(self):
Returns:
The URL of the current/last trace or None if no trace is available.
"""
warnings.warn(
"get_trace_url is deprecated, create a trace for this handler instead. See interop documentation of this integration for more information.",
DeprecationWarning,
)
return self.trace.get_trace_url() if self.trace else None

def flush(self):
Expand Down

0 comments on commit f04d8e0

Please sign in to comment.