mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
Merge pull request #1494 from duarteocarmo/patch-1
Update s3 cache to support folder
This commit is contained in:
commit
7db04afaca
2 changed files with 7 additions and 1 deletions
|
|
@ -204,6 +204,7 @@ def __init__(
|
|||
s3_bucket_name: Optional[str] = None,
|
||||
s3_region_name: Optional[str] = None,
|
||||
s3_api_version: Optional[str] = None,
|
||||
s3_path: Optional[str] = None, # if you wish to save to a spefic path
|
||||
s3_use_ssl: Optional[bool] = True,
|
||||
s3_verify: Optional[Union[bool, str]] = None,
|
||||
s3_endpoint_url: Optional[str] = None,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class S3Logger:
|
|||
def __init__(
|
||||
self,
|
||||
s3_bucket_name=None,
|
||||
s3_path=None,
|
||||
s3_region_name=None,
|
||||
s3_api_version=None,
|
||||
s3_use_ssl=True,
|
||||
|
|
@ -57,6 +58,7 @@ class S3Logger:
|
|||
# done reading litellm.s3_callback_params
|
||||
|
||||
self.bucket_name = s3_bucket_name
|
||||
self.s3_path = s3_path
|
||||
# Create an S3 client with custom endpoint URL
|
||||
self.s3_client = boto3.client(
|
||||
"s3",
|
||||
|
|
@ -122,7 +124,10 @@ class S3Logger:
|
|||
pass
|
||||
|
||||
s3_object_key = (
|
||||
payload["id"] + "-time=" + str(start_time)
|
||||
(self.s3_path.rstrip("/") + "/" if self.s3_path else "")
|
||||
+ payload["id"]
|
||||
+ "-time="
|
||||
+ str(start_time)
|
||||
) # we need the s3 key to include the time, so we log cache hits too
|
||||
|
||||
import json
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue