diff --git a/litellm/main.py b/litellm/main.py index 761080b35..20e554c76 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -672,29 +672,22 @@ def completion( litellm.openai_key or get_secret("DEEPINFRA_API_KEY") ) - openai.api_base = "https://api.deepinfra.com/v1/openai" ## LOGGING logging.pre_call( input=messages, api_key=api_key, ) ## COMPLETION CALL - openai.api_key = "1LntUh4fmg5z6iEW7UPPRhGdBDNuJx5y" - openai.api_base = "https://api.deepinfra.com/v1/openai" + openai.api_key = api_key # set key for deep infra try: - chat_completion = openai.ChatCompletion.create( - model="meta-llama/Llama-2-70b-chat-hf", - messages=[{"role": "user", "content": "Hello world"}] + response = openai.ChatCompletion.create( + model=model, + messages=messages, + api_base="https://api.deepinfra.com/v1/openai", # use the deepinfra api base + api_type="openai", + api_version=api_version, # default None + **optional_params, ) - print(f"chat_completion: {chat_completion}") - # response = openai.ChatCompletion.create( - # model=model, - # messages=messages, - # api_base="https://api.deepinfra.com/v1/openai", # use the deepinfra api base - # api_type="openai", - # api_version=api_version, # default None - # **optional_params, - # ) except Exception as e: ## LOGGING - log the original exception returned logging.post_call( diff --git a/litellm/tests/test_bad_params.py b/litellm/tests/test_bad_params.py index 576cc18f9..3f015a8e8 100644 --- a/litellm/tests/test_bad_params.py +++ b/litellm/tests/test_bad_params.py @@ -52,11 +52,4 @@ def test_completion_with_no_provider(): # except: # print(f"error occurred: {traceback.format_exc()}") # pass -# os.environ["OPENAI_API_KEY"] = str(temp_key) # this passes linting#5 - -def logger_fn(model_details): - print(model_details) -os.environ['OPENAI_API_KEY'] = "1LntUh4fmg5z6iEW7UPPRhGdBDNuJx5y" -messages = [{"role":"user","content":"Request boss to grant me 1 day leave"}] -litellm.api_base = "https://api.deepinfra.com/v1/" -response = litellm.completion(model="meta-llama/Llama-2-70b-chat-hf", messages=messages, custom_llm_provider="openai", logger_fn=logger_fn) \ No newline at end of file +# os.environ["OPENAI_API_KEY"] = str(temp_key) # this passes linting#5 \ No newline at end of file