Based on the data-type using json

The value of response_obj["choices"][0]["message"] is Message object and dict

Added a conditional to use .json only iff it is Message Object
This commit is contained in:
Rajan Paneru 2024-05-10 10:06:50 +09:30
parent 66a1b581e5
commit c45085b728

View file

@ -135,7 +135,9 @@ class LangFuseLogger:
response_obj, litellm.ModelResponse
):
input = prompt
output = response_obj["choices"][0]["message"].json()
output = response_obj["choices"][0]["message"]
if isinstance(output, litellm.Message):
output = output.json()
elif response_obj is not None and isinstance(
response_obj, litellm.TextCompletionResponse
):