mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
(fix) access user in custom logger
This commit is contained in:
parent
93f5c266da
commit
f3b939e603
1 changed files with 6 additions and 0 deletions
|
|
@ -15,8 +15,13 @@ class MyCustomHandler(CustomLogger):
|
|||
# log: key, user, model, prompt, response, tokens, cost
|
||||
print("\n kwargs\n")
|
||||
print(kwargs)
|
||||
### Access kwargs passed to litellm.completion()
|
||||
model = kwargs["model"]
|
||||
messages = kwargs["messages"]
|
||||
user = kwargs.get("user")
|
||||
#################################################
|
||||
|
||||
### Calculate cost #######################
|
||||
cost = litellm.completion_cost(completion_response=response_obj)
|
||||
response = response_obj
|
||||
# tokens used in response
|
||||
|
|
@ -26,6 +31,7 @@ class MyCustomHandler(CustomLogger):
|
|||
f"""
|
||||
Model: {model},
|
||||
Messages: {messages},
|
||||
User: {user},
|
||||
Usage: {usage},
|
||||
Cost: {cost},
|
||||
Response: {response}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue