Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_outputText(completion_response: dict, model_response: "ModelResponse") -
A string with the response of the LLM

"""
if "choices" in completion_response:
if "choices" in completion_response and len(completion_response["choices"]) > 0:
outputText = completion_response["choices"][0]["message"]["content"]
model_response.choices[0].finish_reason = completion_response["choices"][0]["finish_reason"]
elif "outputs" in completion_response:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_litellm/llms/bedrock/chat/test_mistral_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from litellm.llms.bedrock.chat.invoke_transformations.amazon_mistral_transformation import (
AmazonMistralConfig,
)
from litellm.llms.bedrock.common_utils import BedrockError
from litellm.types.utils import ModelResponse


Expand Down Expand Up @@ -30,3 +33,12 @@ def test_mistral_get_outputText():

assert outputText == "Hi!"
assert model_response.choices[0].finish_reason == "finish"


def test_mistral_get_outputText_empty_choices():
model_response = ModelResponse()

with pytest.raises(BedrockError):
AmazonMistralConfig.get_outputText(
completion_response={"choices": []}, model_response=model_response
)
Loading