mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
Merge pull request #5077 from BerriAI/litellm_fix_ui_emails
[Fix] Fix testing emails through Admin UI
This commit is contained in:
commit
237c3a0244
4 changed files with 21 additions and 19 deletions
|
@ -1263,6 +1263,10 @@ Model Info:
|
|||
|
||||
if self.alerting is None or "email" not in self.alerting:
|
||||
# do nothing if user does not want email alerts
|
||||
verbose_proxy_logger.error(
|
||||
"Error sending email alert - 'email' not in self.alerting %s",
|
||||
self.alerting,
|
||||
)
|
||||
return False
|
||||
from litellm.proxy.proxy_server import premium_user, prisma_client
|
||||
|
||||
|
|
|
@ -168,14 +168,14 @@ def missing_keys_form(missing_key_names: str):
|
|||
return missing_keys_html_form.format(missing_keys=missing_key_names)
|
||||
|
||||
|
||||
def setup_admin_ui_on_server_root_path():
|
||||
def setup_admin_ui_on_server_root_path(server_root_path: str):
|
||||
"""
|
||||
Helper util to setup Admin UI on Server root path
|
||||
"""
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
|
||||
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
|
||||
if server_root_path != "":
|
||||
print("setting proxy base url to server root path") # noqa
|
||||
if os.getenv("PROXY_BASE_URL") is None:
|
||||
os.environ["PROXY_BASE_URL"] = server_root_path
|
||||
|
||||
|
@ -190,9 +190,7 @@ def setup_admin_ui_on_server_root_path():
|
|||
build_ui_path = os.path.join(current_dir, "build_ui_custom_path.sh")
|
||||
package_path = os.path.join(current_dir, "package.json")
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
f"Setting up Admin UI on {server_root_path}/ui ......."
|
||||
) # noqa
|
||||
print(f"Setting up Admin UI on {server_root_path}/ui .......") # noqa
|
||||
|
||||
try:
|
||||
# Change the current working directory
|
||||
|
@ -212,21 +210,17 @@ def setup_admin_ui_on_server_root_path():
|
|||
["./build_ui_custom_path.sh", f"{server_root_path}/ui"], check=True
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug("Admin UI setup completed successfully.") # noqa
|
||||
print("Admin UI setup completed successfully.") # noqa
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
verbose_proxy_logger.debug(
|
||||
f"An error occurred during the Admin UI setup: {e}"
|
||||
) # noqa
|
||||
print(f"An error occurred during the Admin UI setup: {e}") # noqa
|
||||
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.debug(f"An unexpected error occurred: {e}")
|
||||
print(f"An unexpected error occurred: {e}") # noqa
|
||||
|
||||
finally:
|
||||
# Always return to the original directory, even if an error occurred
|
||||
os.chdir(original_dir)
|
||||
verbose_proxy_logger.debug(
|
||||
f"Returned to original directory: {original_dir}"
|
||||
) # noqa
|
||||
print(f"Returned to original directory: {original_dir}") # noqa
|
||||
|
||||
pass
|
||||
|
|
|
@ -241,11 +241,9 @@ async def health_services_endpoint(
|
|||
)
|
||||
|
||||
# use create task - this can take 10 seconds. don't keep ui users waiting for notification to check their email
|
||||
asyncio.create_task(
|
||||
proxy_logging_obj.slack_alerting_instance.send_key_created_or_user_invited_email(
|
||||
await proxy_logging_obj.slack_alerting_instance.send_key_created_or_user_invited_email(
|
||||
webhook_event=webhook_event
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
|
|
|
@ -284,8 +284,9 @@ except Exception as e:
|
|||
pass
|
||||
|
||||
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
|
||||
print("server root path: ", server_root_path) # noqa
|
||||
if server_root_path != "":
|
||||
setup_admin_ui_on_server_root_path()
|
||||
setup_admin_ui_on_server_root_path(server_root_path)
|
||||
_license_check = LicenseCheck()
|
||||
premium_user: bool = _license_check.is_premium()
|
||||
ui_link = f"{server_root_path}/ui/"
|
||||
|
@ -2103,7 +2104,6 @@ class ProxyConfig:
|
|||
for alert in _general_settings["alerting"]:
|
||||
if alert not in general_settings["alerting"]:
|
||||
general_settings["alerting"].append(alert)
|
||||
|
||||
proxy_logging_obj.alerting = general_settings["alerting"]
|
||||
proxy_logging_obj.slack_alerting_instance.alerting = general_settings[
|
||||
"alerting"
|
||||
|
@ -2115,6 +2115,12 @@ class ProxyConfig:
|
|||
proxy_logging_obj.slack_alerting_instance.alerting = general_settings[
|
||||
"alerting"
|
||||
]
|
||||
elif isinstance(general_settings, dict):
|
||||
general_settings["alerting"] = _general_settings["alerting"]
|
||||
proxy_logging_obj.alerting = general_settings["alerting"]
|
||||
proxy_logging_obj.slack_alerting_instance.alerting = general_settings[
|
||||
"alerting"
|
||||
]
|
||||
|
||||
if "alert_types" in _general_settings:
|
||||
general_settings["alert_types"] = _general_settings["alert_types"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue