forked from phoenix/litellm-mirror
fix(pass_through_endpoints.py): fix returned response headers for pass-through endpoitns
This commit is contained in:
parent
08411f37b4
commit
b56ecd7e02
2 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,4 @@
|
||||||
model_list:
|
model_list:
|
||||||
- model_name: "text-embedding-ada-002"
|
- model_name: "*"
|
||||||
litellm_params:
|
litellm_params:
|
||||||
model: "azure/azure-embedding-model"
|
model: "*"
|
||||||
api_base: os.environ/AZURE_API_BASE
|
|
||||||
api_key: os.environ/AZURE_API_KEY
|
|
|
@ -308,7 +308,6 @@ async def pass_through_request(
|
||||||
)
|
)
|
||||||
|
|
||||||
async_client = httpx.AsyncClient()
|
async_client = httpx.AsyncClient()
|
||||||
|
|
||||||
response = await async_client.request(
|
response = await async_client.request(
|
||||||
method=request.method,
|
method=request.method,
|
||||||
url=url,
|
url=url,
|
||||||
|
@ -362,10 +361,17 @@ async def pass_through_request(
|
||||||
cache_hit=False,
|
cache_hit=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
excluded_headers = {"transfer-encoding", "content-encoding"}
|
||||||
|
headers = {
|
||||||
|
key: value
|
||||||
|
for key, value in response.headers.items()
|
||||||
|
if key.lower() not in excluded_headers
|
||||||
|
}
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
content=content,
|
content=content,
|
||||||
status_code=response.status_code,
|
status_code=response.status_code,
|
||||||
headers=dict(response.headers),
|
headers=headers,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
verbose_proxy_logger.exception(
|
verbose_proxy_logger.exception(
|
||||||
|
@ -423,7 +429,7 @@ def create_pass_through_route(
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
verbose_proxy_logger.warning("Defaulting to target being a url.")
|
verbose_proxy_logger.debug("Defaulting to target being a url.")
|
||||||
|
|
||||||
async def endpoint_func(
|
async def endpoint_func(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue