mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(bedrock): guard empty outputs in mistral get_outputText
This commit is contained in:
parent
c586769898
commit
92827ab9bc
2 changed files with 10 additions and 1 deletions
|
|
@ -102,7 +102,7 @@ class AmazonMistralConfig(AmazonInvokeConfig, BaseConfig):
|
|||
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:
|
||||
elif "outputs" in completion_response and len(completion_response["outputs"]) > 0:
|
||||
outputText = completion_response["outputs"][0]["text"]
|
||||
model_response.choices[0].finish_reason = completion_response["outputs"][0]["stop_reason"]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -42,3 +42,12 @@ def test_mistral_get_outputText_empty_choices():
|
|||
AmazonMistralConfig.get_outputText(
|
||||
completion_response={"choices": []}, model_response=model_response
|
||||
)
|
||||
|
||||
|
||||
def test_mistral_get_outputText_empty_outputs():
|
||||
model_response = ModelResponse()
|
||||
|
||||
with pytest.raises(BedrockError):
|
||||
AmazonMistralConfig.get_outputText(
|
||||
completion_response={"outputs": []}, model_response=model_response
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue