mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
fix: Handle None response and update InvalidRequestError test
This commit is contained in:
parent
b79c09cf58
commit
14d02bc843
2 changed files with 5 additions and 1 deletions
|
@ -71,6 +71,8 @@ def simple_send_with_retries(model_name, messages, extra_params=None):
|
|||
}
|
||||
|
||||
_hash, response = send_completion(**kwargs)
|
||||
if not response or not hasattr(response, 'choices') or not response.choices:
|
||||
return None
|
||||
return response.choices[0].message.content
|
||||
except litellm_ex.exceptions_tuple() as err:
|
||||
ex_info = litellm_ex.get_ex_info(err)
|
||||
|
|
|
@ -85,7 +85,9 @@ class TestSendChat(unittest.TestCase):
|
|||
mock.status_code = 400
|
||||
|
||||
mock_completion.side_effect = litellm.InvalidRequestError(
|
||||
"Invalid request", response=mock, llm_provider="test_provider", model="test_model"
|
||||
message="Invalid request",
|
||||
llm_provider="test_provider",
|
||||
model="test_model"
|
||||
)
|
||||
|
||||
result = simple_send_with_retries(self.mock_model, self.mock_messages)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue