mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(fireworks_ai): map the Fireworks delete response body to DeleteResponseResult
This commit is contained in:
parent
4b950cd94f
commit
217b5c404c
2 changed files with 30 additions and 1 deletions
|
|
@ -1,6 +1,9 @@
|
|||
from collections.abc import Mapping
|
||||
from types import MappingProxyType
|
||||
from typing import Final
|
||||
from typing import TYPE_CHECKING, Final
|
||||
from urllib.parse import unquote
|
||||
|
||||
import httpx
|
||||
|
||||
from litellm.llms.fireworks_ai.common_utils import (
|
||||
resolve_fireworks_api_key,
|
||||
|
|
@ -10,9 +13,13 @@ from litellm.llms.fireworks_ai.common_utils import (
|
|||
from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig
|
||||
from litellm.secret_managers.main import get_secret_str
|
||||
from litellm.types.llms.openai import ResponseInputParam
|
||||
from litellm.types.responses.main import DeleteResponseResult
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
from litellm.types.utils import LlmProviders
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
|
||||
|
||||
FIREWORKS_AI_DEFAULT_API_BASE: Final = "https://api.fireworks.ai/inference/v1"
|
||||
|
||||
|
||||
|
|
@ -64,5 +71,13 @@ class FireworksAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
headers=headers,
|
||||
)
|
||||
|
||||
def transform_delete_response_api_response(
|
||||
self,
|
||||
raw_response: httpx.Response,
|
||||
logging_obj: "LiteLLMLoggingObj",
|
||||
) -> DeleteResponseResult:
|
||||
deleted_id: Final = unquote(raw_response.request.url.path.rsplit("/", 1)[-1])
|
||||
return DeleteResponseResult(id=deleted_id, object="response", deleted=True)
|
||||
|
||||
def supports_native_websocket(self) -> bool:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from collections.abc import Mapping
|
|||
from types import MappingProxyType
|
||||
from typing import Final, TypedDict
|
||||
from unittest.mock import MagicMock, patch
|
||||
from urllib.parse import quote
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
|
@ -261,3 +262,16 @@ def test_validate_environment_without_any_key_raises() -> None:
|
|||
FireworksAIResponsesAPIConfig().validate_environment(
|
||||
headers=NO_HEADERS, model="accounts/fireworks/models/kimi-k3", litellm_params=None
|
||||
)
|
||||
|
||||
|
||||
def test_delete_responses_maps_fireworks_message_only_body_to_deleted_result() -> None:
|
||||
response_id: Final = "resp_xFaIJR9Nc_OXmqKRqL78UuAGj2Te5GY5BT_knpZiMrYoNOVmu5oc2mQW1HI7hCtEYB4mcx2lEYS0DYP1U5yEQskHunuB4=="
|
||||
request: Final = httpx.Request("DELETE", f"{FIREWORKS_RESPONSES_URL}/{quote(response_id, safe='')}")
|
||||
client: Final = MagicMock()
|
||||
client.delete.return_value = httpx.Response(200, json={"message": "Response deleted successfully"}, request=request)
|
||||
with patch(HTTPX_CLIENT_FACTORY, return_value=client):
|
||||
result: Final = litellm.delete_responses(
|
||||
response_id=response_id, custom_llm_provider="fireworks_ai", api_key="fw-test-key"
|
||||
)
|
||||
assert client.delete.call_args.kwargs["url"] == str(request.url)
|
||||
assert (result.id, result.object, result.deleted) == (response_id, "response", True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue