Skip to content

Commit

Permalink
openai non-stream metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
marcklingen committed Sep 27, 2024
1 parent 68938c0 commit bd4d824
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/filters/langfuse_filter_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ async def outlet(self, body: dict, user: Optional[dict] = None) -> dict:
if assistant_message_obj:
info = assistant_message_obj.get("info", {})
if isinstance(info, dict):
prompt_eval_count = info.get("prompt_eval_count")
eval_count = info.get("eval_count")
if prompt_eval_count is not None and eval_count is not None:
input_tokens = info.get("prompt_eval_count") or info.get("prompt_tokens")
output_tokens = info.get("eval_count") or info.get("completion_tokens")
if input_tokens is not None and output_tokens is not None:
usage = {
"input": prompt_eval_count,
"output": eval_count,
"input": input_tokens,
"output": output_tokens,
"unit": "TOKENS",
}

Expand Down

0 comments on commit bd4d824

Please sign in to comment.