mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-28 04:04:31 +00:00
(test) router: acompletion + caching
This commit is contained in:
parent
f3bef86848
commit
f41683011a
1 changed files with 5 additions and 3 deletions
|
@ -83,7 +83,7 @@ def test_multiple_deployments():
|
||||||
# Check results
|
# Check results
|
||||||
|
|
||||||
|
|
||||||
test_multiple_deployments()
|
# test_multiple_deployments()
|
||||||
|
|
||||||
def test_exception_raising():
|
def test_exception_raising():
|
||||||
# this tests if the router raises an exception when invalid params are set
|
# this tests if the router raises an exception when invalid params are set
|
||||||
|
@ -237,7 +237,7 @@ def test_function_calling():
|
||||||
|
|
||||||
def test_acompletion_on_router():
|
def test_acompletion_on_router():
|
||||||
try:
|
try:
|
||||||
litellm.set_verbose = True
|
litellm.set_verbose = False
|
||||||
model_list = [
|
model_list = [
|
||||||
{
|
{
|
||||||
"model_name": "gpt-3.5-turbo",
|
"model_name": "gpt-3.5-turbo",
|
||||||
|
@ -262,7 +262,7 @@ def test_acompletion_on_router():
|
||||||
]
|
]
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
{"role": "user", "content": f"What is the weather like in Boston {time.time()}?"}
|
{"role": "user", "content": f"write a one sentence poem {time.time()}?"}
|
||||||
]
|
]
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
router = Router(model_list=model_list,
|
router = Router(model_list=model_list,
|
||||||
|
@ -278,6 +278,8 @@ def test_acompletion_on_router():
|
||||||
response2 = await router.acompletion(model="gpt-3.5-turbo", messages=messages)
|
response2 = await router.acompletion(model="gpt-3.5-turbo", messages=messages)
|
||||||
print(f"response2: {response2}")
|
print(f"response2: {response2}")
|
||||||
assert response1.id == response2.id
|
assert response1.id == response2.id
|
||||||
|
assert len(response1.choices[0].message.content) > 0
|
||||||
|
assert response1.choices[0].message.content == response2.choices[0].message.content
|
||||||
asyncio.run(get_response())
|
asyncio.run(get_response())
|
||||||
except litellm.Timeout as e:
|
except litellm.Timeout as e:
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue