Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: not working log_failure_event in langfuse

Yuta Saito20bbfdd7cb0d
diff --git a/litellm/integrations/langfuse/langfuse_prompt_management.py b/litellm/integrations/langfuse/langfuse_prompt_management.py
index adc8ae61d01..8f73eabad44 100644
--- a/litellm/integrations/langfuse/langfuse_prompt_management.py
+++ b/litellm/integrations/langfuse/langfuse_prompt_management.py
@@ -294,6 +294,11 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLogge
self.async_log_success_event, kwargs, response_obj, start_time, end_time
)
+ def log_failure_event(self, kwargs, response_obj, start_time, end_time):
+ return run_async_function(
+ self.async_log_failure_event, kwargs, response_obj, start_time, end_time
+ )
+
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
standard_callback_dynamic_params = kwargs.get(
"standard_callback_dynamic_params"
diff --git a/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py
index 70e97381082..5389cdf7377 100644
--- a/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py
+++ b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py
@@ -27,3 +27,24 @@ class TestLangfusePromptManagement:
mock_get_prompt_from_id.assert_called_once()
assert mock_get_prompt_from_id.call_args.kwargs["prompt_version"] == 4
+
+ def test_log_failure_event_runs_async_logger(self):
+ langfuse_prompt_management = LangfusePromptManagement()
+ with patch(
+ "litellm.integrations.langfuse.langfuse_prompt_management.run_async_function"
+ ) as mock_run_async:
+ kwargs = {"standard_callback_dynamic_params": {}}
+ start_time, end_time = 1, 2
+
+ langfuse_prompt_management.log_failure_event(
+ kwargs=kwargs,
+ response_obj=None,
+ start_time=start_time,
+ end_time=end_time,
+ )
+
+ mock_run_async.assert_called_once()
+ assert (
+ mock_run_async.call_args[0][0]
+ == langfuse_prompt_management.async_log_failure_event
+ )