File tree Expand file tree Collapse file tree 2 files changed +223
-88
lines changed
tests/test_litellm/integrations Expand file tree Collapse file tree 2 files changed +223
-88
lines changed Original file line number Diff line number Diff line change 11#### What this does ####
22# On success + failure, log events to Supabase
33
4+ import hashlib
45from datetime import datetime
56from typing import Optional , cast
67
78import litellm
89from litellm ._logging import print_verbose , verbose_logger
910from litellm .types .utils import StandardLoggingPayload
1011
12+ MAX_S3_FILENAME_COMPONENT_LENGTH = 250
13+
1114
1215class S3Logger :
1316 # Class variables or attributes
@@ -185,6 +188,11 @@ def get_s3_object_key(
185188 start_time : datetime ,
186189 s3_file_name : str ,
187190) -> str :
191+ if len (s3_file_name ) > MAX_S3_FILENAME_COMPONENT_LENGTH :
192+ digest = hashlib .sha256 (s3_file_name .encode ("utf-8" )).hexdigest ()[:16 ]
193+ prefix_length = MAX_S3_FILENAME_COMPONENT_LENGTH - len (digest ) - 1
194+ s3_file_name = f"{ s3_file_name [:prefix_length ]} _{ digest } "
195+
188196 s3_object_key = (
189197 (s3_path .rstrip ("/" ) + "/" if s3_path else "" )
190198 + prefix
You can’t perform that action at this time.
0 commit comments