diff --git a/litellm/__pycache__/__init__.cpython-311.pyc b/litellm/__pycache__/__init__.cpython-311.pyc index ab63061a31..73352d569b 100644 Binary files a/litellm/__pycache__/__init__.cpython-311.pyc and b/litellm/__pycache__/__init__.cpython-311.pyc differ diff --git a/litellm/__pycache__/main.cpython-311.pyc b/litellm/__pycache__/main.cpython-311.pyc index eefa5f2832..11eb85d841 100644 Binary files a/litellm/__pycache__/main.cpython-311.pyc and b/litellm/__pycache__/main.cpython-311.pyc differ diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index 1d27746f83..9a0883ee25 100644 Binary files a/litellm/__pycache__/utils.cpython-311.pyc and b/litellm/__pycache__/utils.cpython-311.pyc differ diff --git a/litellm/main.py b/litellm/main.py index 829cb33810..b5a6b1c8af 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -59,7 +59,6 @@ def get_optional_params( ####### COMPLETION ENDPOINTS ################ ############################################# @client -<<<<<<< HEAD @func_set_timeout(180, allowOverride=True) ## https://pypi.org/project/func-timeout/ - timeouts, in case calls hang (e.g. Azure) def completion( model, messages, # required params @@ -77,12 +76,6 @@ def completion( temperature=temperature, top_p=top_p, n=n, stream=stream, stop=stop, max_tokens=max_tokens, presence_penalty=presence_penalty, frequency_penalty=frequency_penalty, logit_bias=logit_bias, user=user ) -======= -@func_set_timeout(60, allowOverride=True) ## https://pypi.org/project/func-timeout/ - timeouts, in case calls hang (e.g. Azure) -def completion(model, messages, max_tokens=None, *, forceTimeout=60, azure=False, logger_fn=None): # ,*,.. if optional params like forceTimeout, azure and logger_fn are passed then they're keyword arguments - try: - response = None ->>>>>>> bd42ec8 (clean up code files) if azure == True: # azure configs openai.api_type = "azure" @@ -97,7 +90,7 @@ def completion(model, messages, max_tokens=None, *, forceTimeout=60, azure=False messages = messages, **optional_params ) - elif model in open_ai_chat_completion_models: + elif model in litellm.open_ai_chat_completion_models: openai.api_type = "openai" openai.api_base = "https://api.openai.com/v1" openai.api_version = None @@ -111,7 +104,7 @@ def completion(model, messages, max_tokens=None, *, forceTimeout=60, azure=False messages = messages, **optional_params ) - elif model in open_ai_text_completion_models: + elif model in litellm.open_ai_text_completion_models: openai.api_type = "openai" openai.api_base = "https://api.openai.com/v1" openai.api_version = None @@ -221,10 +214,6 @@ def completion(model, messages, max_tokens=None, *, forceTimeout=60, azure=False ], } response = new_response -<<<<<<< HEAD - else: - raise Exception(f"Model '{model}' not found. Please check your model name and try again.") -======= elif model in litellm.open_ai_chat_completion_models: openai.api_type = "openai" @@ -255,7 +244,6 @@ def completion(model, messages, max_tokens=None, *, forceTimeout=60, azure=False logging(model=model, input=messages, azure=azure, logger_fn=logger_fn) args = locals() raise ValueError(f"No valid completion model args passed in - {args}") ->>>>>>> bd42ec8 (clean up code files) return response except Exception as e: logging(model=model, input=messages, azure=azure, additional_args={"max_tokens": max_tokens}, logger_fn=logger_fn) diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index ee64099ce7..88574ff2ee 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -1,10 +1,10 @@ import sys, os import traceback -sys.path.append('..') # Adds the parent directory to the system path -import main -from main import completion +sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path +import litellm +from litellm import embedding, completion -main.set_verbose = True +litellm.set_verbose = True user_message = "Hello, whats the weather in San Francisco??" messages = [{ "content": user_message,"role": "user"}] diff --git a/litellm/tests/test_model_fallback.py b/litellm/tests/test_model_fallback.py index 8e031a9806..b389e9f6ac 100644 --- a/litellm/tests/test_model_fallback.py +++ b/litellm/tests/test_model_fallback.py @@ -17,20 +17,10 @@ model_fallback_list = ["replicate/llama-2-70b-chat:2c1608e18606fad2812020dc54193 user_message = "Hello, how are you?" messages = [{ "content": user_message,"role": "user"}] -# for _ in range(10): for model in model_fallback_list: try: response = embedding(model="text-embedding-ada-002", input=[user_message]) response = completion(model=model, messages=messages) print(response) -<<<<<<< HEAD - if response != None: - break except Exception as e: -======= - # if response != None: - # break - except: ->>>>>>> bd42ec8 (clean up code files) print(f"error occurred: {traceback.format_exc()}") - raise e