From 0b98959e6dccb64d99c86f06f464b0fb41e0f7c5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 7 Aug 2024 13:12:19 -0700 Subject: [PATCH] gemini test skip internal server error --- litellm/tests/test_completion.py | 98 +++++++++++++++++--------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index aee2068ddfe..a07aac5bf10 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -892,57 +892,65 @@ def test_completion_claude_3_base64(): "model", ["gemini/gemini-1.5-flash"] # "claude-3-sonnet-20240229", ) def test_completion_function_plus_image(model): - litellm.set_verbose = True + try: + litellm.set_verbose = True - image_content = [ - {"type": "text", "text": "What’s in this image?"}, - { - "type": "image_url", - "image_url": { - "url": "https://litellm-listing.s3.amazonaws.com/litellm_logo.png" - }, - }, - ] - image_message = {"role": "user", "content": image_content} - - tools = [ - { - "type": "function", - "function": { - "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"], + image_content = [ + {"type": "text", "text": "What’s in this image?"}, + { + "type": "image_url", + "image_url": { + "url": "https://litellm-listing.s3.amazonaws.com/litellm_logo.png" }, }, - } - ] + ] + image_message = {"role": "user", "content": image_content} - tool_choice = {"type": "function", "function": {"name": "get_current_weather"}} - messages = [ - { - "role": "user", - "content": "What's the weather like in Boston today in Fahrenheit?", - } - ] + tools = [ + { + "type": "function", + "function": { + "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"], + }, + }, + } + ] - response = completion( - model=model, - messages=[image_message], - tool_choice=tool_choice, - tools=tools, - stream=False, - ) + tool_choice = {"type": "function", "function": {"name": "get_current_weather"}} + messages = [ + { + "role": "user", + "content": "What's the weather like in Boston today in Fahrenheit?", + } + ] - print(response) + response = completion( + model=model, + messages=[image_message], + tool_choice=tool_choice, + tools=tools, + stream=False, + ) + + print(response) + except litellm.InternalServerError: + pass + except Exception as e: + pytest.fail(f"error occurred: {str(e)}") @pytest.mark.parametrize(