forked from phoenix/litellm-mirror
Merge branch 'main' into litellm_braintrust_integration
This commit is contained in:
commit
e770ac48a2
39 changed files with 1369 additions and 76 deletions
|
@ -1962,6 +1962,43 @@ def _init_custom_logger_compatible_class(
|
|||
_langsmith_logger = LangsmithLogger()
|
||||
_in_memory_loggers.append(_langsmith_logger)
|
||||
return _langsmith_logger # type: ignore
|
||||
elif logging_integration == "arize":
|
||||
if "ARIZE_SPACE_KEY" not in os.environ:
|
||||
raise ValueError("ARIZE_SPACE_KEY not found in environment variables")
|
||||
if "ARIZE_API_KEY" not in os.environ:
|
||||
raise ValueError("ARIZE_API_KEY not found in environment variables")
|
||||
from litellm.integrations.opentelemetry import (
|
||||
OpenTelemetry,
|
||||
OpenTelemetryConfig,
|
||||
)
|
||||
|
||||
otel_config = OpenTelemetryConfig(
|
||||
exporter="otlp_grpc",
|
||||
endpoint="https://otlp.arize.com/v1",
|
||||
)
|
||||
os.environ["OTEL_EXPORTER_OTLP_TRACES_HEADERS"] = (
|
||||
f"space_key={os.getenv('ARIZE_SPACE_KEY')},api_key={os.getenv('ARIZE_API_KEY')}"
|
||||
)
|
||||
for callback in _in_memory_loggers:
|
||||
if (
|
||||
isinstance(callback, OpenTelemetry)
|
||||
and callback.callback_name == "arize"
|
||||
):
|
||||
return callback # type: ignore
|
||||
_otel_logger = OpenTelemetry(config=otel_config, callback_name="arize")
|
||||
_in_memory_loggers.append(_otel_logger)
|
||||
return _otel_logger # type: ignore
|
||||
|
||||
elif logging_integration == "otel":
|
||||
from litellm.integrations.opentelemetry import OpenTelemetry
|
||||
|
||||
for callback in _in_memory_loggers:
|
||||
if isinstance(callback, OpenTelemetry):
|
||||
return callback # type: ignore
|
||||
|
||||
otel_logger = OpenTelemetry()
|
||||
_in_memory_loggers.append(otel_logger)
|
||||
return otel_logger # type: ignore
|
||||
|
||||
elif logging_integration == "galileo":
|
||||
for callback in _in_memory_loggers:
|
||||
|
@ -2039,6 +2076,25 @@ def get_custom_logger_compatible_class(
|
|||
for callback in _in_memory_loggers:
|
||||
if isinstance(callback, LangsmithLogger):
|
||||
return callback
|
||||
elif logging_integration == "otel":
|
||||
from litellm.integrations.opentelemetry import OpenTelemetry
|
||||
|
||||
for callback in _in_memory_loggers:
|
||||
if isinstance(callback, OpenTelemetry):
|
||||
return callback
|
||||
elif logging_integration == "arize":
|
||||
from litellm.integrations.opentelemetry import OpenTelemetry
|
||||
|
||||
if "ARIZE_SPACE_KEY" not in os.environ:
|
||||
raise ValueError("ARIZE_SPACE_KEY not found in environment variables")
|
||||
if "ARIZE_API_KEY" not in os.environ:
|
||||
raise ValueError("ARIZE_API_KEY not found in environment variables")
|
||||
for callback in _in_memory_loggers:
|
||||
if (
|
||||
isinstance(callback, OpenTelemetry)
|
||||
and callback.callback_name == "arize"
|
||||
):
|
||||
return callback
|
||||
elif logging_integration == "logfire":
|
||||
if "LOGFIRE_TOKEN" not in os.environ:
|
||||
raise ValueError("LOGFIRE_TOKEN not found in environment variables")
|
||||
|
|
|
@ -87,3 +87,33 @@ def redact_message_input_output_from_logging(
|
|||
|
||||
# by default return result
|
||||
return result
|
||||
|
||||
|
||||
def redact_user_api_key_info(metadata: dict) -> dict:
|
||||
"""
|
||||
removes any user_api_key_info before passing to logging object, if flag set
|
||||
|
||||
Usage:
|
||||
|
||||
SDK
|
||||
```python
|
||||
litellm.redact_user_api_key_info = True
|
||||
```
|
||||
|
||||
PROXY:
|
||||
```yaml
|
||||
litellm_settings:
|
||||
redact_user_api_key_info: true
|
||||
```
|
||||
"""
|
||||
if litellm.redact_user_api_key_info is not True:
|
||||
return metadata
|
||||
|
||||
new_metadata = {}
|
||||
for k, v in metadata.items():
|
||||
if isinstance(k, str) and k.startswith("user_api_key"):
|
||||
pass
|
||||
else:
|
||||
new_metadata[k] = v
|
||||
|
||||
return new_metadata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue