Commit c52d2e2b authored by Your Name's avatar Your Name

Enable litellm debug mode when --debug flag is set

parent 04b971a4
...@@ -93,6 +93,9 @@ class LiteLLMBackend: ...@@ -93,6 +93,9 @@ class LiteLLMBackend:
litellm.base_url = self.base_url litellm.base_url = self.base_url
if self.api_key: if self.api_key:
litellm.api_key = self.api_key litellm.api_key = self.api_key
# Turn on litellm debug mode if global debug is enabled
_setup_litellm_debug()
def normalize_model_name(self, model: str) -> str: def normalize_model_name(self, model: str) -> str:
""" """
...@@ -745,6 +748,25 @@ class LiteLLMBackend: ...@@ -745,6 +748,25 @@ class LiteLLMBackend:
default_litellm_backend: Optional[LiteLLMBackend] = None default_litellm_backend: Optional[LiteLLMBackend] = None
# Turn on litellm debug mode if global debug is enabled
def _setup_litellm_debug():
"""Turn on litellm debug mode if global debug is enabled."""
global global_debug
try:
# Import global_args from coderai
import sys
import os
# Try to get global_args from the coderai module
if 'coderai' in sys.modules:
from coderai import global_debug as coderai_debug
if coderai_debug:
import litellm
litellm._turn_on_debug()
print("DEBUG litellm: Debug mode enabled")
except Exception as e:
print(f"DEBUG litellm: Could not enable debug mode: {e}")
def get_litellm_backend( def get_litellm_backend(
model: str = "gpt-3.5-turbo", model: str = "gpt-3.5-turbo",
api_key: Optional[str] = None, api_key: Optional[str] = None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment