From 3c28ff616708a3ebb7ae285594724e5b00b715b7 Mon Sep 17 00:00:00 2001 From: mc-marcocheng Date: Tue, 24 Oct 2023 22:04:45 +0800 Subject: [PATCH] test_litellm_params_not_overwritten_by_function_calling --- litellm/tests/test_router.py | 75 +++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/litellm/tests/test_router.py b/litellm/tests/test_router.py index 5f6892cd110..a2a311c5ae6 100644 --- a/litellm/tests/test_router.py +++ b/litellm/tests/test_router.py @@ -108,43 +108,46 @@ def test_function_calling(): ### FUNCTION CALLING -> NORMAL COMPLETION def test_litellm_params_not_overwritten_by_function_calling(): - model_list = [ - { - "model_name": "gpt-3.5-turbo-0613", - "litellm_params": { - "model": "gpt-3.5-turbo-0613", - "api_key": os.getenv("OPENAI_API_KEY"), + try: + model_list = [ + { + "model_name": "gpt-3.5-turbo-0613", + "litellm_params": { + "model": "gpt-3.5-turbo-0613", + "api_key": os.getenv("OPENAI_API_KEY"), + }, + "tpm": 100000, + "rpm": 10000, }, - "tpm": 100000, - "rpm": 10000, - }, - ] + ] - messages = [ - {"role": "user", "content": "What is the weather like in Boston?"} - ] - functions = [ - { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA" - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] + messages = [ + {"role": "user", "content": "What is the weather like in Boston?"} + ] + functions = [ + { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA" + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } + }, + "required": ["location"] } - }, - "required": ["location"] - } - } - ] + } + ] - router = Router(model_list=model_list) - _ = router.completion(model="gpt-3.5-turbo-0613", messages=messages, functions=functions) - response = router.completion(model="gpt-3.5-turbo-0613", messages=messages) - assert response.choices[0].finish_reason != "function_call" + router = Router(model_list=model_list) + _ = router.completion(model="gpt-3.5-turbo-0613", messages=messages, functions=functions) + response = router.completion(model="gpt-3.5-turbo-0613", messages=messages) + assert response.choices[0].finish_reason != "function_call" + except Exception as e: + pytest.fail(f"Error occurred: {e}")