mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
Merge 9b8301551e into b9ad61d4f6
This commit is contained in:
commit
fe3fdd2c08
2 changed files with 17 additions and 2 deletions
|
|
@ -101,10 +101,10 @@ class AmazonMistralConfig(AmazonInvokeConfig, BaseConfig):
|
|||
A string with the response of the LLM
|
||||
|
||||
"""
|
||||
if "choices" in completion_response:
|
||||
if "choices" in completion_response and completion_response["choices"] != []:
|
||||
outputText = completion_response["choices"][0]["message"]["content"]
|
||||
model_response.choices[0].finish_reason = completion_response["choices"][0]["finish_reason"]
|
||||
elif "outputs" in completion_response:
|
||||
elif "outputs" in completion_response and completion_response["outputs"] != []:
|
||||
outputText = completion_response["outputs"][0]["text"]
|
||||
model_response.choices[0].finish_reason = completion_response["outputs"][0]["stop_reason"]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from litellm.llms.custom_httpx.http_handler import HTTPHandler
|
|||
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
|
||||
|
||||
|
||||
|
|
@ -41,6 +42,20 @@ def test_mistral_get_outputText():
|
|||
assert model_response.choices[0].finish_reason == "finish"
|
||||
|
||||
|
||||
def test_mistral_get_outputText_empty_choices() -> None:
|
||||
model_response: Final = ModelResponse()
|
||||
|
||||
with pytest.raises(BedrockError):
|
||||
AmazonMistralConfig.get_outputText(completion_response={"choices": []}, model_response=model_response)
|
||||
|
||||
|
||||
def test_mistral_get_outputText_empty_outputs() -> None:
|
||||
model_response: Final = ModelResponse()
|
||||
|
||||
with pytest.raises(BedrockError):
|
||||
AmazonMistralConfig.get_outputText(completion_response={"outputs": []}, model_response=model_response)
|
||||
|
||||
|
||||
@pytest.mark.respx(assert_all_called=True)
|
||||
def test_mistral_invoke_outputs_become_message_content(respx_mock: respx.Router) -> None:
|
||||
route: Final = respx_mock.post(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue