mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
style(vertex_httpx.py): make vertex error string more helpful
This commit is contained in:
parent
671663abe6
commit
db54b66457
3 changed files with 56 additions and 5 deletions
|
@ -384,8 +384,16 @@ async def pass_through_request(
|
|||
params=requested_query_params,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
response = await async_client.send(req, stream=stream)
|
||||
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as e:
|
||||
raise HTTPException(
|
||||
status_code=e.response.status_code, detail=await e.response.aread()
|
||||
)
|
||||
|
||||
# Create an async generator to yield the response content
|
||||
async def stream_response() -> AsyncIterable[bytes]:
|
||||
async for chunk in response.aiter_bytes():
|
||||
|
@ -409,6 +417,13 @@ async def pass_through_request(
|
|||
response.headers.get("content-type") is not None
|
||||
and response.headers["content-type"] == "text/event-stream"
|
||||
):
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as e:
|
||||
raise HTTPException(
|
||||
status_code=e.response.status_code, detail=await e.response.aread()
|
||||
)
|
||||
|
||||
# streaming response
|
||||
# Create an async generator to yield the response content
|
||||
async def stream_response() -> AsyncIterable[bytes]:
|
||||
|
@ -421,6 +436,13 @@ async def pass_through_request(
|
|||
status_code=response.status_code,
|
||||
)
|
||||
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as e:
|
||||
raise HTTPException(
|
||||
status_code=e.response.status_code, detail=e.response.text
|
||||
)
|
||||
|
||||
if response.status_code >= 300:
|
||||
raise HTTPException(status_code=response.status_code, detail=response.text)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue