fix:completion fails when client=True&no email set

This commit is contained in:
ishaan-jaff 2023-09-08 12:36:21 -07:00
parent 7b795fcd64
commit b0a2e57a8a
3 changed files with 5 additions and 6 deletions

View file

@ -13,6 +13,8 @@ class LiteDebugger:
def validate_environment(self, email):
try:
self.user_email = (email or os.getenv("LITELLM_TOKEN") or os.getenv("LITELLM_EMAIL"))
if self.user_email == None: # if users are trying to use_client=True but token not set
raise ValueError("litellm.use_client = True but no token or email passed. Please set it in litellm.token")
self.dashboard_url = "https://admin.litellm.ai/" + self.user_email
try:
print(
@ -21,7 +23,7 @@ class LiteDebugger:
except:
print(f"Here's your LiteLLM Dashboard 👉 {self.dashboard_url}")
if self.user_email == None:
raise Exception(
raise ValueError(
"[Non-Blocking Error] LiteLLMDebugger: Missing LITELLM_TOKEN. Set it in your environment. Eg.: os.environ['LITELLM_TOKEN']= <your_email>"
)
except Exception as e:

View file

@ -15,10 +15,6 @@ from litellm import embedding, completion, text_completion, completion_cost
litellm.vertex_project = "pathrise-convert-1606954137718"
litellm.vertex_location = "us-central1"
litellm.use_client = True
# from infisical import InfisicalClient
# litellm.set_verbose = True
# litellm.secret_manager_client = InfisicalClient(token=os.environ["INFISICAL_TOKEN"])
user_message = "Write a short poem about the sky"
messages = [{"content": user_message, "role": "user"}]
@ -217,6 +213,7 @@ def test_completion_openai_prompt():
def test_completion_text_openai():
try:
# litellm.set_verbose=True
response = completion(model="text-davinci-003", messages=messages)
# Add any assertions here to check the response
print(response)

View file

@ -1061,7 +1061,7 @@ def set_callbacks(callback_list, function_id=None):
elif litellm.email:
liteDebuggerClient = LiteDebugger(email=litellm.email)
else:
liteDebuggerClient = LiteDebugger()
liteDebuggerClient = LiteDebugger(email=str(uuid.uuid4()))
except Exception as e:
raise e