mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
fix(litellm_logging.py): fix calling success callback w/ stream_options true
Fixes https://github.com/BerriAI/litellm/issues/5118
This commit is contained in:
parent
83180c50f7
commit
9d2410abb1
4 changed files with 50 additions and 28 deletions
|
@ -1,12 +1,18 @@
|
|||
# What is this?
|
||||
## On Success events log cost to OpenMeter - https://github.com/BerriAI/litellm/issues/1268
|
||||
|
||||
import dotenv, os, json
|
||||
import litellm
|
||||
import json
|
||||
import os
|
||||
import traceback
|
||||
import uuid
|
||||
|
||||
import dotenv
|
||||
import httpx
|
||||
|
||||
import litellm
|
||||
from litellm import verbose_logger
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
|
||||
import uuid
|
||||
|
||||
|
||||
def get_utc_datetime():
|
||||
|
@ -122,7 +128,11 @@ class OpenMeterLogger(CustomLogger):
|
|||
)
|
||||
|
||||
response.raise_for_status()
|
||||
except Exception as e:
|
||||
if hasattr(response, "text"):
|
||||
litellm.print_verbose(f"\nError Message: {response.text}")
|
||||
except httpx.HTTPStatusError as e:
|
||||
verbose_logger.error(
|
||||
"Failed OpenMeter logging - {}".format(e.response.text)
|
||||
)
|
||||
raise e
|
||||
except Exception as e:
|
||||
verbose_logger.error("Failed OpenMeter logging - {}".format(str(e)))
|
||||
raise e
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue