fix: not working log_failure_event in langfuse

This commit is contained in:
Yuta Saito 2025-12-19 16:54:57 +09:00
parent 0c48826cdc
commit 20bbfdd7cb
2 changed files with 26 additions and 0 deletions

View file

@ -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"

View file

@ -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
)