mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
Simplify mock_patch_acompletion
This commit is contained in:
parent
6ec058711a
commit
a79fd772f4
1 changed files with 12 additions and 13 deletions
|
@ -37,24 +37,23 @@ token = "sk-1234"
|
||||||
|
|
||||||
headers = {"Authorization": f"Bearer {token}"}
|
headers = {"Authorization": f"Bearer {token}"}
|
||||||
|
|
||||||
|
example_completion_result = {
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"message": {
|
||||||
|
"content": "Whispers of the wind carry dreams to me.",
|
||||||
|
"role": "assistant"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def mock_patch_acompletion():
|
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(
|
with mock.patch(
|
||||||
"litellm.proxy.proxy_server.llm_router.acompletion",
|
"litellm.proxy.proxy_server.llm_router.acompletion",
|
||||||
side_effect=side_effect,
|
return_value=example_completion_result,
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue