mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
transform_response_api_response
This commit is contained in:
parent
9deb8831b6
commit
cb2b49f7a3
2 changed files with 28 additions and 3 deletions
|
@ -103,10 +103,9 @@ class BaseResponsesAPIConfig(ABC):
|
||||||
self,
|
self,
|
||||||
model: str,
|
model: str,
|
||||||
raw_response: httpx.Response,
|
raw_response: httpx.Response,
|
||||||
model_response: ResponsesAPIResponse,
|
|
||||||
logging_obj: LiteLLMLoggingObj,
|
logging_obj: LiteLLMLoggingObj,
|
||||||
) -> ResponsesAPIResponse:
|
) -> ResponsesAPIResponse:
|
||||||
return model_response
|
pass
|
||||||
|
|
||||||
def get_error_class(
|
def get_error_class(
|
||||||
self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers]
|
self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Optional, Union
|
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
import litellm
|
import litellm
|
||||||
from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig
|
from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig
|
||||||
|
@ -7,9 +9,19 @@ from litellm.types.llms.openai import (
|
||||||
ResponseInputParam,
|
ResponseInputParam,
|
||||||
ResponsesAPIOptionalRequestParams,
|
ResponsesAPIOptionalRequestParams,
|
||||||
ResponsesAPIRequestParams,
|
ResponsesAPIRequestParams,
|
||||||
|
ResponsesAPIResponse,
|
||||||
)
|
)
|
||||||
from litellm.types.router import GenericLiteLLMParams
|
from litellm.types.router import GenericLiteLLMParams
|
||||||
|
|
||||||
|
from ..common_utils import OpenAIError
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj
|
||||||
|
|
||||||
|
LiteLLMLoggingObj = _LiteLLMLoggingObj
|
||||||
|
else:
|
||||||
|
LiteLLMLoggingObj = Any
|
||||||
|
|
||||||
|
|
||||||
class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
||||||
def get_supported_openai_params(self, model: str) -> list:
|
def get_supported_openai_params(self, model: str) -> list:
|
||||||
|
@ -83,6 +95,20 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
||||||
model=model, input=input, **response_api_optional_request_params
|
model=model, input=input, **response_api_optional_request_params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def transform_response_api_response(
|
||||||
|
self,
|
||||||
|
model: str,
|
||||||
|
raw_response: httpx.Response,
|
||||||
|
logging_obj: LiteLLMLoggingObj,
|
||||||
|
) -> ResponsesAPIResponse:
|
||||||
|
try:
|
||||||
|
raw_response_json = raw_response.json()
|
||||||
|
except Exception:
|
||||||
|
raise OpenAIError(
|
||||||
|
message=raw_response.text, status_code=raw_response.status_code
|
||||||
|
)
|
||||||
|
return ResponsesAPIResponse(**raw_response_json)
|
||||||
|
|
||||||
def validate_environment(
|
def validate_environment(
|
||||||
self,
|
self,
|
||||||
headers: dict,
|
headers: dict,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue