mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
fix(pass_through_endpoints.py): fix linting error
This commit is contained in:
parent
25718e4a61
commit
0b4bf49553
1 changed files with 6 additions and 4 deletions
|
@ -3,8 +3,8 @@ import asyncio
|
||||||
import json
|
import json
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Optional, Union, Dict
|
from typing import Dict, List, Optional, Union
|
||||||
from urllib.parse import urlencode, parse_qs, urlparse
|
from urllib.parse import parse_qs, urlencode, urlparse
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, Response, status
|
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),
|
code=getattr(e, "status_code", 500),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class HttpPassThroughEndpointHelpers:
|
class HttpPassThroughEndpointHelpers:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def forward_headers_from_request(
|
def forward_headers_from_request(
|
||||||
|
@ -315,11 +316,11 @@ class HttpPassThroughEndpointHelpers:
|
||||||
existing_query_params = parse_qs(existing_query_string)
|
existing_query_params = parse_qs(existing_query_string)
|
||||||
|
|
||||||
# parse_qs returns a dict where each value is a list, so let's flatten it
|
# 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()
|
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
|
# 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
|
@staticmethod
|
||||||
async def _make_non_streaming_http_request(
|
async def _make_non_streaming_http_request(
|
||||||
|
@ -352,6 +353,7 @@ class HttpPassThroughEndpointHelpers:
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
async def pass_through_request( # noqa: PLR0915
|
async def pass_through_request( # noqa: PLR0915
|
||||||
request: Request,
|
request: Request,
|
||||||
target: str,
|
target: str,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue