(Bug Fix - Langfuse) - fix for when model response has choices=[] (#8339)

* refactor _get_langfuse_input_output_content

* test_langfuse_logging_completion_with_malformed_llm_response

* fix _get_langfuse_input_output_content

* fixes for langfuse linting

* unit testing for get chat/text content for langfuse

* fix _should_raise_content_policy_error
This commit is contained in:
Ishaan Jaff 2025-02-06 18:02:26 -08:00 committed by GitHub
parent 92ba180adc
commit 39d616f22d
7 changed files with 352 additions and 119 deletions

View file

@ -3699,8 +3699,9 @@ class Router:
Else, original response is returned.
"""
if response.choices[0].finish_reason != "content_filter":
return False
if response.choices and len(response.choices) > 0:
if response.choices[0].finish_reason != "content_filter":
return False
content_policy_fallbacks = kwargs.get(
"content_policy_fallbacks", self.content_policy_fallbacks