refactor: rename enterprise specific hooks and callbacks to be more precise

This commit is contained in:
Krrish Dholakia 2024-02-17 17:52:32 -08:00
parent ad81e19282
commit 73acdf3736
6 changed files with 6 additions and 10 deletions

View file

@ -1421,7 +1421,7 @@ class ProxyConfig:
isinstance(callback, str) isinstance(callback, str)
and callback == "llamaguard_moderations" and callback == "llamaguard_moderations"
): ):
from litellm.proxy.enterprise.hooks.llama_guard import ( from litellm.proxy.enterprise.enterprise_hooks.llama_guard import (
_ENTERPRISE_LlamaGuard, _ENTERPRISE_LlamaGuard,
) )

View file

@ -34,6 +34,7 @@ from dataclasses import (
try: try:
# this works in python 3.8 # this works in python 3.8
import pkg_resources import pkg_resources
filename = pkg_resources.resource_filename(__name__, "llms/tokenizers") filename = pkg_resources.resource_filename(__name__, "llms/tokenizers")
# try: # try:
# filename = str( # filename = str(
@ -42,6 +43,7 @@ try:
except: except:
# this works in python 3.9+ # this works in python 3.9+
from importlib import resources from importlib import resources
filename = str( filename = str(
resources.files(litellm).joinpath("llms/tokenizers") # for python 3.10 resources.files(litellm).joinpath("llms/tokenizers") # for python 3.10
) # for python 3.10+ ) # for python 3.10+
@ -87,16 +89,10 @@ from .exceptions import (
UnprocessableEntityError, UnprocessableEntityError,
) )
# Import Enterprise features
project_path = abspath(join(dirname(__file__), "..", ".."))
# Add the "enterprise" directory to sys.path
verbose_logger.debug(f"current project_path: {project_path}")
enterprise_path = abspath(join(project_path, "enterprise"))
sys.path.append(enterprise_path)
verbose_logger.debug(f"sys.path: {sys.path}")
try: try:
from enterprise.callbacks.generic_api_callback import GenericAPILogger from .proxy.enterprise.enterprise_callbacks.generic_api_callback import (
GenericAPILogger,
)
except Exception as e: except Exception as e:
verbose_logger.debug(f"Exception import enterprise features {str(e)}") verbose_logger.debug(f"Exception import enterprise features {str(e)}")