mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
(fix) allow using more than 1 custom callback
This commit is contained in:
parent
5cf3c3dc86
commit
16f598aa3f
1 changed files with 6 additions and 7 deletions
|
@ -10,11 +10,10 @@ import traceback
|
|||
|
||||
class CustomLogger:
|
||||
# Class variables or attributes
|
||||
def __init__(self, callback_func):
|
||||
# Instance variables
|
||||
self.callback_func = callback_func
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def log_input_event(self, model, messages, kwargs, print_verbose):
|
||||
def log_input_event(self, model, messages, kwargs, print_verbose, callback_func):
|
||||
try:
|
||||
print_verbose(
|
||||
f"Custom Logger - Enters logging function for model {kwargs}"
|
||||
|
@ -22,7 +21,7 @@ class CustomLogger:
|
|||
kwargs["model"] = model
|
||||
kwargs["messages"] = messages
|
||||
kwargs["log_event_type"] = "pre_api_call"
|
||||
self.callback_func(
|
||||
callback_func(
|
||||
kwargs,
|
||||
)
|
||||
print_verbose(
|
||||
|
@ -32,14 +31,14 @@ class CustomLogger:
|
|||
traceback.print_exc()
|
||||
print_verbose(f"Custom Logger Error - {traceback.format_exc()}")
|
||||
|
||||
def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose):
|
||||
def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose, callback_func):
|
||||
# Method definition
|
||||
try:
|
||||
print_verbose(
|
||||
f"Custom Logger - Enters logging function for model {kwargs}"
|
||||
)
|
||||
kwargs["log_event_type"] = "post_api_call"
|
||||
self.callback_func(
|
||||
callback_func(
|
||||
kwargs, # kwargs to func
|
||||
response_obj,
|
||||
start_time,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue