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

[Feat] Log Request metadata on gcs bucket logging #5743

Merged
merged 9 commits into from
Sep 18, 2024
Next Next commit
add requester_metadata in standard logging payload
  • Loading branch information
ishaan-jaff committed Sep 17, 2024
commit b71c2f583a898bbb07758a81b17231940a556713
36 changes: 19 additions & 17 deletions litellm/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, Dict, List, Literal, Optional, Tuple, Union

from openai._models import BaseModel as OpenAIObject
from openai.types.audio.transcription_create_params import FileTypes
from openai.types.completion_usage import CompletionTokensDetails, CompletionUsage
from pydantic import ConfigDict, Field, PrivateAttr
from typing_extensions import Callable, Dict, Required, TypedDict, override
Expand Down Expand Up @@ -253,7 +252,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -359,7 +358,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -641,6 +640,7 @@ def __init__(
if choices is not None and isinstance(choices, list):
new_choices = []
for choice in choices:
_new_choice = None
if isinstance(choice, StreamingChoices):
_new_choice = choice
elif isinstance(choice, dict):
Expand Down Expand Up @@ -715,7 +715,7 @@ def __getitem__(self, key):
# Allow dictionary-style access to attributes
return getattr(self, key)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -804,7 +804,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -855,7 +855,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -911,6 +911,7 @@ def __init__(
if choices is not None and isinstance(choices, list):
new_choices = []
for choice in choices:
_new_choice = None
if isinstance(choice, TextChoices):
_new_choice = choice
elif isinstance(choice, dict):
Expand All @@ -937,12 +938,12 @@ def __init__(
usage = Usage()

super(TextCompletionResponse, self).__init__(
id=id,
object=object,
created=created,
model=model,
choices=choices,
usage=usage,
id=id, # type: ignore
object=object, # type: ignore
created=created, # type: ignore
model=model, # type: ignore
choices=choices, # type: ignore
usage=usage, # type: ignore
**params,
)

Expand Down Expand Up @@ -986,7 +987,7 @@ class ImageObject(OpenAIObject):
revised_prompt: Optional[str] = None

def __init__(self, b64_json=None, url=None, revised_prompt=None):
super().__init__(b64_json=b64_json, url=url, revised_prompt=revised_prompt)
super().__init__(b64_json=b64_json, url=url, revised_prompt=revised_prompt) # type: ignore

def __contains__(self, key):
# Define custom behavior for the 'in' operator
Expand All @@ -1004,7 +1005,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -1057,7 +1058,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand All @@ -1072,7 +1073,7 @@ class TranscriptionResponse(OpenAIObject):
_response_headers: Optional[dict] = None

def __init__(self, text=None):
super().__init__(text=text)
super().__init__(text=text) # type: ignore

def __contains__(self, key):
# Define custom behavior for the 'in' operator
Expand All @@ -1090,7 +1091,7 @@ def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)

def json(self, **kwargs):
def json(self, **kwargs): # type: ignore
try:
return self.model_dump() # noqa
except:
Expand Down Expand Up @@ -1247,6 +1248,7 @@ class StandardLoggingMetadata(TypedDict):
dict
] # special param to log k,v pairs to spendlogs for a call
requester_ip_address: Optional[str]
requester_metadata: Optional[dict]


class StandardLoggingHiddenParams(TypedDict):
Expand Down