(code clean up) use a folder for gcs bucket logging + add readme in folder (#6080)

* refactor gcs bucket

* add readme
This commit is contained in:
Ishaan Jaff 2024-10-05 16:58:10 +05:30 committed by GitHub
parent 6e6d38841f
commit 3cb04480fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 6 deletions

View file

@ -0,0 +1,12 @@
# GCS (Google Cloud Storage) Bucket Logging on LiteLLM Gateway
This folder contains the GCS Bucket Logging integration for LiteLLM Gateway.
## Folder Structure
- `gcs_bucket.py`: This is the main file that handles failure/success logging to GCS Bucket
- `gcs_bucket_base.py`: This file contains the GCSBucketBase class which handles Authentication for GCS Buckets
## Further Reading
- [Doc setting up GCS Bucket Logging on LiteLLM Proxy (Gateway)](https://docs.litellm.ai/docs/proxy/bucket)
- [Doc on Key / Team Based logging with GCS](https://docs.litellm.ai/docs/proxy/team_logging)

View file

@ -11,7 +11,7 @@ from pydantic import BaseModel, Field
import litellm import litellm
from litellm._logging import verbose_logger from litellm._logging import verbose_logger
from litellm.integrations.custom_logger import CustomLogger from litellm.integrations.custom_logger import CustomLogger
from litellm.integrations.gcs_bucket_base import GCSBucketBase from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase
from litellm.litellm_core_utils.logging_utils import ( from litellm.litellm_core_utils.logging_utils import (
convert_litellm_response_object_to_dict, convert_litellm_response_object_to_dict,
) )

View file

@ -65,7 +65,7 @@ from ..integrations.clickhouse import ClickhouseLogger
from ..integrations.datadog.datadog import DataDogLogger from ..integrations.datadog.datadog import DataDogLogger
from ..integrations.dynamodb import DyanmoDBLogger from ..integrations.dynamodb import DyanmoDBLogger
from ..integrations.galileo import GalileoObserve from ..integrations.galileo import GalileoObserve
from ..integrations.gcs_bucket import GCSBucketLogger from ..integrations.gcs_bucket.gcs_bucket import GCSBucketLogger
from ..integrations.greenscale import GreenscaleLogger from ..integrations.greenscale import GreenscaleLogger
from ..integrations.helicone import HeliconeLogger from ..integrations.helicone import HeliconeLogger
from ..integrations.lago import LagoLogger from ..integrations.lago import LagoLogger

View file

@ -53,9 +53,9 @@ def get_file_contents_from_s3(bucket_name, object_key):
async def get_config_file_contents_from_gcs(bucket_name, object_key): async def get_config_file_contents_from_gcs(bucket_name, object_key):
try: try:
from litellm.integrations.gcs_bucket_base import GCSBucketBase from litellm.integrations.gcs_bucket.gcs_bucket import GCSBucketLogger
gcs_bucket = GCSBucketBase( gcs_bucket = GCSBucketLogger(
bucket_name=bucket_name, bucket_name=bucket_name,
) )
file_contents = await gcs_bucket.download_gcs_object(object_key) file_contents = await gcs_bucket.download_gcs_object(object_key)

View file

@ -5,7 +5,7 @@ from typing import Optional
import litellm import litellm
from litellm._logging import verbose_logger from litellm._logging import verbose_logger
from litellm.caching import InMemoryCache from litellm.caching import InMemoryCache
from litellm.integrations.gcs_bucket_base import GCSBucketBase from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase
from litellm.llms.custom_httpx.http_handler import _get_httpx_client from litellm.llms.custom_httpx.http_handler import _get_httpx_client
from litellm.proxy._types import CommonProxyErrors, KeyManagementSystem from litellm.proxy._types import CommonProxyErrors, KeyManagementSystem

View file

@ -16,7 +16,10 @@ import pytest
import litellm import litellm
from litellm import completion from litellm import completion
from litellm._logging import verbose_logger from litellm._logging import verbose_logger
from litellm.integrations.gcs_bucket import GCSBucketLogger, StandardLoggingPayload from litellm.integrations.gcs_bucket.gcs_bucket import (
GCSBucketLogger,
StandardLoggingPayload,
)
from litellm.types.utils import StandardCallbackDynamicParams from litellm.types.utils import StandardCallbackDynamicParams
verbose_logger.setLevel(logging.DEBUG) verbose_logger.setLevel(logging.DEBUG)