mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(fix) logging callbacks - promptlayer
This commit is contained in:
parent
1bef2c62a6
commit
2c18f7d374
1 changed files with 11 additions and 4 deletions
|
@ -17,18 +17,25 @@ class PromptLayerLogger:
|
||||||
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):
|
||||||
# Method definition
|
# Method definition
|
||||||
try:
|
try:
|
||||||
if 'litellm_logging_obj' in kwargs:
|
new_kwargs = {}
|
||||||
kwargs.pop('litellm_logging_obj')
|
new_kwargs['model'] = kwargs['model']
|
||||||
|
new_kwargs['messages'] = kwargs['messages']
|
||||||
|
|
||||||
|
# add kwargs["optional_params"] to new_kwargs
|
||||||
|
for optional_param in kwargs["optional_params"]:
|
||||||
|
new_kwargs[optional_param] = kwargs["optional_params"][optional_param]
|
||||||
|
|
||||||
|
|
||||||
print_verbose(
|
print_verbose(
|
||||||
f"Prompt Layer Logging - Enters logging function for model kwargs: {kwargs}\n, response: {response_obj}"
|
f"Prompt Layer Logging - Enters logging function for model kwargs: {new_kwargs}\n, response: {response_obj}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
request_response = requests.post(
|
request_response = requests.post(
|
||||||
"https://api.promptlayer.com/rest/track-request",
|
"https://api.promptlayer.com/rest/track-request",
|
||||||
json={
|
json={
|
||||||
"function_name": "openai.ChatCompletion.create",
|
"function_name": "openai.ChatCompletion.create",
|
||||||
"kwargs": kwargs,
|
"kwargs": new_kwargs,
|
||||||
"tags": ["hello", "world"],
|
"tags": ["hello", "world"],
|
||||||
"request_response": dict(response_obj),
|
"request_response": dict(response_obj),
|
||||||
"request_start_time": int(start_time.timestamp()),
|
"request_start_time": int(start_time.timestamp()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue