mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
Update test_api_key_param.py
This commit is contained in:
parent
20ece924a7
commit
2ea993b33a
1 changed files with 20 additions and 20 deletions
|
@ -1,25 +1,25 @@
|
||||||
#### What this tests ####
|
# #### What this tests ####
|
||||||
# This tests the ability to set api key's via the params instead of as environment variables
|
# # This tests the ability to set api key's via the params instead of as environment variables
|
||||||
|
|
||||||
import sys, os
|
# import sys, os
|
||||||
import traceback
|
# import traceback
|
||||||
sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path
|
# sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path
|
||||||
import litellm
|
# import litellm
|
||||||
from litellm import embedding, completion
|
# from litellm import embedding, completion
|
||||||
|
|
||||||
litellm.set_verbose = False
|
# litellm.set_verbose = False
|
||||||
|
|
||||||
def logger_fn(model_call_object: dict):
|
# def logger_fn(model_call_object: dict):
|
||||||
print(f"model call details: {model_call_object}")
|
# print(f"model call details: {model_call_object}")
|
||||||
|
|
||||||
user_message = "Hello, how are you?"
|
# user_message = "Hello, how are you?"
|
||||||
messages = [{ "content": user_message,"role": "user"}]
|
# messages = [{ "content": user_message,"role": "user"}]
|
||||||
|
|
||||||
temp_key = os.environ.get("OPENAI_API_KEY")
|
# temp_key = os.environ.get("OPENAI_API_KEY")
|
||||||
os.environ["OPENAI_API_KEY"] = "bad-key"
|
# os.environ["OPENAI_API_KEY"] = "bad-key"
|
||||||
# test on openai completion call
|
# # test on openai completion call
|
||||||
try:
|
# try:
|
||||||
response = completion(model="gpt-3.5-turbo", messages=messages, logger_fn=logger_fn, api_key=temp_key)
|
# response = completion(model="gpt-3.5-turbo", messages=messages, logger_fn=logger_fn, api_key=temp_key)
|
||||||
except:
|
# except:
|
||||||
print(f"error occurred: {traceback.format_exc()}")
|
# print(f"error occurred: {traceback.format_exc()}")
|
||||||
pass
|
# pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue