mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
Merge pull request #4480 from BerriAI/litellm_fix_image_gen_issue
[Fix] DALL-E connection error bug on litellm proxy
This commit is contained in:
commit
c6fda7fb7e
2 changed files with 31 additions and 21 deletions
|
|
@ -1,4 +1,8 @@
|
|||
import time, json, httpx, asyncio
|
||||
import asyncio
|
||||
import json
|
||||
import time
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
class AsyncCustomHTTPTransport(httpx.AsyncHTTPTransport):
|
||||
|
|
@ -7,15 +11,18 @@ class AsyncCustomHTTPTransport(httpx.AsyncHTTPTransport):
|
|||
"""
|
||||
|
||||
async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
|
||||
if "images/generations" in request.url.path and request.url.params[
|
||||
"api-version"
|
||||
] in [ # dall-e-3 starts from `2023-12-01-preview` so we should be able to avoid conflict
|
||||
"2023-06-01-preview",
|
||||
"2023-07-01-preview",
|
||||
"2023-08-01-preview",
|
||||
"2023-09-01-preview",
|
||||
"2023-10-01-preview",
|
||||
]:
|
||||
_api_version = request.url.params.get("api-version", "")
|
||||
if (
|
||||
"images/generations" in request.url.path
|
||||
and _api_version
|
||||
in [ # dall-e-3 starts from `2023-12-01-preview` so we should be able to avoid conflict
|
||||
"2023-06-01-preview",
|
||||
"2023-07-01-preview",
|
||||
"2023-08-01-preview",
|
||||
"2023-09-01-preview",
|
||||
"2023-10-01-preview",
|
||||
]
|
||||
):
|
||||
request.url = request.url.copy_with(
|
||||
path="/openai/images/generations:submit"
|
||||
)
|
||||
|
|
@ -77,15 +84,18 @@ class CustomHTTPTransport(httpx.HTTPTransport):
|
|||
self,
|
||||
request: httpx.Request,
|
||||
) -> httpx.Response:
|
||||
if "images/generations" in request.url.path and request.url.params[
|
||||
"api-version"
|
||||
] in [ # dall-e-3 starts from `2023-12-01-preview` so we should be able to avoid conflict
|
||||
"2023-06-01-preview",
|
||||
"2023-07-01-preview",
|
||||
"2023-08-01-preview",
|
||||
"2023-09-01-preview",
|
||||
"2023-10-01-preview",
|
||||
]:
|
||||
_api_version = request.url.params.get("api-version", "")
|
||||
if (
|
||||
"images/generations" in request.url.path
|
||||
and _api_version
|
||||
in [ # dall-e-3 starts from `2023-12-01-preview` so we should be able to avoid conflict
|
||||
"2023-06-01-preview",
|
||||
"2023-07-01-preview",
|
||||
"2023-08-01-preview",
|
||||
"2023-09-01-preview",
|
||||
"2023-10-01-preview",
|
||||
]
|
||||
):
|
||||
request.url = request.url.copy_with(
|
||||
path="/openai/images/generations:submit"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1081,7 +1081,7 @@ async def test_aimg_gen_on_router():
|
|||
{
|
||||
"model_name": "dall-e-3",
|
||||
"litellm_params": {
|
||||
"model": "dall-e-3",
|
||||
"model": "openai/dall-e-3",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -1137,7 +1137,7 @@ def test_img_gen_on_router():
|
|||
try:
|
||||
model_list = [
|
||||
{
|
||||
"model_name": "dall-e-3",
|
||||
"model_name": "openai/dall-e-3",
|
||||
"litellm_params": {
|
||||
"model": "dall-e-3",
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue