@@ -172,6 +172,36 @@ def __init__(
172172 # Enable error dropping for cleaner output
173173 litellm .drop_params = True
174174 self ._setup_event_tracking (events )
175+
176+ # Log all initialization parameters when in debug mode
177+ if not isinstance (verbose , bool ) and verbose >= 10 :
178+ debug_info = {
179+ "model" : self .model ,
180+ "timeout" : self .timeout ,
181+ "temperature" : self .temperature ,
182+ "top_p" : self .top_p ,
183+ "n" : self .n ,
184+ "max_tokens" : self .max_tokens ,
185+ "presence_penalty" : self .presence_penalty ,
186+ "frequency_penalty" : self .frequency_penalty ,
187+ "logit_bias" : self .logit_bias ,
188+ "response_format" : self .response_format ,
189+ "seed" : self .seed ,
190+ "logprobs" : self .logprobs ,
191+ "top_logprobs" : self .top_logprobs ,
192+ "api_version" : self .api_version ,
193+ "stop_phrases" : self .stop_phrases ,
194+ "api_key" : "***" if self .api_key else None , # Mask API key for security
195+ "base_url" : self .base_url ,
196+ "verbose" : self .verbose ,
197+ "markdown" : self .markdown ,
198+ "self_reflect" : self .self_reflect ,
199+ "max_reflect" : self .max_reflect ,
200+ "min_reflect" : self .min_reflect ,
201+ "reasoning_steps" : self .reasoning_steps ,
202+ "extra_settings" : {k : v for k , v in self .extra_settings .items () if k not in ["api_key" ]}
203+ }
204+ logging .debug (f"LLM instance initialized with: { json .dumps (debug_info , indent = 2 , default = str )} " )
175205
176206 def get_response (
177207 self ,
@@ -195,6 +225,56 @@ def get_response(
195225 ** kwargs
196226 ) -> str :
197227 """Enhanced get_response with all OpenAI-like features"""
228+ logging .info (f"Getting response from { self .model } " )
229+ # Log all self values when in debug mode
230+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
231+ debug_info = {
232+ "model" : self .model ,
233+ "timeout" : self .timeout ,
234+ "temperature" : self .temperature ,
235+ "top_p" : self .top_p ,
236+ "n" : self .n ,
237+ "max_tokens" : self .max_tokens ,
238+ "presence_penalty" : self .presence_penalty ,
239+ "frequency_penalty" : self .frequency_penalty ,
240+ "logit_bias" : self .logit_bias ,
241+ "response_format" : self .response_format ,
242+ "seed" : self .seed ,
243+ "logprobs" : self .logprobs ,
244+ "top_logprobs" : self .top_logprobs ,
245+ "api_version" : self .api_version ,
246+ "stop_phrases" : self .stop_phrases ,
247+ "api_key" : "***" if self .api_key else None , # Mask API key for security
248+ "base_url" : self .base_url ,
249+ "verbose" : self .verbose ,
250+ "markdown" : self .markdown ,
251+ "self_reflect" : self .self_reflect ,
252+ "max_reflect" : self .max_reflect ,
253+ "min_reflect" : self .min_reflect ,
254+ "reasoning_steps" : self .reasoning_steps
255+ }
256+ logging .debug (f"LLM instance configuration: { json .dumps (debug_info , indent = 2 , default = str )} " )
257+
258+ # Log the parameter values passed to get_response
259+ param_info = {
260+ "prompt" : str (prompt )[:100 ] + "..." if isinstance (prompt , str ) and len (str (prompt )) > 100 else str (prompt ),
261+ "system_prompt" : system_prompt [:100 ] + "..." if system_prompt and len (system_prompt ) > 100 else system_prompt ,
262+ "chat_history" : f"[{ len (chat_history )} messages]" if chat_history else None ,
263+ "temperature" : temperature ,
264+ "tools" : [t .__name__ if hasattr (t , "__name__" ) else str (t ) for t in tools ] if tools else None ,
265+ "output_json" : str (output_json .__class__ .__name__ ) if output_json else None ,
266+ "output_pydantic" : str (output_pydantic .__class__ .__name__ ) if output_pydantic else None ,
267+ "verbose" : verbose ,
268+ "markdown" : markdown ,
269+ "self_reflect" : self_reflect ,
270+ "max_reflect" : max_reflect ,
271+ "min_reflect" : min_reflect ,
272+ "agent_name" : agent_name ,
273+ "agent_role" : agent_role ,
274+ "agent_tools" : agent_tools ,
275+ "kwargs" : str (kwargs )
276+ }
277+ logging .debug (f"get_response parameters: { json .dumps (param_info , indent = 2 , default = str )} " )
198278 try :
199279 import litellm
200280 # This below **kwargs** is passed to .completion() directly. so reasoning_steps has to be popped. OR find alternate best way of handling this.
@@ -552,6 +632,11 @@ def get_response(
552632 except Exception as error :
553633 display_error (f"Error in get_response: { str (error )} " )
554634 raise
635+
636+ # Log completion time if in debug mode
637+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
638+ total_time = time .time () - start_time
639+ logging .debug (f"get_response completed in { total_time :.2f} seconds" )
555640
556641 async def get_response_async (
557642 self ,
@@ -577,6 +662,56 @@ async def get_response_async(
577662 """Async version of get_response with identical functionality."""
578663 try :
579664 import litellm
665+ logging .info (f"Getting async response from { self .model } " )
666+ # Log all self values when in debug mode
667+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
668+ debug_info = {
669+ "model" : self .model ,
670+ "timeout" : self .timeout ,
671+ "temperature" : self .temperature ,
672+ "top_p" : self .top_p ,
673+ "n" : self .n ,
674+ "max_tokens" : self .max_tokens ,
675+ "presence_penalty" : self .presence_penalty ,
676+ "frequency_penalty" : self .frequency_penalty ,
677+ "logit_bias" : self .logit_bias ,
678+ "response_format" : self .response_format ,
679+ "seed" : self .seed ,
680+ "logprobs" : self .logprobs ,
681+ "top_logprobs" : self .top_logprobs ,
682+ "api_version" : self .api_version ,
683+ "stop_phrases" : self .stop_phrases ,
684+ "api_key" : "***" if self .api_key else None , # Mask API key for security
685+ "base_url" : self .base_url ,
686+ "verbose" : self .verbose ,
687+ "markdown" : self .markdown ,
688+ "self_reflect" : self .self_reflect ,
689+ "max_reflect" : self .max_reflect ,
690+ "min_reflect" : self .min_reflect ,
691+ "reasoning_steps" : self .reasoning_steps
692+ }
693+ logging .debug (f"LLM async instance configuration: { json .dumps (debug_info , indent = 2 , default = str )} " )
694+
695+ # Log the parameter values passed to get_response_async
696+ param_info = {
697+ "prompt" : str (prompt )[:100 ] + "..." if isinstance (prompt , str ) and len (str (prompt )) > 100 else str (prompt ),
698+ "system_prompt" : system_prompt [:100 ] + "..." if system_prompt and len (system_prompt ) > 100 else system_prompt ,
699+ "chat_history" : f"[{ len (chat_history )} messages]" if chat_history else None ,
700+ "temperature" : temperature ,
701+ "tools" : [t .__name__ if hasattr (t , "__name__" ) else str (t ) for t in tools ] if tools else None ,
702+ "output_json" : str (output_json .__class__ .__name__ ) if output_json else None ,
703+ "output_pydantic" : str (output_pydantic .__class__ .__name__ ) if output_pydantic else None ,
704+ "verbose" : verbose ,
705+ "markdown" : markdown ,
706+ "self_reflect" : self_reflect ,
707+ "max_reflect" : max_reflect ,
708+ "min_reflect" : min_reflect ,
709+ "agent_name" : agent_name ,
710+ "agent_role" : agent_role ,
711+ "agent_tools" : agent_tools ,
712+ "kwargs" : str (kwargs )
713+ }
714+ logging .debug (f"get_response_async parameters: { json .dumps (param_info , indent = 2 , default = str )} " )
580715 reasoning_steps = kwargs .pop ('reasoning_steps' , self .reasoning_steps )
581716 litellm .set_verbose = False
582717
@@ -983,6 +1118,11 @@ async def get_response_async(
9831118 raise LLMContextLengthExceededException (str (error ))
9841119 display_error (f"Error in get_response_async: { str (error )} " )
9851120 raise
1121+
1122+ # Log completion time if in debug mode
1123+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
1124+ total_time = time .time () - start_time
1125+ logging .debug (f"get_response_async completed in { total_time :.2f} seconds" )
9861126
9871127 def can_use_tools (self ) -> bool :
9881128 """Check if this model can use tool functions"""
@@ -1065,6 +1205,24 @@ def response(
10651205
10661206 logger .debug ("Using synchronous response function" )
10671207
1208+ # Log all self values when in debug mode
1209+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
1210+ debug_info = {
1211+ "model" : self .model ,
1212+ "timeout" : self .timeout ,
1213+ "temperature" : temperature ,
1214+ "top_p" : self .top_p ,
1215+ "n" : self .n ,
1216+ "max_tokens" : self .max_tokens ,
1217+ "presence_penalty" : self .presence_penalty ,
1218+ "frequency_penalty" : self .frequency_penalty ,
1219+ "stream" : stream ,
1220+ "verbose" : verbose ,
1221+ "markdown" : markdown ,
1222+ "kwargs" : str (kwargs )
1223+ }
1224+ logger .debug (f"Response method configuration: { json .dumps (debug_info , indent = 2 , default = str )} " )
1225+
10681226 # Build messages list
10691227 messages = []
10701228 if system_prompt :
@@ -1150,6 +1308,24 @@ async def aresponse(
11501308
11511309 logger .debug ("Using asynchronous response function" )
11521310
1311+ # Log all self values when in debug mode
1312+ if logging .getLogger ().getEffectiveLevel () == logging .DEBUG :
1313+ debug_info = {
1314+ "model" : self .model ,
1315+ "timeout" : self .timeout ,
1316+ "temperature" : temperature ,
1317+ "top_p" : self .top_p ,
1318+ "n" : self .n ,
1319+ "max_tokens" : self .max_tokens ,
1320+ "presence_penalty" : self .presence_penalty ,
1321+ "frequency_penalty" : self .frequency_penalty ,
1322+ "stream" : stream ,
1323+ "verbose" : verbose ,
1324+ "markdown" : markdown ,
1325+ "kwargs" : str (kwargs )
1326+ }
1327+ logger .debug (f"Async response method configuration: { json .dumps (debug_info , indent = 2 , default = str )} " )
1328+
11531329 # Build messages list
11541330 messages = []
11551331 if system_prompt :
0 commit comments