mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
feat - allow sending tags
on vertex pass through requests (#6876)
* feat - allow tagging vertex JS SDK request * add unit testing for passing headers for pass through endpoints * fix allow using vertex_ai as the primary way for pass through vertex endpoints * docs on vertex js pass tags * add e2e test for vertex pass through with spend tags * add e2e tests for streaming vertex JS with tags * fix vertex ai testing
This commit is contained in:
parent
c73ce95c01
commit
f77bf49772
7 changed files with 548 additions and 77 deletions
|
@ -393,6 +393,7 @@ async def pass_through_request( # noqa: PLR0915
|
|||
_parsed_body=_parsed_body,
|
||||
passthrough_logging_payload=passthrough_logging_payload,
|
||||
litellm_call_id=litellm_call_id,
|
||||
request=request,
|
||||
)
|
||||
# done for supporting 'parallel_request_limiter.py' with pass-through endpoints
|
||||
logging_obj.update_environment_variables(
|
||||
|
@ -572,6 +573,7 @@ async def pass_through_request( # noqa: PLR0915
|
|||
|
||||
|
||||
def _init_kwargs_for_pass_through_endpoint(
|
||||
request: Request,
|
||||
user_api_key_dict: UserAPIKeyAuth,
|
||||
passthrough_logging_payload: PassthroughStandardLoggingPayload,
|
||||
_parsed_body: Optional[dict] = None,
|
||||
|
@ -587,6 +589,12 @@ def _init_kwargs_for_pass_through_endpoint(
|
|||
}
|
||||
if _litellm_metadata:
|
||||
_metadata.update(_litellm_metadata)
|
||||
|
||||
_metadata = _update_metadata_with_tags_in_header(
|
||||
request=request,
|
||||
metadata=_metadata,
|
||||
)
|
||||
|
||||
kwargs = {
|
||||
"litellm_params": {
|
||||
"metadata": _metadata,
|
||||
|
@ -598,6 +606,13 @@ def _init_kwargs_for_pass_through_endpoint(
|
|||
return kwargs
|
||||
|
||||
|
||||
def _update_metadata_with_tags_in_header(request: Request, metadata: dict) -> dict:
|
||||
_tags = request.headers.get("tags")
|
||||
if _tags:
|
||||
metadata["tags"] = _tags.split(",")
|
||||
return metadata
|
||||
|
||||
|
||||
def create_pass_through_route(
|
||||
endpoint,
|
||||
target: str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue