Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update s3 cache to support folder #1494

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/my-website/docs/caching/redis_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion litellm/integrations/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -57,6 +58,7 @@ def __init__(
# 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",
Expand Down Expand Up @@ -122,7 +124,10 @@ def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose):
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
duarteocarmo marked this conversation as resolved.
Show resolved Hide resolved

import json
Expand Down