Skip to content

Commit

Permalink
fix: do not show langfuse warning
Browse files Browse the repository at this point in the history
  • Loading branch information
skoob13 committed Oct 24, 2024
1 parent deaa5e8 commit 3dadcdc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ee/hogai/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
from posthog.schema import AssistantMessage as FrontendAssistantMessage
from posthog.schema import VisualizationMessagePayload

langfuse_handler = CallbackHandler(
public_key=settings.LANGFUSE_PUBLIC_KEY, secret_key=settings.LANGFUSE_SECRET_KEY, host=settings.LANGFUSE_HOST
)
if settings.LANGFUSE_PUBLIC_KEY:
langfuse_handler = CallbackHandler(
public_key=settings.LANGFUSE_PUBLIC_KEY, secret_key=settings.LANGFUSE_SECRET_KEY, host=settings.LANGFUSE_HOST
)
else:
langfuse_handler = None


class Assistant:
Expand Down Expand Up @@ -46,9 +49,11 @@ def _compile_graph(self):

def stream(self, messages: list[AssistantMessage]) -> Generator[str, None, None]:
assistant_graph = self._compile_graph()
callbacks = [langfuse_handler] if langfuse_handler else []

generator = assistant_graph.stream(
{"messages": messages},
config={"recursion_limit": 24, "callbacks": [langfuse_handler]},
config={"recursion_limit": 24, "callbacks": callbacks},
stream_mode="messages",
)

Expand Down

0 comments on commit 3dadcdc

Please sign in to comment.