mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(langfuse.py): langfuse success logging fix
This commit is contained in:
parent
bc23a9266e
commit
64fd1f7d21
1 changed files with 19 additions and 14 deletions
|
@ -275,19 +275,24 @@ class LangFuseLogger:
|
||||||
"completion_tokens": response_obj["usage"]["completion_tokens"],
|
"completion_tokens": response_obj["usage"]["completion_tokens"],
|
||||||
"total_cost": cost if supports_costs else None,
|
"total_cost": cost if supports_costs else None,
|
||||||
}
|
}
|
||||||
trace.generation(
|
|
||||||
name=generation_name,
|
generation_params = {
|
||||||
id=metadata.get("generation_id", generation_id),
|
"name": generation_name,
|
||||||
startTime=start_time,
|
"id": metadata.get("generation_id", generation_id),
|
||||||
endTime=end_time,
|
"startTime": start_time,
|
||||||
model=kwargs["model"],
|
"endTime": end_time,
|
||||||
modelParameters=optional_params,
|
"model": kwargs["model"],
|
||||||
input=input,
|
"modelParameters": optional_params,
|
||||||
output=output,
|
"input": input,
|
||||||
usage=usage,
|
"output": output,
|
||||||
metadata=metadata,
|
"usage": usage,
|
||||||
level=level,
|
"metadata": metadata,
|
||||||
status_message=output,
|
"level": level,
|
||||||
)
|
}
|
||||||
|
|
||||||
|
if output is not None and isinstance(output, str) and level == "ERROR":
|
||||||
|
generation_params["statusMessage"] = output
|
||||||
|
|
||||||
|
trace.generation(**generation_params)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Langfuse Layer Error - {traceback.format_exc()}")
|
print(f"Langfuse Layer Error - {traceback.format_exc()}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue