From 5478b920df5fdc26d69a185a440ebde05d013a9d Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 2 Jun 2024 11:40:24 -0700 Subject: [PATCH] enh: langfuse filter --- examples/filters/langfuse_filter_pipeline.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/filters/langfuse_filter_pipeline.py b/examples/filters/langfuse_filter_pipeline.py index 706f591f..eb8e7514 100644 --- a/examples/filters/langfuse_filter_pipeline.py +++ b/examples/filters/langfuse_filter_pipeline.py @@ -101,3 +101,18 @@ async def inlet(self, body: dict, user: Optional[dict] = None) -> dict: print(trace.get_trace_url()) return body + + async def outlet(self, body: dict, user: Optional[dict] = None) -> dict: + print(f"outlet:{__name__}") + + trace = self.langfuse.trace( + name=f"filter:{__name__}", + input=body, + user_id=user["id"], + metadata={"name": user["name"]}, + session_id=body["chat_id"], + ) + + print(trace.get_trace_url()) + + return body