Skip to content

Commit

Permalink
Simplify mock_patch_acompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
msabramo committed May 2, 2024
1 parent 6ec0587 commit a79fd77
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions litellm/tests/test_proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@

headers = {"Authorization": f"Bearer {token}"}

example_completion_result = {
"choices": [
{
"message": {
"content": "Whispers of the wind carry dreams to me.",
"role": "assistant"
}
}
],
}


@contextlib.contextmanager
def mock_patch_acompletion():
async def side_effect(*args, **kwargs):
return {
"choices": [
{
"message": {
"content": "Whispers of the wind carry dreams to me.",
"role": "assistant"
}
}
],
}

with mock.patch(
"litellm.proxy.proxy_server.llm_router.acompletion",
side_effect=side_effect,
return_value=example_completion_result,
):
yield

Expand Down

0 comments on commit a79fd77

Please sign in to comment.