mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
add transform_delete_response_api_request
This commit is contained in:
parent
45c299d27f
commit
988ae4feca
1 changed files with 37 additions and 5 deletions
|
@ -7,6 +7,7 @@ from litellm._logging import verbose_logger
|
||||||
from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig
|
from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig
|
||||||
from litellm.secret_managers.main import get_secret_str
|
from litellm.secret_managers.main import get_secret_str
|
||||||
from litellm.types.llms.openai import *
|
from litellm.types.llms.openai import *
|
||||||
|
from litellm.types.responses.main import *
|
||||||
from litellm.types.router import GenericLiteLLMParams
|
from litellm.types.router import GenericLiteLLMParams
|
||||||
|
|
||||||
from ..common_utils import OpenAIError
|
from ..common_utils import OpenAIError
|
||||||
|
@ -110,11 +111,6 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
||||||
def get_complete_url(
|
def get_complete_url(
|
||||||
self,
|
self,
|
||||||
api_base: Optional[str],
|
api_base: Optional[str],
|
||||||
api_key: Optional[str],
|
|
||||||
model: str,
|
|
||||||
optional_params: dict,
|
|
||||||
litellm_params: dict,
|
|
||||||
stream: Optional[bool] = None,
|
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Get the endpoint for OpenAI responses API
|
Get the endpoint for OpenAI responses API
|
||||||
|
@ -217,3 +213,39 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
||||||
f"Error getting model info in OpenAIResponsesAPIConfig: {e}"
|
f"Error getting model info in OpenAIResponsesAPIConfig: {e}"
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
#########################################################
|
||||||
|
########## DELETE RESPONSE API TRANSFORMATION ##############
|
||||||
|
#########################################################
|
||||||
|
def transform_delete_response_api_request(
|
||||||
|
self,
|
||||||
|
response_id: str,
|
||||||
|
api_base: str,
|
||||||
|
litellm_params: GenericLiteLLMParams,
|
||||||
|
headers: dict,
|
||||||
|
) -> Tuple[str, Dict]:
|
||||||
|
"""
|
||||||
|
Transform the delete response API request into a URL and data
|
||||||
|
|
||||||
|
OpenAI API expects the following request
|
||||||
|
- DELETE /v1/responses/{response_id}
|
||||||
|
"""
|
||||||
|
url = f"{api_base}/responses/{response_id}"
|
||||||
|
data = {}
|
||||||
|
return url, data
|
||||||
|
|
||||||
|
def transform_delete_response_api_response(
|
||||||
|
self,
|
||||||
|
raw_response: httpx.Response,
|
||||||
|
logging_obj: LiteLLMLoggingObj,
|
||||||
|
) -> DeleteResponseResult:
|
||||||
|
"""
|
||||||
|
Transform the delete response API response into a DeleteResponseResult
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
raw_response_json = raw_response.json()
|
||||||
|
except Exception:
|
||||||
|
raise OpenAIError(
|
||||||
|
message=raw_response.text, status_code=raw_response.status_code
|
||||||
|
)
|
||||||
|
return DeleteResponseResult(**raw_response_json)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue