From c7ceeaa4d70cd27a7d98dce79546996c8a0529bd Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 12 Mar 2025 12:00:05 -0700 Subject: [PATCH] fix(pass_through_endpoints.py): fix linting error --- .../pass_through_endpoints/pass_through_endpoints.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 5e2080db0c..546fc01e0c 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -3,8 +3,8 @@ import asyncio import json from base64 import b64encode from datetime import datetime -from typing import List, Optional, Union, Dict -from urllib.parse import urlencode, parse_qs, urlparse +from typing import Dict, List, Optional, Union +from urllib.parse import parse_qs, urlencode, urlparse import httpx from fastapi import APIRouter, Depends, HTTPException, Request, Response, status @@ -260,6 +260,7 @@ async def chat_completion_pass_through_endpoint( # noqa: PLR0915 code=getattr(e, "status_code", 500), ) + class HttpPassThroughEndpointHelpers: @staticmethod def forward_headers_from_request( @@ -315,11 +316,11 @@ class HttpPassThroughEndpointHelpers: existing_query_params = parse_qs(existing_query_string) # parse_qs returns a dict where each value is a list, so let's flatten it - existing_query_params = { + updated_existing_query_params = { k: v[0] if len(v) == 1 else v for k, v in existing_query_params.items() } # Merge the query params, giving priority to the existing ones - return {**request_query_params, **existing_query_params} + return {**request_query_params, **updated_existing_query_params} @staticmethod async def _make_non_streaming_http_request( @@ -352,6 +353,7 @@ class HttpPassThroughEndpointHelpers: ) return response + async def pass_through_request( # noqa: PLR0915 request: Request, target: str,