mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
Add router_obj
tests.
This commit is contained in:
parent
2498092343
commit
c63859a136
1 changed files with 29 additions and 0 deletions
|
@ -390,3 +390,32 @@ class Test_Chat:
|
||||||
call(model="gemini/gemini-1.5-flash", messages=[{"role": "user", "content": "hello"}], bar="foo"),
|
call(model="gemini/gemini-1.5-flash", messages=[{"role": "user", "content": "hello"}], bar="foo"),
|
||||||
]
|
]
|
||||||
assert params == {"acompletion": True}
|
assert params == {"acompletion": True}
|
||||||
|
|
||||||
|
def test_calls_completion_with_router_obj(self, mocker):
|
||||||
|
router_obj = mocker.MagicMock()
|
||||||
|
chatobj = litellm.main.Chat({}, router_obj=router_obj)
|
||||||
|
chatobj.completions.create(
|
||||||
|
messages=[{"role": "user", "content": "hello"}],
|
||||||
|
model="gemini/gemini-1.5-flash",
|
||||||
|
foo="bar",
|
||||||
|
)
|
||||||
|
router_obj.completion.assert_called_once_with(
|
||||||
|
model="gemini/gemini-1.5-flash",
|
||||||
|
messages=[{"role": "user", "content": "hello"}],
|
||||||
|
foo="bar"
|
||||||
|
)
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_calls_acompletion_with_router_obj(self, mocker):
|
||||||
|
router_obj = mocker.AsyncMock()
|
||||||
|
chatobj = litellm.main.Chat({"acompletion": True}, router_obj=router_obj)
|
||||||
|
await chatobj.completions.create( # type: ignore
|
||||||
|
messages=[{"role": "user", "content": "hello"}],
|
||||||
|
model="gemini/gemini-1.5-flash",
|
||||||
|
foo="bar",
|
||||||
|
)
|
||||||
|
router_obj.acompletion.assert_called_once_with(
|
||||||
|
model="gemini/gemini-1.5-flash",
|
||||||
|
messages=[{"role": "user", "content": "hello"}],
|
||||||
|
foo="bar"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue