Skip to content

Commit

Permalink
Merge pull request #249 from marcklingen/feat-user-email-in-langfuse-…
Browse files Browse the repository at this point in the history
…filter-pipeline

feat: track user.email in langfuse filter pipeline and remove wrong token count
  • Loading branch information
tjbck committed Sep 9, 2024
2 parents d4fca4c + 4d53b80 commit a235f3d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions examples/filters/langfuse_filter_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Langfuse Filter Pipeline
author: open-webui
date: 2024-05-30
version: 1.1
version: 1.2
license: MIT
description: A filter pipeline that uses Langfuse.
requirements: langfuse
Expand Down Expand Up @@ -90,8 +90,8 @@ async def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
trace = self.langfuse.trace(
name=f"filter:{__name__}",
input=body,
user_id=user["id"],
metadata={"name": user["name"]},
user_id=user["email"],
metadata={"user_name": user["name"], "user_id": user["id"]},
session_id=body["chat_id"],
)

Expand Down Expand Up @@ -119,10 +119,6 @@ async def outlet(self, body: dict, user: Optional[dict] = None) -> dict:

generation.end(
output=generated_message,
usage={
"totalCost": (len(user_message) + len(generated_message)) / 1000,
"unit": "CHARACTERS",
},
metadata={"interface": "open-webui"},
)

Expand Down

0 comments on commit a235f3d

Please sign in to comment.