From 54da723e88d60c5c1b24694d62fe65b52f4ef38f Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Thu, 27 Aug 2026 17:19:05 +0800 Subject: [PATCH 01/15] feat: add FlowSpeech text-to-speech provider --- litellm/llms/flowspeech/__init__.py | 1 + .../flowspeech/text_to_speech/__init__.py | 1 + .../text_to_speech/transformation.py | 207 ++++++++++++++++++ litellm/main.py | 34 +++ litellm/types/utils.py | 1 + litellm/utils.py | 6 + model_prices_and_context_window.json | 8 + .../test_litellm/llms/flowspeech/__init__.py | 1 + .../test_text_to_speech_transformation.py | 168 ++++++++++++++ 9 files changed, 427 insertions(+) create mode 100644 litellm/llms/flowspeech/__init__.py create mode 100644 litellm/llms/flowspeech/text_to_speech/__init__.py create mode 100644 litellm/llms/flowspeech/text_to_speech/transformation.py create mode 100644 tests/test_litellm/llms/flowspeech/__init__.py create mode 100644 tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py diff --git a/litellm/llms/flowspeech/__init__.py b/litellm/llms/flowspeech/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/litellm/llms/flowspeech/__init__.py @@ -0,0 +1 @@ + diff --git a/litellm/llms/flowspeech/text_to_speech/__init__.py b/litellm/llms/flowspeech/text_to_speech/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/litellm/llms/flowspeech/text_to_speech/__init__.py @@ -0,0 +1 @@ + diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py new file mode 100644 index 00000000000..5d3f9847017 --- /dev/null +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -0,0 +1,207 @@ +import base64 +import binascii +from typing import TYPE_CHECKING, Final + +import httpx +from httpx import Headers +from pydantic import BaseModel + +import litellm +from litellm.llms.base_llm.chat.transformation import BaseLLMException +from litellm.llms.base_llm.text_to_speech.transformation import ( + BaseTextToSpeechConfig, + TextToSpeechRequestData, +) +from litellm.secret_managers.main import get_secret_str + +if TYPE_CHECKING: + from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj + from litellm.types.llms.openai import HttpxBinaryResponseContent + + +class FlowSpeechException(BaseLLMException): + def __init__( + self, + status_code: int, + message: str, + headers: dict[str, str] | Headers | None = None, # mutable-ok: exception contract accepts dict headers + ) -> None: + super().__init__( # pyright: ignore[reportUnknownMemberType] # upstream exception keeps untyped dict fields + status_code=status_code, + message=message, + headers=headers, + ) + + +class FlowSpeechAudioData(BaseModel): + mimeType: str + audioBase64: str + + +class FlowSpeechResponse(BaseModel): + code: int + message: str | None = None + data: FlowSpeechAudioData | None = None + + +class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): + TTS_BASE_URL = "https://flowspeech.io" + TTS_ENDPOINT_PATH = "/api/ai/text-to-speech" + DEFAULT_VOICE = "Kore" + + def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base provider interface returns list + return ["voice", "instructions"] # mutable-ok: base provider interface returns list + + def map_openai_params( + self, + model: str, + optional_params: dict[str, object], # mutable-ok: base provider interface requires dict + voice: str | dict[str, object] | None = None, # mutable-ok: base provider interface accepts dict voices + drop_params: bool = False, + kwargs: dict[str, object] | None = None, # mutable-ok: base provider interface requires dict + ) -> tuple[str | None, dict[str, object]]: # mutable-ok: base provider interface returns dict params + params: Final[dict[str, object]] = ( # mutable-ok: isolated request copy + dict(optional_params) if optional_params else {} # mutable-ok: isolated request copy + ) + mapped_voice: Final = self._resolve_voice(voice) + instructions: Final = params.get("instructions") + mapped_params: Final[dict[str, object]] = ( # mutable-ok: base provider interface returns dict params + {"prompt": instructions} # mutable-ok: base provider interface returns dict params + if isinstance(instructions, str) and instructions.strip() + else {} # mutable-ok: base provider interface returns dict params + ) + return mapped_voice, mapped_params + + def _resolve_voice( + self, + voice: str | dict[str, object] | None, # mutable-ok: base provider interface accepts dict voices + ) -> str: + if isinstance(voice, str) and voice.strip(): + return voice.strip() + if isinstance(voice, dict): + candidate: Final = next( + ( + value + for key in ("voice_name", "voiceName", "id", "name") + if isinstance((value := voice.get(key)), str) and value.strip() + ), + None, + ) + if isinstance(candidate, str): + return candidate.strip() + return self.DEFAULT_VOICE + + def validate_environment( + self, + headers: dict[str, str], # mutable-ok: base provider interface requires dict headers + model: str, + api_key: str | None = None, + api_base: str | None = None, + ) -> dict[str, str]: # mutable-ok: base provider interface returns dict headers + resolved_api_key: Final = api_key or litellm.api_key or get_secret_str("FLOWSPEECH_API_KEY") + if resolved_api_key is None: + raise ValueError("FlowSpeech API key is required. Set FLOWSPEECH_API_KEY environment variable.") + return { # mutable-ok: base provider interface returns dict headers + **headers, + "Authorization": f"Bearer {resolved_api_key}", + "Content-Type": "application/json", + } + + def get_error_class( + self, + error_message: str, + status_code: int, + headers: dict[str, str] | Headers, # mutable-ok: exception contract accepts dict headers + ) -> BaseLLMException: + return FlowSpeechException(message=error_message, status_code=status_code, headers=headers) + + def transform_text_to_speech_request( + self, + model: str, + input: str, + voice: str | None, + optional_params: dict[str, object], # mutable-ok: base provider interface requires dict + litellm_params: dict[str, object], # mutable-ok: base provider interface requires dict + headers: dict[str, str], # mutable-ok: base provider interface requires dict + ) -> TextToSpeechRequestData: + prompt: Final = optional_params.get("prompt") + prompt_data: Final[dict[str, str]] = ( # mutable-ok: JSON request body requires a dict + {"prompt": prompt} # mutable-ok: JSON request body requires a dict + if isinstance(prompt, str) and prompt.strip() + else {} # mutable-ok: JSON request body requires a dict + ) + request_body: Final[dict[str, object]] = { # mutable-ok: JSON request body requires a dict + "text": input, + "originalText": input, + "speakers": [ # mutable-ok: FlowSpeech JSON schema requires a speakers array + {"voiceName": voice or self.DEFAULT_VOICE} # mutable-ok: FlowSpeech JSON schema requires an object + ], + **prompt_data, + } + return TextToSpeechRequestData( + dict_body=request_body, + headers={"Content-Type": "application/json"}, # mutable-ok: base request type requires dict headers + ) + + def transform_text_to_speech_response( + self, + model: str, + raw_response: httpx.Response, + logging_obj: "LiteLLMLoggingObj", + ) -> "HttpxBinaryResponseContent": + from litellm.types.llms.openai import HttpxBinaryResponseContent + + try: + payload: Final = FlowSpeechResponse.model_validate(raw_response.json()) + except ValueError as exc: + raise FlowSpeechException( + status_code=raw_response.status_code, + message="FlowSpeech API returned an invalid JSON response", + headers=raw_response.headers, + ) from exc + + if payload.code != 0 or payload.data is None or not payload.data.audioBase64: + raise FlowSpeechException( + status_code=raw_response.status_code, + message=payload.message or "FlowSpeech API response did not include audio data", + headers=raw_response.headers, + ) + + try: + audio_bytes: Final = base64.b64decode(payload.data.audioBase64, validate=True) + except (binascii.Error, ValueError) as exc: + raise FlowSpeechException( + status_code=raw_response.status_code, + message="FlowSpeech API returned invalid base64 audio data", + headers=raw_response.headers, + ) from exc + + preserved_headers: Final = { # mutable-ok: httpx.Response requires materialized headers + key: value + for key, value in raw_response.headers.items() + if key.lower() not in frozenset({"content-encoding", "content-length", "content-type", "transfer-encoding"}) + } + response_headers: Final = { # mutable-ok: httpx.Response requires materialized headers + **preserved_headers, + "content-length": str(len(audio_bytes)), + "content-type": payload.data.mimeType, + } + binary_response: Final = httpx.Response( + status_code=200, + headers=response_headers, + content=audio_bytes, + request=raw_response.request, + ) + return HttpxBinaryResponseContent(binary_response) + + def get_complete_url( + self, + model: str, + api_base: str | None, + litellm_params: dict[str, object], # mutable-ok: base provider interface requires dict + ) -> str: + base_url: Final = api_base or get_secret_str("FLOWSPEECH_API_BASE") or self.TTS_BASE_URL + normalized_base_url: Final = base_url.rstrip("/") + if normalized_base_url.endswith(self.TTS_ENDPOINT_PATH): + return normalized_base_url + return f"{normalized_base_url}{self.TTS_ENDPOINT_PATH}" diff --git a/litellm/main.py b/litellm/main.py index 8ee102f5d07..e9c1b9fa281 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -8225,6 +8225,40 @@ def speech( client=client, _is_async=aspeech or False, ) + elif custom_llm_provider == "flowspeech": + from litellm.llms.flowspeech.text_to_speech.transformation import ( + FlowSpeechTextToSpeechConfig, + ) + + if text_to_speech_provider_config is None: + text_to_speech_provider_config = ( # rebind-ok: provider config is resolved lazily for speech dispatch + FlowSpeechTextToSpeechConfig() + ) + + if not isinstance(text_to_speech_provider_config, FlowSpeechTextToSpeechConfig): + raise TypeError("FlowSpeech TTS configuration has an unexpected type") + flowspeech_config: Final = text_to_speech_provider_config + + if api_base is not None: + litellm_params_dict["api_base"] = api_base + if api_key is not None: + litellm_params_dict["api_key"] = api_key + + voice_name: Final = voice if isinstance(voice, str) else None + response = base_llm_http_handler.text_to_speech_handler( # rebind-ok: provider branch sets dispatch result + model=model, + input=input, + voice=voice_name, + text_to_speech_provider_config=flowspeech_config, + text_to_speech_optional_params=optional_params, + custom_llm_provider=custom_llm_provider, + litellm_params=litellm_params_dict, + logging_obj=logging_obj, + timeout=timeout, + extra_headers=extra_headers, + client=client, + _is_async=aspeech or False, + ) elif custom_llm_provider == "vertex_ai" or custom_llm_provider == "vertex_ai_beta": from litellm.llms.vertex_ai.text_to_speech.transformation import ( VertexAITextToSpeechConfig, diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 58103b84749..092a405a180 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3783,6 +3783,7 @@ class LlmProviders(str, Enum): INFINITY = "infinity" DEEPGRAM = "deepgram" ELEVENLABS = "elevenlabs" + FLOWSPEECH = "flowspeech" NOVITA = "novita" AIOHTTP_OPENAI = "aiohttp_openai" LANGFUSE = "langfuse" diff --git a/litellm/utils.py b/litellm/utils.py index 54f97ccae54..85da141dab1 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -9309,6 +9309,12 @@ class ProviderConfigManager: ) return ElevenLabsTextToSpeechConfig() + elif litellm.LlmProviders.FLOWSPEECH == provider: + from litellm.llms.flowspeech.text_to_speech.transformation import ( + FlowSpeechTextToSpeechConfig, + ) + + return FlowSpeechTextToSpeechConfig() elif litellm.LlmProviders.RUNWAYML == provider: from litellm.llms.runwayml.text_to_speech.transformation import ( RunwayMLTextToSpeechConfig, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index dd367e875de..8a543eddcd4 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -17298,6 +17298,14 @@ "/v1/audio/transcriptions" ] }, + "flowspeech/flowspeech-tts": { + "litellm_provider": "flowspeech", + "mode": "audio_speech", + "source": "https://flowspeech.io/", + "supported_endpoints": [ + "/v1/audio/speech" + ] + }, "elevenlabs/eleven_v3": { "input_cost_per_character": 0.00018, "litellm_provider": "elevenlabs", diff --git a/tests/test_litellm/llms/flowspeech/__init__.py b/tests/test_litellm/llms/flowspeech/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/test_litellm/llms/flowspeech/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py b/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py new file mode 100644 index 00000000000..903495a19d4 --- /dev/null +++ b/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py @@ -0,0 +1,168 @@ +import base64 +import json + +import httpx +import pytest + +import litellm +from litellm.llms.custom_httpx.http_handler import HTTPHandler +from litellm.llms.flowspeech.text_to_speech.transformation import ( + FlowSpeechException, + FlowSpeechTextToSpeechConfig, +) + + +def test_maps_voice_and_instructions_to_flowspeech_request(): + config = FlowSpeechTextToSpeechConfig() + voice, params = config.map_openai_params( + model="flowspeech-tts", + optional_params={"instructions": "Speak with calm confidence"}, + voice={"voiceName": "Aoede"}, + ) + + request = config.transform_text_to_speech_request( + model="flowspeech-tts", + input="Hello from FlowSpeech", + voice=voice, + optional_params=params, + litellm_params={}, + headers={}, + ) + + assert request["dict_body"] == { + "text": "Hello from FlowSpeech", + "originalText": "Hello from FlowSpeech", + "speakers": [{"voiceName": "Aoede"}], + "prompt": "Speak with calm confidence", + } + + +def test_uses_default_voice_and_ignores_unsupported_openai_params(): + config = FlowSpeechTextToSpeechConfig() + voice, params = config.map_openai_params( + model="flowspeech-tts", + optional_params={"response_format": "mp3", "speed": 1.5}, + ) + + assert voice == "Kore" + assert params == {} + + +def test_validates_bearer_api_key(): + config = FlowSpeechTextToSpeechConfig() + + headers = config.validate_environment({}, "flowspeech-tts", api_key="test-key") + + assert headers == { + "Authorization": "Bearer test-key", + "Content-Type": "application/json", + } + + +def test_requires_api_key(monkeypatch): + config = FlowSpeechTextToSpeechConfig() + monkeypatch.setattr(litellm, "api_key", None) + monkeypatch.delenv("FLOWSPEECH_API_KEY", raising=False) + + with pytest.raises(ValueError, match="FlowSpeech API key is required"): + config.validate_environment({}, "flowspeech-tts") + + +def test_decodes_flowspeech_audio_response(): + config = FlowSpeechTextToSpeechConfig() + audio = b"test audio bytes" + response = httpx.Response( + 200, + headers={"content-type": "application/json", "x-request-id": "request-1"}, + json={ + "code": 0, + "data": { + "mimeType": "audio/mpeg", + "audioBase64": base64.b64encode(audio).decode(), + }, + }, + request=httpx.Request("POST", "https://flowspeech.io/api/ai/text-to-speech"), + ) + + result = config.transform_text_to_speech_response("flowspeech-tts", response, logging_obj=None) + + assert result.content == audio + assert result.response.headers["content-type"] == "audio/mpeg" + assert result.response.headers["x-request-id"] == "request-1" + + +def test_rejects_api_error_response(): + config = FlowSpeechTextToSpeechConfig() + response = httpx.Response( + 400, + json={"code": 4001, "message": "Quota exceeded", "data": None}, + request=httpx.Request("POST", "https://flowspeech.io/api/ai/text-to-speech"), + ) + + with pytest.raises(FlowSpeechException, match="Quota exceeded"): + config.transform_text_to_speech_response("flowspeech-tts", response, logging_obj=None) + + +def test_builds_default_and_custom_urls(): + config = FlowSpeechTextToSpeechConfig() + + assert config.get_complete_url("flowspeech-tts", None, {}) == "https://flowspeech.io/api/ai/text-to-speech" + assert ( + config.get_complete_url( + "flowspeech-tts", + "https://example.com/api/ai/text-to-speech", + {}, + ) + == "https://example.com/api/ai/text-to-speech" + ) + + +def test_registers_flowspeech_provider_and_config(): + from litellm.utils import ProviderConfigManager + + model, provider, _, _ = litellm.get_llm_provider("flowspeech/flowspeech-tts") + config = ProviderConfigManager.get_provider_text_to_speech_config( + model=model, + provider=litellm.LlmProviders.FLOWSPEECH, + ) + + assert model == "flowspeech-tts" + assert provider == "flowspeech" + assert isinstance(config, FlowSpeechTextToSpeechConfig) + + +def test_speech_dispatches_to_flowspeech_handler(): + audio = b"generated audio" + + def respond(request: httpx.Request) -> httpx.Response: + assert request.url == "https://flowspeech.io/api/ai/text-to-speech" + assert request.headers["authorization"] == "Bearer test-key" + assert json.loads(request.content) == { + "text": "Hello", + "originalText": "Hello", + "speakers": [{"voiceName": "Aoede"}], + "prompt": "Speak warmly", + } + return httpx.Response( + 200, + json={ + "code": 0, + "data": { + "mimeType": "audio/mpeg", + "audioBase64": base64.b64encode(audio).decode(), + }, + }, + ) + + client = HTTPHandler(client=httpx.Client(transport=httpx.MockTransport(respond))) + result = litellm.speech( + model="flowspeech/flowspeech-tts", + input="Hello", + voice="Aoede", + instructions="Speak warmly", + api_key="test-key", + client=client, + ) + + assert result.content == audio + assert result.response.headers["content-type"] == "audio/mpeg" From 18679e182e3d33df71a8ab4447c7f060cdc4a905 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch <267864308+waeckerlinfederowicz66-sketch@users.noreply.github.com> Date: Mon, 14 Sep 2026 12:14:02 +0800 Subject: [PATCH 02/15] fix: register FlowSpeech speech endpoint support --- provider_endpoints_support.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 1d8d374c2c4..2bf1b2ec4a9 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -883,6 +883,24 @@ "interactions": true } }, + "flowspeech": { + "display_name": "FlowSpeech (`flowspeech`)", + "url": "https://docs.litellm.ai/docs/providers/flowspeech", + "endpoints": { + "chat_completions": false, + "messages": false, + "responses": false, + "embeddings": false, + "image_generations": false, + "audio_transcriptions": false, + "audio_speech": true, + "moderations": false, + "batches": false, + "rerank": false, + "a2a": false, + "interactions": false + } + }, "exa_ai": { "display_name": "Exa AI (`exa_ai`)", "url": "https://docs.litellm.ai/docs/search/exa_ai", From f0f286341155be71cd7ea9e5d5b66b1157f14520 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch <267864308+waeckerlinfederowicz66-sketch@users.noreply.github.com> Date: Mon, 14 Sep 2026 12:18:00 +0800 Subject: [PATCH 03/15] fix: stop advertising unsupported speech instructions --- .../text_to_speech/transformation.py | 20 ++----------------- .../test_text_to_speech_transformation.py | 6 ++---- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py index 5d3f9847017..784f40cf4df 100644 --- a/litellm/llms/flowspeech/text_to_speech/transformation.py +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -50,7 +50,7 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): DEFAULT_VOICE = "Kore" def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base provider interface returns list - return ["voice", "instructions"] # mutable-ok: base provider interface returns list + return ["voice"] # mutable-ok: base provider interface returns list def map_openai_params( self, @@ -60,17 +60,8 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): drop_params: bool = False, kwargs: dict[str, object] | None = None, # mutable-ok: base provider interface requires dict ) -> tuple[str | None, dict[str, object]]: # mutable-ok: base provider interface returns dict params - params: Final[dict[str, object]] = ( # mutable-ok: isolated request copy - dict(optional_params) if optional_params else {} # mutable-ok: isolated request copy - ) mapped_voice: Final = self._resolve_voice(voice) - instructions: Final = params.get("instructions") - mapped_params: Final[dict[str, object]] = ( # mutable-ok: base provider interface returns dict params - {"prompt": instructions} # mutable-ok: base provider interface returns dict params - if isinstance(instructions, str) and instructions.strip() - else {} # mutable-ok: base provider interface returns dict params - ) - return mapped_voice, mapped_params + return mapped_voice, {} # mutable-ok: base provider interface returns dict params def _resolve_voice( self, @@ -124,19 +115,12 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): litellm_params: dict[str, object], # mutable-ok: base provider interface requires dict headers: dict[str, str], # mutable-ok: base provider interface requires dict ) -> TextToSpeechRequestData: - prompt: Final = optional_params.get("prompt") - prompt_data: Final[dict[str, str]] = ( # mutable-ok: JSON request body requires a dict - {"prompt": prompt} # mutable-ok: JSON request body requires a dict - if isinstance(prompt, str) and prompt.strip() - else {} # mutable-ok: JSON request body requires a dict - ) request_body: Final[dict[str, object]] = { # mutable-ok: JSON request body requires a dict "text": input, "originalText": input, "speakers": [ # mutable-ok: FlowSpeech JSON schema requires a speakers array {"voiceName": voice or self.DEFAULT_VOICE} # mutable-ok: FlowSpeech JSON schema requires an object ], - **prompt_data, } return TextToSpeechRequestData( dict_body=request_body, diff --git a/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py b/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py index 903495a19d4..6b5653ef99b 100644 --- a/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/test_litellm/llms/flowspeech/test_text_to_speech_transformation.py @@ -12,7 +12,7 @@ from litellm.llms.flowspeech.text_to_speech.transformation import ( ) -def test_maps_voice_and_instructions_to_flowspeech_request(): +def test_maps_voice_without_unsupported_instructions(): config = FlowSpeechTextToSpeechConfig() voice, params = config.map_openai_params( model="flowspeech-tts", @@ -33,8 +33,8 @@ def test_maps_voice_and_instructions_to_flowspeech_request(): "text": "Hello from FlowSpeech", "originalText": "Hello from FlowSpeech", "speakers": [{"voiceName": "Aoede"}], - "prompt": "Speak with calm confidence", } + assert config.get_supported_openai_params("flowspeech-tts") == ["voice"] def test_uses_default_voice_and_ignores_unsupported_openai_params(): @@ -141,7 +141,6 @@ def test_speech_dispatches_to_flowspeech_handler(): "text": "Hello", "originalText": "Hello", "speakers": [{"voiceName": "Aoede"}], - "prompt": "Speak warmly", } return httpx.Response( 200, @@ -159,7 +158,6 @@ def test_speech_dispatches_to_flowspeech_handler(): model="flowspeech/flowspeech-tts", input="Hello", voice="Aoede", - instructions="Speak warmly", api_key="test-key", client=client, ) From 57648104669b85bcd66bcc108ae54770de6d476d Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch <267864308+waeckerlinfederowicz66-sketch@users.noreply.github.com> Date: Mon, 14 Sep 2026 12:23:50 +0800 Subject: [PATCH 04/15] fix: synchronize FlowSpeech fallback model registry --- litellm/model_prices_and_context_window_backup.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index dd367e875de..8a543eddcd4 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -17298,6 +17298,14 @@ "/v1/audio/transcriptions" ] }, + "flowspeech/flowspeech-tts": { + "litellm_provider": "flowspeech", + "mode": "audio_speech", + "source": "https://flowspeech.io/", + "supported_endpoints": [ + "/v1/audio/speech" + ] + }, "elevenlabs/eleven_v3": { "input_cost_per_character": 0.00018, "litellm_provider": "elevenlabs", From 817c76a488e057fcc3eb4466dcda6bd2775662e7 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Mon, 26 Oct 2026 16:21:24 +0800 Subject: [PATCH 05/15] fix(flowspeech): migrate speech provider to public API v1 --- .../llms/flowspeech/text_to_speech/handler.py | 372 +++++++++++++ .../text_to_speech/transformation.py | 293 +++++----- litellm/main.py | 58 +- litellm/proxy/proxy_server.py | 12 + .../llms/flowspeech/test_handler.py | 512 ++++++++++++++++++ .../test_text_to_speech_transformation.py | 349 +++++++----- .../proxy/proxy_server/test_routes_audio.py | 43 ++ 7 files changed, 1378 insertions(+), 261 deletions(-) create mode 100644 litellm/llms/flowspeech/text_to_speech/handler.py create mode 100644 tests/test_litellm/llms/flowspeech/test_handler.py diff --git a/litellm/llms/flowspeech/text_to_speech/handler.py b/litellm/llms/flowspeech/text_to_speech/handler.py new file mode 100644 index 00000000000..20d83c3d493 --- /dev/null +++ b/litellm/llms/flowspeech/text_to_speech/handler.py @@ -0,0 +1,372 @@ +import asyncio +import io +import json +import math +import struct +import time +import wave +from collections.abc import Awaitable, Callable, Generator, Mapping +from datetime import timezone +from email.utils import parsedate_to_datetime +from types import MappingProxyType +from typing import Final, TypeAlias + +import httpx + +from litellm.types.llms.openai import HttpxBinaryResponseContent + +from .transformation import ( + FlowSpeechErrorResponse, + FlowSpeechException, + FlowSpeechJob, + validate_url, + validate_uuid, +) + +Flow: TypeAlias = Generator[ + httpx.Request | float, httpx.Response | httpx.TransportError | None, HttpxBinaryResponseContent +] +Exchange: TypeAlias = Generator[httpx.Request | float, httpx.Response | httpx.TransportError | None, httpx.Response] + + +def validate_wav_structure(content: bytes) -> None: + if ( + len(content) < 12 + or content[:4] != b"RIFF" + or content[8:12] != b"WAVE" + or int.from_bytes(content[4:8], "little") != len(content) - 8 + ): + raise ValueError("Invalid RIFF container length") + stream: Final = io.BytesIO(content) + stream.seek(12) + for header in iter(lambda: stream.read(8), b""): + if len(header) != 8: + raise ValueError("Truncated WAV chunk header") + size = int.from_bytes(header[4:], "little") # rebind-ok: each RIFF chunk declares its own size + end = stream.tell() + size + size % 2 # rebind-ok: boundary belongs to the current chunk + if end > len(content): + raise ValueError("Truncated WAV chunk") + if header[:4] == b"fmt " and stream.read(min(size, 16))[2:] != struct.pack(" None: + seconds: Final = timeout.read if isinstance(timeout, httpx.Timeout) else timeout + if isinstance(seconds, bool) or seconds is None or not math.isfinite(seconds) or seconds <= 0: + raise ValueError("FlowSpeech timeout must be finite and positive (httpx.Timeout uses read as total)") + if isinstance(max_retries, bool) or not isinstance(max_retries, int) or not 0 <= max_retries <= 10: + raise ValueError("FlowSpeech max_retries must be an integer between 0 and 10") + self.url = str(validate_url(url)) + self.headers = httpx.Headers(headers) + self.request_id = validate_uuid(self.headers["Idempotency-Key"]) + self.job_id: str | None = None + serialized: Final = json.dumps( + dict(body), # mutable-ok: JSON encoder requires a concrete dict + ensure_ascii=False, + separators=(",", ":"), + ) + self.body = serialized.encode("utf-8") + if len(self.body) > self.MAX_JSON_BYTES: + raise ValueError("FlowSpeech request exceeds 1 MiB") + self.timeout = timeout + self.deadline = clock() + seconds + self.clock = clock + self.wall_clock = wall_clock + self.sleep = sleep + self.async_sleep = async_sleep + self.max_retries = max_retries + self.on_completed = on_completed + + def error(self, status: int, message: str, headers: httpx.Headers | None = None) -> FlowSpeechException: + return FlowSpeechException( + status, + f"{message} (request_id={self.request_id}, job_id={self.job_id or 'unknown'})", + headers, + ) + + def remaining(self) -> float: + remaining: Final = self.deadline - self.clock() + if remaining <= 0: + raise self.error(408, "FlowSpeech total deadline exceeded; recover using the same request_id") + return remaining + + def delay(self, response: httpx.Response | None = None) -> float: + value: Final = ( + response.headers["retry-after"] if response is not None and "retry-after" in response.headers else None + ) + if not value: + return self.POLL_INTERVAL + try: + seconds: Final = float(value) + except ValueError: + try: + date: Final = parsedate_to_datetime(value) + return max( + self.POLL_INTERVAL, date.replace(tzinfo=date.tzinfo or timezone.utc).timestamp() - self.wall_clock() + ) + except (ValueError, TypeError, OverflowError): + return self.POLL_INTERVAL + return max(self.POLL_INTERVAL, seconds) if math.isfinite(seconds) else self.POLL_INTERVAL + + def wait_budget(self, delay: float) -> None: + if delay >= self.remaining(): + raise self.error(408, "FlowSpeech total deadline cannot accommodate Retry-After/poll delay") + + def request(self, method: str, url: str, download: bool) -> httpx.Request: + remaining: Final = self.remaining() + timeouts: Final[Mapping[str, float | None]] = ( + self.timeout.as_dict() if isinstance(self.timeout, httpx.Timeout) else MappingProxyType({}) + ) + return httpx.Request( + method, + url, + headers=MappingProxyType({"Accept-Encoding": "identity"}) + if download + else MappingProxyType({**self.headers, "Accept-Encoding": "identity"}), + content=self.body if method == "POST" else None, + extensions=MappingProxyType( + { + "timeout": MappingProxyType( + { + phase: min(limit, remaining) if (limit := timeouts.get(phase)) is not None else remaining + for phase in ("connect", "read", "write", "pool") + } + ), + "flowspeech_download": download, + } + ), + ) + + def exchange(self, method: str, url: str, *, download: bool = False) -> Exchange: + for attempt in range(self.max_retries + 1): + response = yield self.request(method, url, download) # rebind-ok: one response per retry + self.remaining() + if isinstance(response, httpx.TransportError): + if attempt == self.max_retries: + raise self.error( + 502, "FlowSpeech download transport failed" if download else "FlowSpeech API transport failed" + ) + yield self.delay() + continue + if not isinstance(response, httpx.Response): + raise self.error(502, "FlowSpeech transport did not return a response") + if response.status_code in ((200,) if download or method == "GET" else (200, 202)): + return response + if response.is_redirect: + raise self.error(502, "FlowSpeech unexpected redirect rejected", response.headers) + try: + payload = FlowSpeechErrorResponse.model_validate_json( + response.content + ) # rebind-ok: parse each retry response + except ValueError: + payload = None # rebind-ok: malformed server errors have no structured payload + retryable = response.status_code == 429 or ( # rebind-ok: evaluated for each retry response + response.status_code >= 500 and (download or (payload is not None and payload.error.retryable)) + ) + if retryable and attempt < self.max_retries: + yield self.delay(response) + continue + detail = ( # rebind-ok: evaluated for each retry response + f"{payload.error.code}: {payload.error.message}; traceId={payload.traceId or 'unknown'}" + if payload + else f"unexpected HTTP {response.status_code}" + ) + raise self.error( + response.status_code if response.status_code >= 400 else 502, + f"FlowSpeech {'download' if download else 'API'}: {detail}", + response.headers, + ) + raise self.error(502, "FlowSpeech retries exhausted") + + def flow(self) -> Flow: + response = yield from self.exchange("POST", self.url) # rebind-ok: advances through job status responses + while True: + try: + job = FlowSpeechJob.model_validate_json(response.content) # rebind-ok: validate each status response + job_id = job.id # rebind-ok: model has normalized each status response's UUID + except ValueError as exc: + raise self.error(502, "FlowSpeech returned an invalid job, ID, status or result") from exc + if job.requestId != self.request_id: + raise self.error(502, "FlowSpeech returned a different request ID") + if self.job_id is not None and self.job_id != job_id: + raise self.error(502, "FlowSpeech returned a different job ID") + self.job_id = job_id + if job.status in ("failed", "cancelled"): + detail = ( + f"{job.error.code}: {job.error.message}" if job.error else job.status + ) # rebind-ok: terminal loop branch + raise self.error(422, f"FlowSpeech job {job.status}: {detail}") + if job.status == "success": + if job.resultDeleted: + raise self.error(410, "FlowSpeech recording was deleted (resultDeleted=true)") + if job.result is None: + raise self.error(502, "FlowSpeech successful job has no result") + try: + audio_url = str(validate_url(job.result.url)) # rebind-ok: terminal loop branch + except ValueError as exc: + raise self.error(502, "FlowSpeech returned an unsafe audio URL") from exc + audio = yield from self.exchange("GET", audio_url, download=True) # rebind-ok: terminal loop branch + return self.completed_response(job, audio) + yield self.delay(response) + response = yield from self.exchange("GET", f"{self.url}/{job_id}") # rebind-ok: advance job polling + + def completed_response(self, job: FlowSpeechJob, response: httpx.Response) -> HttpxBinaryResponseContent: + result: Final = self.audio_response(response) + if self.on_completed is not None: + self.on_completed(job) + return result + + def audio_response(self, response: httpx.Response) -> HttpxBinaryResponseContent: + try: + validate_wav_structure(response.content) + with wave.open(io.BytesIO(response.content), "rb") as audio: + if (audio.getframerate(), audio.getnchannels(), audio.getsampwidth(), audio.getcomptype()) != ( + 24000, + 1, + 2, + "NONE", + ): + raise ValueError("Unexpected WAV encoding") + if audio.getnframes() == 0 or len(audio.readframes(audio.getnframes() + 1)) != audio.getnframes() * 2: + raise ValueError("Empty or truncated WAV") + except (wave.Error, EOFError, ValueError) as exc: + raise self.error(502, "FlowSpeech download is not complete 24 kHz mono 16-bit WAV audio") from exc + return HttpxBinaryResponseContent( + httpx.Response( + 200, + content=response.content, + headers=MappingProxyType( + { + "content-type": "audio/wav", + "x-flowspeech-request-id": self.request_id, + "x-flowspeech-job-id": self.job_id or "", + } + ), + request=response.request, + ) + ) + + def limit(self, request: httpx.Request, response: httpx.Response) -> int: + maximum: Final = self.MAX_AUDIO_BYTES if request.extensions["flowspeech_download"] else self.MAX_JSON_BYTES + if "content-encoding" in response.headers and response.headers["content-encoding"].lower() != "identity": + raise self.error(502, "FlowSpeech encoded response rejected") + try: + length: Final = int(response.headers["content-length"]) if "content-length" in response.headers else 0 + except ValueError as exc: + raise self.error(502, "FlowSpeech invalid Content-Length") from exc + if not 0 <= length <= maximum: + raise self.error(502, "FlowSpeech response exceeds size limit") + return maximum + + def read(self, client: httpx.Client, request: httpx.Request) -> httpx.Response: + response: Final = client.send(request, stream=True, auth=None, follow_redirects=False) + try: + maximum: Final = self.limit(request, response) + with io.BytesIO() as content: + for chunk in response.iter_bytes(): + self.remaining() + if content.tell() + len(chunk) > maximum: + raise self.error(502, "FlowSpeech response exceeds size limit") + content.write(chunk) + self.remaining() + return httpx.Response( + response.status_code, headers=response.headers, content=content.getvalue(), request=request + ) + finally: + response.close() + + async def aread(self, client: httpx.AsyncClient, request: httpx.Request) -> httpx.Response: + response: Final = await client.send(request, stream=True, auth=None, follow_redirects=False) + try: + maximum: Final = self.limit(request, response) + with io.BytesIO() as content: + async for chunk in response.aiter_bytes(): + self.remaining() + if content.tell() + len(chunk) > maximum: + raise self.error(502, "FlowSpeech response exceeds size limit") + content.write(chunk) + self.remaining() + return httpx.Response( + response.status_code, headers=response.headers, content=content.getvalue(), request=request + ) + finally: + await response.aclose() + + def run(self, client: httpx.Client | None = None) -> HttpxBinaryResponseContent: + if client is None: + with httpx.Client(trust_env=False) as owned_client: + return self.run(owned_client) + flow: Final = self.flow() + action = next(flow) # rebind-ok: workflow driver advances actions + try: + while True: + result: httpx.Response | httpx.TransportError | None = None + if not isinstance(action, httpx.Request): + self.wait_budget(action) + self.sleep(action) + else: + try: + result = self.read(client, action) # rebind-ok: result feeds shared workflow + except httpx.TransportError as exc: + result = exc # rebind-ok: retry policy handles transport errors + action = flow.send(result) # rebind-ok: advance shared workflow + except StopIteration as done: + value: Final[object] = done.value # pyright: ignore[reportAny] # StopIteration erases the typed generator return; checked below + if not isinstance(value, HttpxBinaryResponseContent): + raise self.error(502, "FlowSpeech workflow did not return audio") + return value + finally: + flow.close() + + async def arun(self, client: httpx.AsyncClient | None = None) -> HttpxBinaryResponseContent: + if client is None: + async with httpx.AsyncClient(trust_env=False) as owned_client: + return await self.arun(owned_client) + try: + return await asyncio.wait_for(self._arun(client), timeout=self.remaining()) + except asyncio.TimeoutError as exc: + raise self.error(408, "FlowSpeech total deadline exceeded; recover using the same request_id") from exc + + async def _arun(self, client: httpx.AsyncClient) -> HttpxBinaryResponseContent: + flow: Final = self.flow() + action = next(flow) # rebind-ok: workflow driver advances actions + try: + while True: + result: httpx.Response | httpx.TransportError | None = None + if not isinstance(action, httpx.Request): + self.wait_budget(action) + await self.async_sleep(action) + else: + try: + result = await self.aread(client, action) # rebind-ok: result feeds shared workflow + except httpx.TransportError as exc: + result = exc # rebind-ok: retry policy handles transport errors + action = flow.send(result) # rebind-ok: advance shared workflow + except StopIteration as done: + value: Final[object] = done.value # pyright: ignore[reportAny] # StopIteration erases the typed generator return; checked below + if not isinstance(value, HttpxBinaryResponseContent): + raise self.error(502, "FlowSpeech workflow did not return audio") + return value + finally: + flow.close() diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py index 784f40cf4df..a2ebaff40ef 100644 --- a/litellm/llms/flowspeech/text_to_speech/transformation.py +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -1,17 +1,14 @@ -import base64 -import binascii -from typing import TYPE_CHECKING, Final +from collections.abc import Mapping +from types import MappingProxyType +from typing import TYPE_CHECKING, Final, Literal +from uuid import UUID, uuid4 import httpx -from httpx import Headers -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, field_validator import litellm from litellm.llms.base_llm.chat.transformation import BaseLLMException -from litellm.llms.base_llm.text_to_speech.transformation import ( - BaseTextToSpeechConfig, - TextToSpeechRequestData, -) +from litellm.llms.base_llm.text_to_speech.transformation import BaseTextToSpeechConfig, TextToSpeechRequestData from litellm.secret_managers.main import get_secret_str if TYPE_CHECKING: @@ -24,77 +21,146 @@ class FlowSpeechException(BaseLLMException): self, status_code: int, message: str, - headers: dict[str, str] | Headers | None = None, # mutable-ok: exception contract accepts dict headers + headers: dict[str, str] | httpx.Headers | None = None, # mutable-ok: upstream exception interface ) -> None: - super().__init__( # pyright: ignore[reportUnknownMemberType] # upstream exception keeps untyped dict fields - status_code=status_code, - message=message, - headers=headers, + super().__init__( # pyright: ignore[reportUnknownMemberType] # upstream exception has untyped dictionary fields + status_code=status_code, message=message, headers=headers ) -class FlowSpeechAudioData(BaseModel): - mimeType: str - audioBase64: str +class FlowSpeechSegment(BaseModel): + model_config = ConfigDict(extra="forbid", strict=True, frozen=True) + speaker: str = Field(min_length=1, max_length=100) + text: str = Field(min_length=1, max_length=100_000) + voiceName: str = Field(min_length=1, max_length=100) -class FlowSpeechResponse(BaseModel): - code: int - message: str | None = None - data: FlowSpeechAudioData | None = None +class FlowSpeechResult(BaseModel): + model_config = ConfigDict(strict=True, frozen=True) + url: str + mimeType: Literal["audio/wav"] + sampleRate: Literal[24000] + channels: Literal[1] + bitsPerSample: Literal[16] + + +class FlowSpeechError(BaseModel): + model_config = ConfigDict(strict=True, frozen=True) + code: str + message: str + retryable: bool = False + + +class FlowSpeechUsage(BaseModel): + model_config = ConfigDict(strict=True, frozen=True) + billableCharacters: int = Field(ge=0) + reservedCredits: int = Field(ge=0) + chargedCredits: int = Field(ge=0) + + +class FlowSpeechJob(BaseModel): + model_config = ConfigDict(strict=True, frozen=True) + id: str + requestId: str + usage: FlowSpeechUsage + status: Literal["queued", "running", "merging", "settling", "success", "failed", "cancelled"] + result: FlowSpeechResult | None = None + resultDeleted: bool = False + error: FlowSpeechError | None = None + + @field_validator("id", "requestId") + @classmethod + def canonical_identifier(cls, value: str) -> str: + return validate_uuid(value) + + +class FlowSpeechErrorResponse(BaseModel): + model_config = ConfigDict(strict=True, frozen=True) + error: FlowSpeechError + traceId: str | None = None + + +def validate_uuid(value: object) -> str: + text: Final = TypeAdapter(str).validate_python(value, strict=True) + try: + parsed: Final = str(UUID(text)) + except ValueError as exc: + raise ValueError("FlowSpeech requires a UUID") from exc + if parsed != text.lower(): + raise ValueError("FlowSpeech requires a hyphenated UUID") + return parsed + + +def validate_url(value: str) -> httpx.URL: + try: + url: Final = httpx.URL(value) + except httpx.InvalidURL as exc: + raise ValueError("FlowSpeech requires a valid HTTPS URL") from exc + if url.scheme != "https" or not url.host or url.userinfo or url.fragment: + raise ValueError("FlowSpeech requires an HTTPS URL without credentials or fragment") + return url class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): TTS_BASE_URL = "https://flowspeech.io" - TTS_ENDPOINT_PATH = "/api/ai/text-to-speech" + TTS_ENDPOINT_PATH = "/api/v1/tts/jobs" DEFAULT_VOICE = "Kore" - def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base provider interface returns list - return ["voice"] # mutable-ok: base provider interface returns list + def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base provider interface + return ["voice", "response_format"] # mutable-ok: base provider interface def map_openai_params( self, model: str, - optional_params: dict[str, object], # mutable-ok: base provider interface requires dict - voice: str | dict[str, object] | None = None, # mutable-ok: base provider interface accepts dict voices + optional_params: Mapping[str, object], + voice: str | Mapping[str, object] | None = None, drop_params: bool = False, - kwargs: dict[str, object] | None = None, # mutable-ok: base provider interface requires dict - ) -> tuple[str | None, dict[str, object]]: # mutable-ok: base provider interface returns dict params - mapped_voice: Final = self._resolve_voice(voice) - return mapped_voice, {} # mutable-ok: base provider interface returns dict params + kwargs: Mapping[str, object] | None = None, + ) -> tuple[str | None, dict[str, object]]: # mutable-ok: base provider interface + if model != "flowspeech-tts": + raise ValueError("FlowSpeech only supports the flowspeech/flowspeech-tts route") + if any(key != "response_format" for key in optional_params): + raise ValueError("FlowSpeech does not support instructions or speed") + if optional_params.get("response_format") not in (None, "wav"): + raise ValueError("FlowSpeech only supports response_format='wav'") + supplied: Final = kwargs or MappingProxyType({}) + if any( + key in supplied + for key in ("source", "format", "speakers", "originalText", "prompt", "stream", "extra_body") + ): + raise ValueError("Unsupported FlowSpeech option; use voice or segments") + if "segments" in supplied and voice is not None: + raise ValueError("Use segment voiceName fields instead of voice for multi-speaker input") + return self._resolve_voice(voice), { # mutable-ok: base provider interface + key: supplied[key] for key in ("segments", "request_id") if key in supplied + } - def _resolve_voice( - self, - voice: str | dict[str, object] | None, # mutable-ok: base provider interface accepts dict voices - ) -> str: + def _resolve_voice(self, voice: str | Mapping[str, object] | None) -> str: + if voice is None: + return self.DEFAULT_VOICE if isinstance(voice, str) and voice.strip(): return voice.strip() - if isinstance(voice, dict): + if isinstance(voice, Mapping): candidate: Final = next( - ( - value - for key in ("voice_name", "voiceName", "id", "name") - if isinstance((value := voice.get(key)), str) and value.strip() - ), - None, + (voice[key] for key in ("voice_name", "voiceName", "id", "name") if key in voice), None ) - if isinstance(candidate, str): + if isinstance(candidate, str) and candidate.strip(): return candidate.strip() - return self.DEFAULT_VOICE + raise ValueError("FlowSpeech voice must be a nonempty voice name") def validate_environment( - self, - headers: dict[str, str], # mutable-ok: base provider interface requires dict headers - model: str, - api_key: str | None = None, - api_base: str | None = None, - ) -> dict[str, str]: # mutable-ok: base provider interface returns dict headers - resolved_api_key: Final = api_key or litellm.api_key or get_secret_str("FLOWSPEECH_API_KEY") - if resolved_api_key is None: - raise ValueError("FlowSpeech API key is required. Set FLOWSPEECH_API_KEY environment variable.") - return { # mutable-ok: base provider interface returns dict headers - **headers, - "Authorization": f"Bearer {resolved_api_key}", + self, headers: Mapping[str, str], model: str, api_key: str | None = None, api_base: str | None = None + ) -> dict[str, str]: # mutable-ok: base provider interface + key: Final = api_key if api_key is not None else (litellm.api_key or get_secret_str("FLOWSPEECH_API_KEY")) + if not key or not key.isascii() or any(char.isspace() or ord(char) < 33 or ord(char) == 127 for char in key): + raise ValueError("FlowSpeech API key is required and must be a nonempty token. Set FLOWSPEECH_API_KEY.") + if any(name.lower() in ("cookie", "proxy-authorization", "host", "content-length") for name in headers): + raise ValueError("FlowSpeech does not accept cookie, proxy credential, host or content-length overrides") + return { # mutable-ok: base provider interface + **{ # mutable-ok: headers are materialized once + name: value for name, value in headers.items() if name.lower() not in ("authorization", "content-type") + }, + "Authorization": f"Bearer {key}", "Content-Type": "application/json", } @@ -102,29 +168,56 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): self, error_message: str, status_code: int, - headers: dict[str, str] | Headers, # mutable-ok: exception contract accepts dict headers + headers: dict[str, str] | httpx.Headers, # mutable-ok: upstream exception interface ) -> BaseLLMException: - return FlowSpeechException(message=error_message, status_code=status_code, headers=headers) + return FlowSpeechException(status_code, error_message, headers) + + def _input_body( + self, + input: str, + voice: str | None, + optional_params: Mapping[str, object], + ) -> dict[str, object]: # mutable-ok: JSON body required by base interface + if "segments" in optional_params: + if input: + raise ValueError("Use input='' with FlowSpeech segments") + segments: Final = TypeAdapter(list[FlowSpeechSegment]).validate_python(optional_params["segments"]) + if not 1 <= len(segments) <= 1000 or any( + not part.speaker.strip() or not part.text.strip() or not part.voiceName.strip() for part in segments + ): + raise ValueError("FlowSpeech requires 1 to 1000 nonempty speaker turns") + return { # mutable-ok: JSON body required by base interface + "mode": "multi", + "segments": [part.model_dump() for part in segments], # mutable-ok: JSON speaker array + } + if not input.strip(): + raise ValueError("FlowSpeech input must contain text") + return { # mutable-ok: JSON body required by base interface + "mode": "single", + "text": input, + "voiceName": self._resolve_voice(voice), + } def transform_text_to_speech_request( self, model: str, input: str, voice: str | None, - optional_params: dict[str, object], # mutable-ok: base provider interface requires dict - litellm_params: dict[str, object], # mutable-ok: base provider interface requires dict - headers: dict[str, str], # mutable-ok: base provider interface requires dict + optional_params: Mapping[str, object], + litellm_params: Mapping[str, object], + headers: Mapping[str, str], ) -> TextToSpeechRequestData: - request_body: Final[dict[str, object]] = { # mutable-ok: JSON request body requires a dict - "text": input, - "originalText": input, - "speakers": [ # mutable-ok: FlowSpeech JSON schema requires a speakers array - {"voiceName": voice or self.DEFAULT_VOICE} # mutable-ok: FlowSpeech JSON schema requires an object - ], - } + if frozenset(optional_params) - frozenset(("segments", "request_id")): + raise ValueError("Unsupported FlowSpeech request options") + body: Final = self._input_body(input, voice, optional_params) + header_id: Final = next((value for key, value in headers.items() if key.lower() == "idempotency-key"), None) + supplied_id: Final = optional_params.get("request_id", header_id) + request_id: Final = validate_uuid(supplied_id) if supplied_id is not None else str(uuid4()) + if header_id is not None and validate_uuid(header_id) != request_id: + raise ValueError("FlowSpeech request_id and Idempotency-Key must agree") return TextToSpeechRequestData( - dict_body=request_body, - headers={"Content-Type": "application/json"}, # mutable-ok: base request type requires dict headers + dict_body={"input": body}, # mutable-ok: base request interface + headers={"Idempotency-Key": request_id}, # mutable-ok: base request interface ) def transform_text_to_speech_response( @@ -135,57 +228,13 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): ) -> "HttpxBinaryResponseContent": from litellm.types.llms.openai import HttpxBinaryResponseContent - try: - payload: Final = FlowSpeechResponse.model_validate(raw_response.json()) - except ValueError as exc: - raise FlowSpeechException( - status_code=raw_response.status_code, - message="FlowSpeech API returned an invalid JSON response", - headers=raw_response.headers, - ) from exc + if raw_response.status_code != 200 or raw_response.headers.get("content-type") != "audio/wav": + raise FlowSpeechException(502, "FlowSpeech requires completed, downloaded WAV audio") + return HttpxBinaryResponseContent(raw_response) - if payload.code != 0 or payload.data is None or not payload.data.audioBase64: - raise FlowSpeechException( - status_code=raw_response.status_code, - message=payload.message or "FlowSpeech API response did not include audio data", - headers=raw_response.headers, - ) - - try: - audio_bytes: Final = base64.b64decode(payload.data.audioBase64, validate=True) - except (binascii.Error, ValueError) as exc: - raise FlowSpeechException( - status_code=raw_response.status_code, - message="FlowSpeech API returned invalid base64 audio data", - headers=raw_response.headers, - ) from exc - - preserved_headers: Final = { # mutable-ok: httpx.Response requires materialized headers - key: value - for key, value in raw_response.headers.items() - if key.lower() not in frozenset({"content-encoding", "content-length", "content-type", "transfer-encoding"}) - } - response_headers: Final = { # mutable-ok: httpx.Response requires materialized headers - **preserved_headers, - "content-length": str(len(audio_bytes)), - "content-type": payload.data.mimeType, - } - binary_response: Final = httpx.Response( - status_code=200, - headers=response_headers, - content=audio_bytes, - request=raw_response.request, - ) - return HttpxBinaryResponseContent(binary_response) - - def get_complete_url( - self, - model: str, - api_base: str | None, - litellm_params: dict[str, object], # mutable-ok: base provider interface requires dict - ) -> str: - base_url: Final = api_base or get_secret_str("FLOWSPEECH_API_BASE") or self.TTS_BASE_URL - normalized_base_url: Final = base_url.rstrip("/") - if normalized_base_url.endswith(self.TTS_ENDPOINT_PATH): - return normalized_base_url - return f"{normalized_base_url}{self.TTS_ENDPOINT_PATH}" + def get_complete_url(self, model: str, api_base: str | None, litellm_params: Mapping[str, object]) -> str: + base: Final = api_base if api_base is not None else (get_secret_str("FLOWSPEECH_API_BASE") or self.TTS_BASE_URL) + url: Final = validate_url(base) + if url.query or url.path.rstrip("/") not in ("", self.TTS_ENDPOINT_PATH): + raise ValueError("FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint") + return str(url.copy_with(path=self.TTS_ENDPOINT_PATH)) diff --git a/litellm/main.py b/litellm/main.py index e9c1b9fa281..5c87cb3ca0e 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -8226,7 +8226,9 @@ def speech( _is_async=aspeech or False, ) elif custom_llm_provider == "flowspeech": + from litellm.llms.flowspeech.text_to_speech.handler import FlowSpeechTTS from litellm.llms.flowspeech.text_to_speech.transformation import ( + FlowSpeechJob, FlowSpeechTextToSpeechConfig, ) @@ -8244,20 +8246,56 @@ def speech( if api_key is not None: litellm_params_dict["api_key"] = api_key - voice_name: Final = voice if isinstance(voice, str) else None - response = base_llm_http_handler.text_to_speech_handler( # rebind-ok: provider branch sets dispatch result + flowspeech_headers: Final = flowspeech_config.validate_environment( + extra_headers or headers or MappingProxyType({}), model, litellm_params_dict.get("api_key"), api_base + ) + flowspeech_request: Final = flowspeech_config.transform_text_to_speech_request( model=model, input=input, - voice=voice_name, - text_to_speech_provider_config=flowspeech_config, - text_to_speech_optional_params=optional_params, - custom_llm_provider=custom_llm_provider, + voice=voice if isinstance(voice, str) else None, + optional_params=optional_params, litellm_params=litellm_params_dict, - logging_obj=logging_obj, + headers=flowspeech_headers, + ) + flowspeech_url: Final = flowspeech_config.get_complete_url(model, api_base, litellm_params_dict) + + def flowspeech_post_call(job: FlowSpeechJob) -> None: + logging_obj.post_call( + input=input, + api_key="", + original_response=job.model_dump_json( + include={"id", "requestId", "status", "usage"} # mutable-ok: Pydantic include contract requires set + ), + additional_args=MappingProxyType({"request_id": job.requestId, "job_id": job.id}), + ) + + flowspeech_job: Final = FlowSpeechTTS( + url=flowspeech_url, + headers=MappingProxyType( + { + **MappingProxyType( + {key: value for key, value in flowspeech_headers.items() if key.lower() != "idempotency-key"} + ), + **flowspeech_request["headers"], + } + ), + body=flowspeech_request["dict_body"], timeout=timeout, - extra_headers=extra_headers, - client=client, - _is_async=aspeech or False, + max_retries=max_retries, + on_completed=flowspeech_post_call, + ) + logging_obj.pre_call( + input=input, + api_key="", + additional_args=MappingProxyType({"api_base": flowspeech_url, "request_id": flowspeech_job.request_id}), + ) + flowspeech_client: Final = client.client if isinstance(client, (HTTPHandler, AsyncHTTPHandler)) else client + if flowspeech_client is not None and not isinstance( + flowspeech_client, httpx.AsyncClient if aspeech else httpx.Client + ): + raise ValueError("FlowSpeech client must match the synchronous or asynchronous speech call") + response = ( # rebind-ok: provider branch sets dispatch result + flowspeech_job.arun(flowspeech_client) if aspeech else flowspeech_job.run(flowspeech_client) ) elif custom_llm_provider == "vertex_ai" or custom_llm_provider == "vertex_ai_beta": from litellm.llms.vertex_ai.text_to_speech.transformation import ( diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 990682f10a5..993a7ae2346 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -10826,6 +10826,18 @@ async def audio_speech( ): media_type = "audio/wav" # Gemini TTS returns WAV format after conversion + if isinstance(response, HttpxBinaryResponseContent) and "x-flowspeech-job-id" in response.response.headers: + media_type = "audio/wav" # rebind-ok: FlowSpeech v1 returns downloaded WAV even for proxy model aliases + custom_headers.update( + MappingProxyType( + { + key: response.response.headers[key] + for key in ("x-flowspeech-job-id", "x-flowspeech-request-id") + if key in response.response.headers + } + ) + ) + return StreamingResponse( _audio_speech_chunk_generator(response), media_type=media_type, diff --git a/tests/test_litellm/llms/flowspeech/test_handler.py b/tests/test_litellm/llms/flowspeech/test_handler.py new file mode 100644 index 00000000000..c0641e9e493 --- /dev/null +++ b/tests/test_litellm/llms/flowspeech/test_handler.py @@ -0,0 +1,512 @@ +import asyncio +import io +import json +import struct +import wave +from datetime import datetime, timezone +from email.utils import format_datetime + +import httpx +import pytest + +from litellm.llms.flowspeech.text_to_speech.handler import FlowSpeechTTS +from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException + +REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" +JOB_ID = "11111111-2222-4333-8444-555555555555" +URL = "https://flowspeech.io/api/v1/tts/jobs" +AUDIO_URL = "https://audio.example.com/recording.wav" + + +def wav_bytes(pcm=b"\x00\x00" * 24, metadata=False): + output = io.BytesIO() + with wave.open(output, "wb") as audio: + audio.setparams((1, 2, 24000, 0, "NONE", "not compressed")) + audio.writeframes(pcm) + content = output.getvalue() + if metadata: + content = content[:12] + b"JUNK" + struct.pack(" httpx.Response: - assert request.url == "https://flowspeech.io/api/ai/text-to-speech" - assert request.headers["authorization"] == "Bearer test-key" - assert json.loads(request.content) == { - "text": "Hello", - "originalText": "Hello", - "speakers": [{"voiceName": "Aoede"}], - } - return httpx.Response( - 200, - json={ - "code": 0, - "data": { - "mimeType": "audio/mpeg", - "audioBase64": base64.b64encode(audio).decode(), - }, - }, + def log_event(details): + if details.get("log_event_type") == "post_api_call": + logs.append((details["api_key"], details["original_response"], dict(details["additional_args"]))) + + def respond(request): + requests.append(request) + if request.method == "POST": + assert request.url.path == "/api/v1/tts/jobs" + assert request.headers["authorization"] == "Bearer test-key" + assert request.headers["idempotency-key"] == REQUEST_ID + assert json.loads(request.content) == { + "input": ( + {"mode": "multi", "segments": segments} + if multi + else {"mode": "single", "text": "Hello", "voiceName": "Aoede"} + ) + } + return httpx.Response(202, json=success()) + assert request.url.host == "audio.example.com" + assert logs == [] + assert "authorization" not in request.headers and "cookie" not in request.headers + return httpx.Response(200, content=wav_bytes()) + + with httpx.Client(transport=httpx.MockTransport(respond)) as http_client: + result = litellm.speech( + model="flowspeech/flowspeech-tts", + input="" if multi else "Hello", + api_key="test-key", + response_format="wav", + request_id=REQUEST_ID, + timeout=60, + client=HTTPHandler(client=http_client), + logger_fn=log_event, + **({"segments": segments} if multi else {"voice": "Aoede"}), ) + assert result.content == wav_bytes() + assert result.response.headers["content-type"] == "audio/wav" + assert result.response.headers["x-flowspeech-job-id"] == JOB_ID + assert len(requests) == 2 + assert len(logs) == 1 and logs[0][0] == "" + assert json.loads(logs[0][1]) == {key: success()[key] for key in ("id", "requestId", "status", "usage")} + assert logs[0][2] == {"request_id": REQUEST_ID, "job_id": JOB_ID} + assert "test-key" not in repr(logs) and "audio.example.com" not in repr(logs) - client = HTTPHandler(client=httpx.Client(transport=httpx.MockTransport(respond))) - result = litellm.speech( - model="flowspeech/flowspeech-tts", - input="Hello", - voice="Aoede", - api_key="test-key", - client=client, - ) - assert result.content == audio - assert result.response.headers["content-type"] == "audio/mpeg" +@pytest.mark.asyncio +async def test_aspeech_dispatch(): + requests = [] + logs = [] + + def log_event(details): + if details.get("log_event_type") == "post_api_call": + logs.append((details["api_key"], details["original_response"], dict(details["additional_args"]))) + + async def respond(request): + requests.append(request) + if request.method == "POST": + assert json.loads(request.content)["input"]["voiceName"] == "Kore" + return httpx.Response(200, json=success(request.headers["idempotency-key"])) + assert "authorization" not in request.headers + assert logs == [] + return httpx.Response(200, content=wav_bytes()) + + async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: + result = await litellm.aspeech( + model="flowspeech/flowspeech-tts", + input="Hello", + api_key="test-key", + client=client, + timeout=60, + logger_fn=log_event, + ) + assert result.content == wav_bytes() + assert len(requests) == 2 + assert len(logs) == 1 and logs[0][0] == "" + assert json.loads(logs[0][1])["requestId"] == requests[0].headers["idempotency-key"] + assert logs[0][2]["job_id"] == JOB_ID + assert "test-key" not in repr(logs) and "audio.example.com" not in repr(logs) diff --git a/tests/test_litellm/proxy/proxy_server/test_routes_audio.py b/tests/test_litellm/proxy/proxy_server/test_routes_audio.py index 74542a3eaf6..df344ce656f 100644 --- a/tests/test_litellm/proxy/proxy_server/test_routes_audio.py +++ b/tests/test_litellm/proxy/proxy_server/test_routes_audio.py @@ -12,6 +12,7 @@ from __future__ import annotations import io from unittest.mock import AsyncMock, MagicMock +import httpx import pytest from litellm.proxy import proxy_server @@ -152,6 +153,48 @@ def test_audio_speech_happy_path(client, auth_as, patched_speech, path): } +@pytest.mark.parametrize("path", ["/v1/audio/speech", "/audio/speech"]) +def test_flowspeech_proxy_preserves_wav_and_recovery_ids(client, auth_as, patched_speech, monkeypatch, path): + from litellm.types.llms.openai import HttpxBinaryResponseContent + + job_id = "11111111-2222-4333-8444-555555555555" + request_id = "b698824b-de05-486d-8833-05d5c4522a39" + + async def audio(): + return HttpxBinaryResponseContent( + httpx.Response( + 200, + content=b"RIFF-test-WAVE", + headers={ + "content-type": "audio/wav", + "x-flowspeech-job-id": job_id, + "x-flowspeech-request-id": request_id, + }, + ) + ) + + async def route(*args, **kwargs): + assert kwargs["data"]["request_id"] == request_id + return audio() + + monkeypatch.setattr(proxy_server, "route_request", route) + with auth_as(): + response = client.post( + path, + json={ + "model": "narration-alias", + "input": "Hi", + "voice": "Kore", + "request_id": request_id, + }, + ) + assert response.status_code == 200 + assert response.content == b"RIFF-test-WAVE" + assert response.headers["content-type"] == "audio/wav" + assert response.headers["x-flowspeech-job-id"] == job_id + assert response.headers["x-flowspeech-request-id"] == request_id + + @pytest.mark.parametrize("path", ["/v1/audio/speech", "/audio/speech"]) def test_audio_speech_error(client, auth_as, patched_speech_error, path): """Pins ``POST /v1/audio/speech`` and ``POST /audio/speech`` (error).""" From c2043165c9e8065d6186da5fbf79abcddf384c00 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Mon, 26 Oct 2026 18:29:08 +0800 Subject: [PATCH 06/15] fix(flowspeech): satisfy provider CI lint and shard checks --- .github/workflows/test-unit.yml | 1 + .../llms/flowspeech/text_to_speech/handler.py | 18 ++--- .../text_to_speech/transformation.py | 8 +-- litellm/main.py | 4 +- tests/unit/llms/flowspeech/test_handler.py | 45 ++++++++++++ .../test_text_to_speech_transformation.py | 70 ++++++++++++------- 6 files changed, 105 insertions(+), 41 deletions(-) diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 76af64c8ccd..7833bccc222 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -269,6 +269,7 @@ jobs: tests/unit/llms/featherless_ai tests/unit/llms/firecrawl tests/unit/llms/fireworks_ai + tests/unit/llms/flowspeech tests/unit/llms/friendliai tests/unit/llms/gdc tests/unit/llms/gemini diff --git a/litellm/llms/flowspeech/text_to_speech/handler.py b/litellm/llms/flowspeech/text_to_speech/handler.py index 1111cca42f7..dff182c82fd 100644 --- a/litellm/llms/flowspeech/text_to_speech/handler.py +++ b/litellm/llms/flowspeech/text_to_speech/handler.py @@ -176,9 +176,7 @@ class FlowSpeechTTS: if response.is_redirect: raise self.error(502, "FlowSpeech unexpected redirect rejected", response.headers) try: - payload = FlowSpeechErrorResponse.model_validate_json( - response.content - ) + payload = FlowSpeechErrorResponse.model_validate_json(response.content) except ValueError: payload = None retryable = response.status_code == 429 or ( @@ -213,9 +211,7 @@ class FlowSpeechTTS: raise self.error(502, "FlowSpeech returned a different job ID") self.job_id = job_id if job.status in ("failed", "cancelled"): - detail = ( - f"{job.error.code}: {job.error.message}" if job.error else job.status - ) + detail = f"{job.error.code}: {job.error.message}" if job.error else job.status raise self.error(422, f"FlowSpeech job {job.status}: {detail}") if job.status == "success": if job.resultDeleted: @@ -316,7 +312,10 @@ class FlowSpeechTTS: def run(self, client: httpx.Client | None = None) -> HttpxBinaryResponseContent: if client is None: with httpx.Client(trust_env=False) as owned_client: - return self.run(owned_client) + return self._run(owned_client) + return self._run(client) + + def _run(self, client: httpx.Client) -> HttpxBinaryResponseContent: flow: Final = self.flow() action = next(flow) # rebind-ok: workflow driver advances actions try: @@ -342,7 +341,10 @@ class FlowSpeechTTS: async def arun(self, client: httpx.AsyncClient | None = None) -> HttpxBinaryResponseContent: if client is None: async with httpx.AsyncClient(trust_env=False) as owned_client: - return await self.arun(owned_client) + return await self._arun_with_deadline(owned_client) + return await self._arun_with_deadline(client) + + async def _arun_with_deadline(self, client: httpx.AsyncClient) -> HttpxBinaryResponseContent: try: return await asyncio.wait_for(self._arun(client), timeout=self.remaining()) except asyncio.TimeoutError as exc: diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py index 9e94fbc936b..4e27e4eaaac 100644 --- a/litellm/llms/flowspeech/text_to_speech/transformation.py +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -131,9 +131,7 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): raise ValueError("Unsupported FlowSpeech option; use voice or segments") if "segments" in supplied and voice is not None: raise ValueError("Use segment voiceName fields instead of voice for multi-speaker input") - return self._resolve_voice(voice), { - key: supplied[key] for key in ("segments", "request_id") if key in supplied - } + return self._resolve_voice(voice), {key: supplied[key] for key in ("segments", "request_id") if key in supplied} def _resolve_voice(self, voice: str | Mapping[str, object] | None) -> str: if voice is None: @@ -157,9 +155,7 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): if any(name.lower() in ("cookie", "proxy-authorization", "host", "content-length") for name in headers): raise ValueError("FlowSpeech does not accept cookie, proxy credential, host or content-length overrides") return { - **{ - name: value for name, value in headers.items() if name.lower() not in ("authorization", "content-type") - }, + **{name: value for name, value in headers.items() if name.lower() not in ("authorization", "content-type")}, "Authorization": f"Bearer {key}", "Content-Type": "application/json", } diff --git a/litellm/main.py b/litellm/main.py index 757d5abad63..694e371afca 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -8909,9 +8909,7 @@ def speech( logging_obj.post_call( input=input, api_key="", - original_response=job.model_dump_json( - include={"id", "requestId", "status", "usage"} - ), + original_response=job.model_dump_json(include={"id", "requestId", "status", "usage"}), additional_args=MappingProxyType({"request_id": job.requestId, "job_id": job.id}), ) diff --git a/tests/unit/llms/flowspeech/test_handler.py b/tests/unit/llms/flowspeech/test_handler.py index c0641e9e493..578aee7e9d4 100644 --- a/tests/unit/llms/flowspeech/test_handler.py +++ b/tests/unit/llms/flowspeech/test_handler.py @@ -483,6 +483,51 @@ def test_stream_size_limit_without_content_length(invoke): invoke(tts, respond) +@pytest.mark.parametrize("asynchronous", [False, True]) +@pytest.mark.parametrize("owned", [False, True]) +@pytest.mark.parametrize("successful", [False, True]) +@pytest.mark.asyncio +async def test_client_lifetime(monkeypatch, asynchronous, owned, successful): + methods = [] + + def respond(request): + methods.append(request.method) + if request.method == "POST": + return httpx.Response(202, json=job("success" if successful else "failed")) + return httpx.Response(200, content=wav_bytes()) + + client_type = httpx.AsyncClient if asynchronous else httpx.Client + client = client_type(transport=httpx.MockTransport(respond)) + + def create_client(*, trust_env): + assert trust_env is False + return client + + if owned: + monkeypatch.setattr(httpx, "AsyncClient" if asynchronous else "Client", create_client) + tts = handler(Clock()) + + async def call(): + if asynchronous: + return await tts.arun(None if owned else client) + return tts.run(None if owned else client) + + try: + if successful: + result = await call() + assert result.content == wav_bytes() + else: + with pytest.raises(FlowSpeechException, match="FlowSpeech job failed"): + await call() + assert methods == (["POST", "GET"] if successful else ["POST"]) + assert client.is_closed is owned + finally: + if asynchronous: + await client.aclose() + else: + client.close() + + @pytest.mark.asyncio async def test_async_total_deadline_interrupts_network(): async def respond(request): diff --git a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py index fd37766ddb9..3b11512ea70 100644 --- a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py @@ -58,9 +58,16 @@ def test_maps_multi_and_recovery_id(): assert request["headers"]["Idempotency-Key"] == REQUEST_ID -@pytest.mark.parametrize("params", [{"speed": 1}, {"instructions": "calm"}, {"response_format": "mp3"}]) -def test_rejects_unsupported_options_even_with_drop_params(params): - with pytest.raises(ValueError): +@pytest.mark.parametrize( + "params,message", + [ + ({"speed": 1}, "FlowSpeech does not support instructions or speed"), + ({"instructions": "calm"}, "FlowSpeech does not support instructions or speed"), + ({"response_format": "mp3"}, "FlowSpeech only supports response_format='wav'"), + ], +) +def test_rejects_unsupported_options_even_with_drop_params(params, message): + with pytest.raises(ValueError, match=message): FlowSpeechTextToSpeechConfig().map_openai_params("flowspeech-tts", params, drop_params=True) @@ -72,23 +79,35 @@ def test_rejects_legacy_and_unsupported_kwargs(key): @pytest.mark.parametrize("voice", ["", " ", {}, {"voiceName": ""}, {"voiceName": 7}]) def test_rejects_invalid_voice(voice): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="FlowSpeech voice must be a nonempty voice name"): FlowSpeechTextToSpeechConfig().map_openai_params("flowspeech-tts", {}, voice) @pytest.mark.parametrize( - "params,text", + "params,text,message", [ - ({"segments": []}, ""), - ({"segments": [{"speaker": "A", "text": "Hi", "voiceName": "Kore", "speed": 1}]}, ""), - ({"segments": [{"speaker": " ", "text": "Hi", "voiceName": "Kore"}]}, ""), - ({"segments": [{"speaker": "A", "text": "Hi", "voiceName": "Kore"}]}, "ambiguous"), - ({"request_id": "../bad"}, "Hi"), - ({}, " "), + ({"segments": []}, "", "FlowSpeech requires 1 to 1000 nonempty speaker turns"), + ( + {"segments": [{"speaker": "A", "text": "Hi", "voiceName": "Kore", "speed": 1}]}, + "", + "Extra inputs are not permitted", + ), + ( + {"segments": [{"speaker": " ", "text": "Hi", "voiceName": "Kore"}]}, + "", + "FlowSpeech requires 1 to 1000 nonempty speaker turns", + ), + ( + {"segments": [{"speaker": "A", "text": "Hi", "voiceName": "Kore"}]}, + "ambiguous", + "Use input='' with FlowSpeech segments", + ), + ({"request_id": "../bad"}, "Hi", "FlowSpeech requires a UUID"), + ({}, " ", "FlowSpeech input must contain text"), ], ) -def test_invalid_requests(params, text): - with pytest.raises(ValueError): +def test_invalid_requests(params, text, message): + with pytest.raises(ValueError, match=message): FlowSpeechTextToSpeechConfig().transform_text_to_speech_request("flowspeech-tts", text, None, params, {}, {}) @@ -125,7 +144,7 @@ def test_rejects_invalid_key(key): @pytest.mark.parametrize("name", ["Cookie", "Proxy-Authorization", "Host", "content-length"]) def test_rejects_unsafe_api_headers(name): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="does not accept cookie, proxy credential, host or content-length overrides"): FlowSpeechTextToSpeechConfig().validate_environment({name: "test"}, "flowspeech-tts", "test-key") @@ -145,19 +164,22 @@ def test_complete_url(base): @pytest.mark.parametrize( - "base", + "base,message", [ - "http://example.com", - "https://u:p@example.com", - "file:///tmp/test", - "https://example.com/?key=x", - "https://example.com/#x", - "https://example.com/api/ai/text-to-speech", - "", + ("http://example.com", "FlowSpeech requires an HTTPS URL without credentials or fragment"), + ("https://u:p@example.com", "FlowSpeech requires an HTTPS URL without credentials or fragment"), + ("file:///tmp/test", "FlowSpeech requires an HTTPS URL without credentials or fragment"), + ("https://example.com/?key=x", "FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint"), + ("https://example.com/#x", "FlowSpeech requires an HTTPS URL without credentials or fragment"), + ( + "https://example.com/api/ai/text-to-speech", + "FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint", + ), + ("", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ], ) -def test_rejects_invalid_base(base): - with pytest.raises(ValueError): +def test_rejects_invalid_base(base, message): + with pytest.raises(ValueError, match=message): FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", base, {}) From 81c91d5777c7e39a9079912dfee0271c5600977e Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Mon, 26 Oct 2026 19:15:50 +0800 Subject: [PATCH 07/15] fix: align FlowSpeech integration with provider contracts --- litellm/__init__.py | 5 ++ .../llms/flowspeech/text_to_speech/handler.py | 12 ++-- .../text_to_speech/transformation.py | 10 +++- litellm/main.py | 43 ++++++++------ litellm/proxy/proxy_server.py | 26 +++++---- .../provider_create_fields.json | 28 +++++++++ tests/unit/llms/flowspeech/test_handler.py | 37 +++++++++++- .../test_text_to_speech_transformation.py | 58 +++++++++++++++++-- .../public_endpoints/test_public_endpoints.py | 18 ++++++ 9 files changed, 194 insertions(+), 43 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index c0141f43611..0a72fd38b26 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -673,6 +673,7 @@ nebius_embedding_models: Set = set() aiml_models: Set = set() deepgram_models: Set = set() elevenlabs_models: Set = set() +flowspeech_models: Final[set[str]] = set() # mutable-ok: populated when the shared model catalog loads dashscope_models: Set = set() qwencloud_models: Set = set() qwen_ai_platform_models: Set = set() @@ -949,6 +950,8 @@ def _populate_provider_model_sets(model_cost_map: Mapping[str, Mapping[str, obje deepgram_models.add(key) elif value.get("litellm_provider") == "elevenlabs": elevenlabs_models.add(key) + elif value.get("litellm_provider") == "flowspeech": + flowspeech_models.add(key) elif value.get("litellm_provider") == "heroku": heroku_models.add(key) elif value.get("litellm_provider") == "dashscope": @@ -1131,6 +1134,7 @@ model_list = list( | nscale_models | deepgram_models | elevenlabs_models + | flowspeech_models | dashscope_models | qwencloud_models | qwen_ai_platform_models @@ -1247,6 +1251,7 @@ def _build_models_by_provider() -> dict: "featherless_ai": featherless_ai_models, "deepgram": deepgram_models, "elevenlabs": elevenlabs_models, + "flowspeech": flowspeech_models, "heroku": heroku_models, "dashscope": dashscope_models, "qwencloud": qwencloud_models, diff --git a/litellm/llms/flowspeech/text_to_speech/handler.py b/litellm/llms/flowspeech/text_to_speech/handler.py index dff182c82fd..f538302a05c 100644 --- a/litellm/llms/flowspeech/text_to_speech/handler.py +++ b/litellm/llms/flowspeech/text_to_speech/handler.py @@ -13,7 +13,11 @@ from typing import Final, TypeAlias import httpx +from litellm.llms.custom_httpx.http_handler import ( + get_async_httpx_client, # pyright: ignore[reportUnknownVariableType] # unused factory params are untyped upstream +) from litellm.types.llms.openai import HttpxBinaryResponseContent +from litellm.types.utils import LlmProviders from .transformation import ( FlowSpeechErrorResponse, @@ -339,10 +343,10 @@ class FlowSpeechTTS: flow.close() async def arun(self, client: httpx.AsyncClient | None = None) -> HttpxBinaryResponseContent: - if client is None: - async with httpx.AsyncClient(trust_env=False) as owned_client: - return await self._arun_with_deadline(owned_client) - return await self._arun_with_deadline(client) + selected_client: Final = ( + client if client is not None else get_async_httpx_client(LlmProviders.FLOWSPEECH).client + ) + return await self._arun_with_deadline(selected_client) async def _arun_with_deadline(self, client: httpx.AsyncClient) -> HttpxBinaryResponseContent: try: diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py index 4e27e4eaaac..f53a8915454 100644 --- a/litellm/llms/flowspeech/text_to_speech/transformation.py +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -231,6 +231,10 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): def get_complete_url(self, model: str, api_base: str | None, litellm_params: Mapping[str, object]) -> str: base: Final = api_base if api_base is not None else (get_secret_str("FLOWSPEECH_API_BASE") or self.TTS_BASE_URL) url: Final = validate_url(base) - if url.query or url.path.rstrip("/") not in ("", self.TTS_ENDPOINT_PATH): - raise ValueError("FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint") - return str(url.copy_with(path=self.TTS_ENDPOINT_PATH)) + if url.query: + raise ValueError("FlowSpeech api_base must not contain a query") + path: Final = url.path.rstrip("/") + if path.endswith("/api/ai/text-to-speech"): + raise ValueError("FlowSpeech api_base must not use the legacy text-to-speech endpoint") + endpoint: Final = path if path.endswith(self.TTS_ENDPOINT_PATH) else path + self.TTS_ENDPOINT_PATH + return str(url.copy_with(path=endpoint)) diff --git a/litellm/main.py b/litellm/main.py index 694e371afca..59e8591a625 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: import dotenv import httpx import openai -from pydantic import BaseModel, TypeAdapter, ValidationError +from pydantic import BaseModel, StrictStr, TypeAdapter, ValidationError from typing_extensions import assert_never, overload import litellm @@ -8892,21 +8892,27 @@ def speech( if api_key is not None: litellm_params_dict["api_key"] = api_key + flowspeech_params: Final = TypeAdapter(Mapping[str, object]).validate_python(litellm_params_dict) flowspeech_headers: Final = flowspeech_config.validate_environment( - extra_headers or headers or MappingProxyType({}), model, litellm_params_dict.get("api_key"), api_base + TypeAdapter(Mapping[StrictStr, StrictStr]).validate_python( + extra_headers or headers or MappingProxyType({}) + ), + model, + TypeAdapter[str | None](str | None).validate_python(flowspeech_params.get("api_key"), strict=True), + api_base, ) flowspeech_request: Final = flowspeech_config.transform_text_to_speech_request( model=model, input=input, voice=voice if isinstance(voice, str) else None, - optional_params=optional_params, - litellm_params=litellm_params_dict, + optional_params=TypeAdapter(Mapping[str, object]).validate_python(optional_params), + litellm_params=flowspeech_params, headers=flowspeech_headers, ) - flowspeech_url: Final = flowspeech_config.get_complete_url(model, api_base, litellm_params_dict) + flowspeech_url: Final = flowspeech_config.get_complete_url(model, api_base, flowspeech_params) def flowspeech_post_call(job: FlowSpeechJob) -> None: - logging_obj.post_call( + logging_obj.post_call( # pyright: ignore[reportUnknownMemberType] # upstream logging callback has untyped parameters input=input, api_key="", original_response=job.model_dump_json(include={"id", "requestId", "status", "usage"}), @@ -8920,27 +8926,30 @@ def speech( **MappingProxyType( {key: value for key, value in flowspeech_headers.items() if key.lower() != "idempotency-key"} ), - **flowspeech_request["headers"], + **TypeAdapter(Mapping[str, str]).validate_python(flowspeech_request.get("headers"), strict=True), } ), - body=flowspeech_request["dict_body"], - timeout=timeout, + body=TypeAdapter(Mapping[str, object]).validate_python(flowspeech_request.get("dict_body")), + timeout=http_timeout, max_retries=max_retries, on_completed=flowspeech_post_call, ) - logging_obj.pre_call( + logging_obj.pre_call( # pyright: ignore[reportUnknownMemberType] # upstream logging callback has untyped parameters input=input, api_key="", additional_args=MappingProxyType({"api_base": flowspeech_url, "request_id": flowspeech_job.request_id}), ) - flowspeech_client: Final = client.client if isinstance(client, (HTTPHandler, AsyncHTTPHandler)) else client - if flowspeech_client is not None and not isinstance( - flowspeech_client, httpx.AsyncClient if aspeech else httpx.Client - ): - raise ValueError("FlowSpeech client must match the synchronous or asynchronous speech call") - response = ( # rebind-ok: provider branch sets dispatch result - flowspeech_job.arun(flowspeech_client) if aspeech else flowspeech_job.run(flowspeech_client) + flowspeech_client: Final = TypeAdapter(object).validate_python( + client.client if isinstance(client, (HTTPHandler, AsyncHTTPHandler)) else client ) + if aspeech: + if flowspeech_client is not None and not isinstance(flowspeech_client, httpx.AsyncClient): + raise ValueError("FlowSpeech client must match the synchronous or asynchronous speech call") + response = flowspeech_job.arun(flowspeech_client) # rebind-ok: provider branch sets dispatch result + else: + if flowspeech_client is not None and not isinstance(flowspeech_client, httpx.Client): + raise ValueError("FlowSpeech client must match the synchronous or asynchronous speech call") + response = flowspeech_job.run(flowspeech_client) # rebind-ok: provider branch sets dispatch result elif custom_llm_provider == "vertex_ai" or custom_llm_provider == "vertex_ai_beta": from litellm.llms.vertex_ai.text_to_speech.transformation import ( VertexAILyriaTextToSpeechConfig, diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 55486e26517..fee9feecb73 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -13378,22 +13378,26 @@ async def audio_speech( response_format=requested_format if isinstance(requested_format, str) else None, ) - if isinstance(response, HttpxBinaryResponseContent) and "x-flowspeech-job-id" in response.response.headers: - media_type = "audio/wav" - custom_headers.update( - MappingProxyType( - { - key: response.response.headers[key] - for key in ("x-flowspeech-job-id", "x-flowspeech-request-id") - if key in response.response.headers - } - ) + flowspeech_raw_response: Final = _UNTYPED_VALUE.validate_python( + getattr(_UNTYPED_VALUE.validate_python(response), "response", None) + ) + flowspeech_recovery_headers: Final[Mapping[str, str]] = ( + MappingProxyType( + { + key: flowspeech_raw_response.headers[key] + for key in ("x-flowspeech-job-id", "x-flowspeech-request-id") + if key in flowspeech_raw_response.headers + } ) + if isinstance(flowspeech_raw_response, httpx.Response) + and "x-flowspeech-job-id" in flowspeech_raw_response.headers + else MappingProxyType({}) + ) return StreamingResponse( _audio_speech_chunk_generator(response), media_type=media_type, - headers=custom_headers, + headers={**TypeAdapter(Mapping[str, str]).validate_python(custom_headers), **flowspeech_recovery_headers}, ) except Exception as e: diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index 19ee465c7dc..ce092f26572 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -1561,6 +1561,34 @@ ], "default_model_placeholder": "gpt-3.5-turbo" }, + { + "provider": "FlowSpeech", + "provider_display_name": "FlowSpeech", + "litellm_provider": "flowspeech", + "credential_fields": [ + { + "key": "api_key", + "label": "API Key", + "placeholder": null, + "tooltip": null, + "required": true, + "field_type": "password", + "options": null, + "default_value": null + }, + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://flowspeech.io", + "tooltip": "HTTPS origin, trusted gateway prefix, or complete /api/v1/tts/jobs endpoint", + "required": false, + "field_type": "text", + "options": null, + "default_value": null + } + ], + "default_model_placeholder": "flowspeech/flowspeech-tts" + }, { "provider": "FRIENDLIAI", "provider_display_name": "Friendliai", diff --git a/tests/unit/llms/flowspeech/test_handler.py b/tests/unit/llms/flowspeech/test_handler.py index 578aee7e9d4..965f001afa1 100644 --- a/tests/unit/llms/flowspeech/test_handler.py +++ b/tests/unit/llms/flowspeech/test_handler.py @@ -9,8 +9,10 @@ from email.utils import format_datetime import httpx import pytest +from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.llms.flowspeech.text_to_speech.handler import FlowSpeechTTS from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException +from litellm.types.utils import LlmProviders REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" JOB_ID = "11111111-2222-4333-8444-555555555555" @@ -504,7 +506,10 @@ async def test_client_lifetime(monkeypatch, asynchronous, owned, successful): return client if owned: - monkeypatch.setattr(httpx, "AsyncClient" if asynchronous else "Client", create_client) + if asynchronous: + get_async_httpx_client(LlmProviders.FLOWSPEECH).client = client + else: + monkeypatch.setattr(httpx, "Client", create_client) tts = handler(Clock()) async def call(): @@ -520,7 +525,7 @@ async def test_client_lifetime(monkeypatch, asynchronous, owned, successful): with pytest.raises(FlowSpeechException, match="FlowSpeech job failed"): await call() assert methods == (["POST", "GET"] if successful else ["POST"]) - assert client.is_closed is owned + assert client.is_closed is (owned and not asynchronous) finally: if asynchronous: await client.aclose() @@ -528,6 +533,34 @@ async def test_client_lifetime(monkeypatch, asynchronous, owned, successful): client.close() +@pytest.mark.asyncio +async def test_default_async_client_is_reused_without_download_credentials(): + requests = [] + + def respond(request): + requests.append(request) + if request.method == "POST": + return httpx.Response(202, json=job()) + assert "authorization" not in request.headers + assert "cookie" not in request.headers + assert "x-client-secret" not in request.headers + return httpx.Response(200, content=wav_bytes()) + + cached = get_async_httpx_client(LlmProviders.FLOWSPEECH) + async with httpx.AsyncClient( + transport=httpx.MockTransport(respond), + headers={"Authorization": "discard", "X-Client-Secret": "discard"}, + cookies={"session": "discard"}, + ) as client: + cached.client = client + for _ in range(2): + result = await handler(Clock()).arun() + assert result.content == wav_bytes() + assert not client.is_closed + assert get_async_httpx_client(LlmProviders.FLOWSPEECH).client is client + assert [request.method for request in requests] == ["POST", "GET", "POST", "GET"] + + @pytest.mark.asyncio async def test_async_total_deadline_interrupts_network(): async def respond(request): diff --git a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py index 3b11512ea70..4698fefacd3 100644 --- a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py @@ -169,11 +169,11 @@ def test_complete_url(base): ("http://example.com", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ("https://u:p@example.com", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ("file:///tmp/test", "FlowSpeech requires an HTTPS URL without credentials or fragment"), - ("https://example.com/?key=x", "FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint"), + ("https://example.com/?key=x", "FlowSpeech api_base must not contain a query"), ("https://example.com/#x", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ( "https://example.com/api/ai/text-to-speech", - "FlowSpeech api_base must be an origin or the /api/v1/tts/jobs endpoint", + "FlowSpeech api_base must not use the legacy text-to-speech endpoint", ), ("", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ], @@ -183,6 +183,19 @@ def test_rejects_invalid_base(base, message): FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", base, {}) +@pytest.mark.parametrize( + "base,expected", + [ + ("https://gateway.example/p", "https://gateway.example/p/api/v1/tts/jobs"), + ("https://gateway.example/p/", "https://gateway.example/p/api/v1/tts/jobs"), + ("https://gateway.example/p/api/v1/tts/jobs/", "https://gateway.example/p/api/v1/tts/jobs"), + ("https://api/v1/", "https://api/v1/api/v1/tts/jobs"), + ], +) +def test_gateway_base_preserves_prefix_without_duplicating_endpoint(base, expected): + assert FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", base, {}) == expected + + def test_registers_provider(): from litellm.utils import ProviderConfigManager @@ -191,10 +204,14 @@ def test_registers_provider(): assert model == "flowspeech-tts" assert provider == "flowspeech" assert isinstance(config, FlowSpeechTextToSpeechConfig) + assert "flowspeech/flowspeech-tts" in litellm.model_list + assert litellm.models_by_provider[provider] == litellm.flowspeech_models + assert "flowspeech/flowspeech-tts" in litellm.models_by_provider[provider] @pytest.mark.parametrize("multi", [False, True]) -def test_speech_dispatch(multi): +@pytest.mark.parametrize("timeout_args", [{}, {"timeout": None}, {"timeout": 60}]) +def test_speech_dispatch(multi, timeout_args): requests = [] logs = [] segments = [{"speaker": "A", "text": "Hi", "voiceName": "Kore"}] @@ -229,9 +246,9 @@ def test_speech_dispatch(multi): api_key="test-key", response_format="wav", request_id=REQUEST_ID, - timeout=60, client=HTTPHandler(client=http_client), logger_fn=log_event, + **timeout_args, **({"segments": segments} if multi else {"voice": "Aoede"}), ) assert result.content == wav_bytes() @@ -245,7 +262,8 @@ def test_speech_dispatch(multi): @pytest.mark.asyncio -async def test_aspeech_dispatch(): +@pytest.mark.parametrize("timeout_args", [{}, {"timeout": None}, {"timeout": 60}]) +async def test_aspeech_dispatch(timeout_args): requests = [] logs = [] @@ -268,8 +286,8 @@ async def test_aspeech_dispatch(): input="Hello", api_key="test-key", client=client, - timeout=60, logger_fn=log_event, + **timeout_args, ) assert result.content == wav_bytes() assert len(requests) == 2 @@ -277,3 +295,31 @@ async def test_aspeech_dispatch(): assert json.loads(logs[0][1])["requestId"] == requests[0].headers["idempotency-key"] assert logs[0][2]["job_id"] == JOB_ID assert "test-key" not in repr(logs) and "audio.example.com" not in repr(logs) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("asynchronous", [False, True]) +async def test_dispatch_rejects_mismatched_client_before_sending(asynchronous): + requests = [] + + def respond(request): + requests.append(request) + return httpx.Response(200, json=success()) + + client_type = httpx.Client if asynchronous else httpx.AsyncClient + client = client_type(transport=httpx.MockTransport(respond)) + try: + kwargs = {"model": "flowspeech/flowspeech-tts", "input": "Hello", "api_key": "test-key", "client": client} + message = "client must match the synchronous or asynchronous speech call" + if asynchronous: + with pytest.raises(litellm.APIConnectionError, match=message): + await litellm.aspeech(**kwargs) + else: + with pytest.raises(ValueError, match=message): + litellm.speech(**kwargs) + assert requests == [] + finally: + if isinstance(client, httpx.AsyncClient): + await client.aclose() + else: + client.close() diff --git a/tests/unit/proxy/public_endpoints/test_public_endpoints.py b/tests/unit/proxy/public_endpoints/test_public_endpoints.py index cc61b6f2fcf..c180b348a95 100644 --- a/tests/unit/proxy/public_endpoints/test_public_endpoints.py +++ b/tests/unit/proxy/public_endpoints/test_public_endpoints.py @@ -560,6 +560,24 @@ def test_every_backend_provider_is_listed_in_add_model_or_frozen_as_unlisted(): ) +def test_flowspeech_provider_fields_support_configured_credentials(): + app_instance = FastAPI() + app_instance.include_router(router) + test_client = TestClient(app_instance) + + response = test_client.get("/public/providers/fields") + assert response.status_code == 200 + entry = next(p for p in response.json() if p["litellm_provider"] == "flowspeech") + fields = {field["key"]: field for field in entry["credential_fields"]} + assert entry["provider_display_name"] == "FlowSpeech" + assert entry["default_model_placeholder"] in litellm.models_by_provider["flowspeech"] + assert fields["api_key"]["required"] is True + assert fields["api_key"]["field_type"] == "password" + assert fields["api_base"]["required"] is False + assert fields["api_base"]["field_type"] == "text" + assert fields["api_base"]["placeholder"] == "https://flowspeech.io" + + def test_google_ai_studio_provider_fields_expose_api_base(): """The Google AI Studio (gemini) credential form must let admins set a custom api_base so they can point at a Gemini-compatible gateway (e.g. a self-hosted From 81e77c34fafefa2a376e43ab53c33f0d435de53a Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Mon, 26 Oct 2026 21:14:19 +0800 Subject: [PATCH 08/15] fix: protect FlowSpeech credentials and deadline boundaries --- .../llms/flowspeech/text_to_speech/handler.py | 11 + .../text_to_speech/transformation.py | 40 +++- litellm/main.py | 8 +- .../sdk/test_flowspeech_deadline_wire.py | 213 ++++++++++++++++++ tests/unit/llms/flowspeech/test_handler.py | 96 +++++++- .../test_text_to_speech_transformation.py | 81 +++++++ 6 files changed, 431 insertions(+), 18 deletions(-) create mode 100644 tests/integration/sdk/test_flowspeech_deadline_wire.py diff --git a/litellm/llms/flowspeech/text_to_speech/handler.py b/litellm/llms/flowspeech/text_to_speech/handler.py index f538302a05c..297d35eba4d 100644 --- a/litellm/llms/flowspeech/text_to_speech/handler.py +++ b/litellm/llms/flowspeech/text_to_speech/handler.py @@ -232,9 +232,12 @@ class FlowSpeechTTS: response = yield from self.exchange("GET", f"{self.url}/{job_id}") def completed_response(self, job: FlowSpeechJob, response: httpx.Response) -> HttpxBinaryResponseContent: + self.remaining() result: Final = self.audio_response(response) + self.remaining() if self.on_completed is not None: self.on_completed(job) + self.remaining() return result def audio_response(self, response: httpx.Response) -> HttpxBinaryResponseContent: @@ -280,15 +283,19 @@ class FlowSpeechTTS: return maximum def read(self, client: httpx.Client, request: httpx.Request) -> httpx.Response: + self.remaining() response: Final = client.send(request, stream=True, auth=None, follow_redirects=False) try: + self.remaining() maximum: Final = self.limit(request, response) with io.BytesIO() as content: + self.remaining() for chunk in response.iter_bytes(): self.remaining() if content.tell() + len(chunk) > maximum: raise self.error(502, "FlowSpeech response exceeds size limit") content.write(chunk) + self.remaining() self.remaining() return httpx.Response( response.status_code, headers=response.headers, content=content.getvalue(), request=request @@ -297,15 +304,19 @@ class FlowSpeechTTS: response.close() async def aread(self, client: httpx.AsyncClient, request: httpx.Request) -> httpx.Response: + self.remaining() response: Final = await client.send(request, stream=True, auth=None, follow_redirects=False) try: + self.remaining() maximum: Final = self.limit(request, response) with io.BytesIO() as content: + self.remaining() async for chunk in response.aiter_bytes(): self.remaining() if content.tell() + len(chunk) > maximum: raise self.error(502, "FlowSpeech response exceeds size limit") content.write(chunk) + self.remaining() self.remaining() return httpx.Response( response.status_code, headers=response.headers, content=content.getvalue(), request=request diff --git a/litellm/llms/flowspeech/text_to_speech/transformation.py b/litellm/llms/flowspeech/text_to_speech/transformation.py index f53a8915454..7aac647e4dd 100644 --- a/litellm/llms/flowspeech/text_to_speech/transformation.py +++ b/litellm/llms/flowspeech/text_to_speech/transformation.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Final, Literal from uuid import UUID, uuid4 import httpx -from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictStr, TypeAdapter, ValidationError, field_validator import litellm from litellm.llms.base_llm.chat.transformation import BaseLLMException @@ -101,6 +101,13 @@ def validate_url(value: str) -> httpx.URL: return url +def credential_headers(value: object) -> Mapping[str, str] | None: + try: + return TypeAdapter(Mapping[StrictStr, StrictStr]).validate_python(value) + except ValidationError: + return None + + class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): TTS_BASE_URL = "https://flowspeech.io" TTS_ENDPOINT_PATH = "/api/v1/tts/jobs" @@ -147,15 +154,27 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): raise ValueError("FlowSpeech voice must be a nonempty voice name") def validate_environment( - self, headers: Mapping[str, str], model: str, api_key: str | None = None, api_base: str | None = None + self, headers: object, model: str, api_key: object = None, api_base: str | None = None ) -> dict[str, str]: # mutable-ok: base provider interface key: Final = api_key if api_key is not None else (litellm.api_key or get_secret_str("FLOWSPEECH_API_KEY")) - if not key or not key.isascii() or any(char.isspace() or ord(char) < 33 or ord(char) == 127 for char in key): + if ( + not isinstance(key, str) + or not key + or not key.isascii() + or any(char.isspace() or ord(char) < 33 or ord(char) == 127 for char in key) + ): raise ValueError("FlowSpeech API key is required and must be a nonempty token. Set FLOWSPEECH_API_KEY.") - if any(name.lower() in ("cookie", "proxy-authorization", "host", "content-length") for name in headers): + checked_headers: Final = credential_headers(headers) + if checked_headers is None: + raise ValueError("FlowSpeech headers must be a mapping of string names to string values") + if any(name.lower() in ("cookie", "proxy-authorization", "host", "content-length") for name in checked_headers): raise ValueError("FlowSpeech does not accept cookie, proxy credential, host or content-length overrides") return { - **{name: value for name, value in headers.items() if name.lower() not in ("authorization", "content-type")}, + **{ + name: value + for name, value in checked_headers.items() + if name.lower() not in ("authorization", "content-type") + }, "Authorization": f"Bearer {key}", "Content-Type": "application/json", } @@ -231,10 +250,11 @@ class FlowSpeechTextToSpeechConfig(BaseTextToSpeechConfig): def get_complete_url(self, model: str, api_base: str | None, litellm_params: Mapping[str, object]) -> str: base: Final = api_base if api_base is not None else (get_secret_str("FLOWSPEECH_API_BASE") or self.TTS_BASE_URL) url: Final = validate_url(base) - if url.query: + if url.query or b"?" in url.raw_path: raise ValueError("FlowSpeech api_base must not contain a query") - path: Final = url.path.rstrip("/") - if path.endswith("/api/ai/text-to-speech"): + if url.path.rstrip("/").endswith("/api/ai/text-to-speech"): raise ValueError("FlowSpeech api_base must not use the legacy text-to-speech endpoint") - endpoint: Final = path if path.endswith(self.TTS_ENDPOINT_PATH) else path + self.TTS_ENDPOINT_PATH - return str(url.copy_with(path=endpoint)) + path: Final = url.raw_path.rstrip(b"/") + suffix: Final = self.TTS_ENDPOINT_PATH.encode("ascii") + endpoint: Final = path if path.endswith(suffix) else path + suffix + return str(url.copy_with(raw_path=endpoint)) diff --git a/litellm/main.py b/litellm/main.py index 59e8591a625..2a84c76e43b 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: import dotenv import httpx import openai -from pydantic import BaseModel, StrictStr, TypeAdapter, ValidationError +from pydantic import BaseModel, TypeAdapter, ValidationError from typing_extensions import assert_never, overload import litellm @@ -8894,11 +8894,9 @@ def speech( flowspeech_params: Final = TypeAdapter(Mapping[str, object]).validate_python(litellm_params_dict) flowspeech_headers: Final = flowspeech_config.validate_environment( - TypeAdapter(Mapping[StrictStr, StrictStr]).validate_python( - extra_headers or headers or MappingProxyType({}) - ), + TypeAdapter(object).validate_python(extra_headers or headers or MappingProxyType({})), model, - TypeAdapter[str | None](str | None).validate_python(flowspeech_params.get("api_key"), strict=True), + flowspeech_params.get("api_key"), api_base, ) flowspeech_request: Final = flowspeech_config.transform_text_to_speech_request( diff --git a/tests/integration/sdk/test_flowspeech_deadline_wire.py b/tests/integration/sdk/test_flowspeech_deadline_wire.py new file mode 100644 index 00000000000..60dd0806c57 --- /dev/null +++ b/tests/integration/sdk/test_flowspeech_deadline_wire.py @@ -0,0 +1,213 @@ +import asyncio +import io +import ipaddress +import json +import ssl +import threading +import time +import wave +from concurrent.futures import ThreadPoolExecutor +from datetime import datetime, timezone +from http.server import BaseHTTPRequestHandler, HTTPServer + +import httpx +import pytest +from cryptography import x509 +from cryptography.hazmat.primitives import hashes, serialization +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.x509.oid import NameOID + +import litellm +from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException + +REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" +JOB_ID = "11111111-2222-4333-8444-555555555555" +BUDGET = 0.3 + + +def wav_bytes(): + buffer = io.BytesIO() + with wave.open(buffer, "wb") as audio: + audio.setparams((1, 2, 24000, 0, "NONE", "not compressed")) + audio.writeframes(b"\x00\x00" * 24) + return buffer.getvalue() + + +def tls_contexts(directory): + key = ec.generate_private_key(ec.SECP256R1()) + name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "localhost")]) + certificate = ( + x509.CertificateBuilder() + .subject_name(name) + .issuer_name(name) + .public_key(key.public_key()) + .serial_number(1) + .not_valid_before(datetime(2020, 1, 1, tzinfo=timezone.utc)) + .not_valid_after(datetime(2100, 1, 1, tzinfo=timezone.utc)) + .add_extension(x509.SubjectAlternativeName([x509.IPAddress(ipaddress.ip_address("127.0.0.1"))]), False) + .sign(key, hashes.SHA256()) + ) + cert_file = directory / "loopback.pem" + key_file = directory / "loopback.key" + cert_file.write_bytes(certificate.public_bytes(serialization.Encoding.PEM)) + key_file.write_bytes( + key.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()) + ) + server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + server_context.load_cert_chain(cert_file, key_file) + return server_context, ssl.create_default_context(cafile=str(cert_file)) + + +@pytest.fixture +def slow_speech_peer(tmp_path, scenario): + requests = [] + body = wav_bytes() + server_context, client_context = tls_contexts(tmp_path) + + class Handler(BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + + def setup(self): + super().setup() + self.connection.settimeout(2) + + def log_message(self, format, *args): + return + + def reply(self, content): + self.send_response(200) + self.send_header("Content-Length", str(len(content))) + self.end_headers() + self.wfile.write(content) + self.wfile.flush() + + def do_POST(self): + request_body = self.rfile.read(int(self.headers["Content-Length"])) + requests.append((self.command, self.path, dict(self.headers), json.loads(request_body))) + self.reply( + json.dumps( + { + "id": JOB_ID, + "requestId": self.headers["Idempotency-Key"], + "status": "success", + "usage": {"billableCharacters": 5, "reservedCredits": 0, "chargedCredits": 5}, + "result": { + "url": f"{base_url}/audio.wav", + "mimeType": "audio/wav", + "sampleRate": 24000, + "channels": 1, + "bitsPerSample": 16, + }, + } + ).encode() + ) + + def do_GET(self): + requests.append((self.command, self.path, dict(self.headers), None)) + if self.path == "/health": + self.reply(b"ok") + return + try: + if scenario == "slow_headers_body": + time.sleep(0.2) + self.send_response(200) + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.flush() + time.sleep(0.2) + self.wfile.write(body) + elif scenario == "slow_header_progress": + self.wfile.write(b"HTTP/1.1 200 OK\r\nX-Progress: ") + for _ in range(10): + self.wfile.write(b"x") + self.wfile.flush() + time.sleep(0.05) + self.wfile.write(f"\r\nContent-Length: {len(body)}\r\n\r\n".encode() + body) + else: + self.send_response(200) + self.send_header("Content-Length", str(len(body))) + self.end_headers() + for offset in range(0, len(body), 8): + time.sleep(0.05) + self.wfile.write(body[offset : offset + 8]) + self.wfile.flush() + self.wfile.flush() + except (BrokenPipeError, ConnectionResetError, ssl.SSLEOFError): + self.close_connection = True + + server = HTTPServer(("127.0.0.1", 0), Handler) + server.socket = server_context.wrap_socket(server.socket, server_side=True) + base_url = f"https://127.0.0.1:{server.server_port}" + worker = threading.Thread(target=server.serve_forever, kwargs={"poll_interval": 0.02}) + worker.start() + try: + yield base_url, client_context, requests + finally: + server.shutdown() + server.server_close() + worker.join(timeout=3) + assert not worker.is_alive() + + +@pytest.mark.asyncio +@pytest.mark.parametrize("mode", ["sync", "worker", "async"]) +@pytest.mark.parametrize("scenario", ["slow_headers_body", "slow_body_progress", "slow_header_progress"]) +async def test_cooperative_deadline_rejects_late_audio_without_retry_or_client_closure(slow_speech_peer, mode): + base_url, client_context, requests = slow_speech_peer + responses = [] + completed = [] + + def log_event(details): + if details.get("log_event_type") == "post_api_call": + completed.append(details) + + async def record_response(response): + responses.append(response) + + kwargs = { + "model": "flowspeech/flowspeech-tts", + "input": "Hello", + "api_key": "synthetic-loopback-only", + "api_base": base_url, + "request_id": REQUEST_ID, + "timeout": BUDGET, + "max_retries": 2, + "logger_fn": log_event, + } + options = { + "verify": client_context, + "trust_env": False, + "limits": httpx.Limits(max_connections=1, max_keepalive_connections=1), + } + if mode == "async": + async with httpx.AsyncClient(**options, event_hooks={"response": [record_response]}) as client: + with pytest.raises(litellm.Timeout, match="total deadline") as error: + await asyncio.wait_for(litellm.aspeech(**kwargs, client=client), timeout=5) + assert not client.is_closed + assert responses and all(response.is_closed for response in responses) + assert (await client.get(f"{base_url}/health", timeout=3)).content == b"ok" + else: + with httpx.Client(**options, event_hooks={"response": [responses.append]}) as client: + if mode == "worker": + with ThreadPoolExecutor(max_workers=1) as pool: + result = pool.submit(litellm.speech, **kwargs, client=client) + with pytest.raises(FlowSpeechException, match="total deadline") as error: + result.result(timeout=5) + else: + with pytest.raises(FlowSpeechException, match="total deadline") as error: + litellm.speech(**kwargs, client=client) + assert not client.is_closed + assert responses and all(response.is_closed for response in responses) + assert client.get(f"{base_url}/health", timeout=3).content == b"ok" + + assert REQUEST_ID in str(error.value) + assert JOB_ID in str(error.value) + assert [(method, path) for method, path, _, _ in requests] == [ + ("POST", "/api/v1/tts/jobs"), + ("GET", "/audio.wav"), + ("GET", "/health"), + ] + assert httpx.Headers(requests[0][2])["Idempotency-Key"] == REQUEST_ID + assert requests[0][3] == {"input": {"mode": "single", "text": "Hello", "voiceName": "Kore"}} + assert "authorization" not in httpx.Headers(requests[1][2]) + assert completed == [] diff --git a/tests/unit/llms/flowspeech/test_handler.py b/tests/unit/llms/flowspeech/test_handler.py index 965f001afa1..2a42f9210da 100644 --- a/tests/unit/llms/flowspeech/test_handler.py +++ b/tests/unit/llms/flowspeech/test_handler.py @@ -11,7 +11,7 @@ import pytest from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.llms.flowspeech.text_to_speech.handler import FlowSpeechTTS -from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException +from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException, FlowSpeechTextToSpeechConfig from litellm.types.utils import LlmProviders REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" @@ -81,9 +81,9 @@ class Clock: await asyncio.sleep(0) -def handler(clock, timeout=120, **kwargs): +def handler(clock, timeout=120, url=URL, **kwargs): return FlowSpeechTTS( - URL, + url, { "Authorization": "Bearer test-key", "Idempotency-Key": REQUEST_ID, @@ -154,6 +154,29 @@ def test_all_pending_states_and_uncredentialed_download(invoke): assert requests[-1].extensions["timeout"]["read"] == 100 +@pytest.mark.parametrize("prefix", ["/p%2Fq", "/p%2fq", "/p%252Fq", "/p%3Fq", "/p%23q"]) +def test_encoded_gateway_prefix_survives_submission_and_polling(invoke, prefix): + requests = [] + endpoint = f"{prefix}/api/v1/tts/jobs" + url = FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", f"https://gateway.example{prefix}/", {}) + + def respond(request): + requests.append(request) + if request.method == "POST": + return httpx.Response(202, json=job("queued")) + if request.url.host == "gateway.example": + return httpx.Response(200, json=job()) + return httpx.Response(200, content=wav_bytes()) + + assert invoke(handler(Clock(), url=url), respond).content == wav_bytes() + assert [(request.method, request.url.raw_path) for request in requests] == [ + ("POST", endpoint.encode()), + ("GET", f"{endpoint}/{JOB_ID}".encode()), + ("GET", b"/recording.wav"), + ] + assert requests[0].headers["Idempotency-Key"] == REQUEST_ID + + @pytest.mark.parametrize("failure", ["network", "server", "rate_limit"]) def test_create_retry_preserves_uuid_and_body(invoke, failure): clock = Clock() @@ -427,6 +450,73 @@ def test_deadline_during_request(invoke): invoke(handler(clock, timeout=10), respond) +@pytest.mark.parametrize("stage", ["submission", "download"]) +@pytest.mark.parametrize("header_delay,body_delay,expected_reads", [(0.125, 0, 0), (0.075, 0.075, 1)]) +def test_expired_stream_is_closed_without_more_work(invoke, stage, header_delay, body_delay, expected_reads): + clock = Clock() + completed = [] + requests = [] + + class Stream(httpx.SyncByteStream, httpx.AsyncByteStream): + def __init__(self): + self.reads = 0 + self.closed = False + + def __iter__(self): + self.reads += 1 + clock.now += body_delay + yield wav_bytes() if stage == "download" else json.dumps(job()).encode() + pytest.fail("must not advance a stream after its budget expires") + + async def __aiter__(self): + for chunk in self: + yield chunk + + def close(self): + self.closed = True + + async def aclose(self): + self.close() + + stream = Stream() + + def respond(request): + requests.append(request) + if stage == "download" and request.method == "POST": + return httpx.Response(202, json=job()) + clock.now += header_delay + return httpx.Response(200, stream=stream) + + with pytest.raises(FlowSpeechException, match="total deadline") as error: + invoke(handler(clock, timeout=0.1, on_completed=completed.append), respond) + assert error.value.status_code == 408 + assert REQUEST_ID in str(error.value) + assert f"job_id={JOB_ID if stage == 'download' else 'unknown'}" in str(error.value) + assert stream.reads == expected_reads + assert stream.closed + assert [request.method for request in requests] == (["POST", "GET"] if stage == "download" else ["POST"]) + assert clock.sleeps == [] + assert completed == [] + + +def test_deadline_after_wav_validation_prevents_success_callback(invoke, monkeypatch): + clock = Clock() + completed = [] + content = wav_bytes() + open_wav = wave.open + + def delayed_open(*args, **kwargs): + clock.now = 11 + return open_wav(*args, **kwargs) + + monkeypatch.setattr(wave, "open", delayed_open) + responses = iter([httpx.Response(202, json=job()), httpx.Response(200, content=content)]) + with pytest.raises(FlowSpeechException, match="total deadline"): + invoke(handler(clock, timeout=10, on_completed=completed.append), lambda request: next(responses)) + assert completed == [] + assert clock.sleeps == [] + + @pytest.mark.parametrize("timeout", [0, -1, float("inf"), float("nan"), httpx.Timeout(None)]) def test_invalid_timeout(timeout): with pytest.raises(ValueError, match="timeout"): diff --git a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py index 4698fefacd3..6e8e75995cc 100644 --- a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py @@ -1,5 +1,7 @@ import io import json +import logging +import traceback import wave from uuid import UUID @@ -7,11 +9,27 @@ import httpx import pytest import litellm +from litellm.integrations.custom_logger import CustomLogger from litellm.llms.custom_httpx.http_handler import HTTPHandler from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechTextToSpeechConfig REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" JOB_ID = "11111111-2222-4333-8444-555555555555" +SECRET_SENTINEL = "credential-value-must-not-appear-672911" + + +class FailureRecorder(CustomLogger): + def __init__(self): + super().__init__() + self.errors = [] + + def log_failure_event(self, kwargs, response_obj, start_time, end_time): + self.errors.append( + (str(kwargs["exception"]), kwargs["traceback_exception"], kwargs["standard_logging_object"]["error_str"]) + ) + + async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time): + self.log_failure_event(kwargs, response_obj, start_time, end_time) def wav_bytes(): @@ -170,6 +188,7 @@ def test_complete_url(base): ("https://u:p@example.com", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ("file:///tmp/test", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ("https://example.com/?key=x", "FlowSpeech api_base must not contain a query"), + ("https://example.com/p?", "FlowSpeech api_base must not contain a query"), ("https://example.com/#x", "FlowSpeech requires an HTTPS URL without credentials or fragment"), ( "https://example.com/api/ai/text-to-speech", @@ -196,6 +215,68 @@ def test_gateway_base_preserves_prefix_without_duplicating_endpoint(base, expect assert FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", base, {}) == expected +@pytest.mark.parametrize("prefix", ["/p%2Fq", "/p%2fq", "/p%252Fq", "/p%3Fq", "/p%23q"]) +@pytest.mark.parametrize("suffix", ["/", "/api/v1/tts/jobs", "/api/v1/tts/jobs/"]) +def test_gateway_prefix_preserves_encoded_path(prefix, suffix): + url = FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", f"https://gateway.example{prefix}{suffix}", {}) + assert httpx.URL(url).raw_path == f"{prefix}/api/v1/tts/jobs".encode("ascii") + assert httpx.URL(url).query == b"" + assert httpx.URL(url).fragment == "" + + +@pytest.mark.parametrize( + "headers", + [SECRET_SENTINEL, {SECRET_SENTINEL.encode(): "invalid"}, {"Authorization": {"value": SECRET_SENTINEL}}], +) +def test_invalid_headers_raise_no_input_bearing_exception_chain(headers): + with pytest.raises(ValueError, match="FlowSpeech headers must be a mapping") as error: + FlowSpeechTextToSpeechConfig().validate_environment(headers, "flowspeech-tts", "test-key") + assert error.value.__context__ is None + assert SECRET_SENTINEL not in "".join(traceback.format_exception(error.value)) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("asynchronous", [False, True]) +@pytest.mark.parametrize( + "invalid,message", + [ + ({"api_key": SECRET_SENTINEL.encode()}, "FlowSpeech API key is required"), + ({"api_key": {"value": SECRET_SENTINEL}}, "FlowSpeech API key is required"), + ({"headers": {"Authorization": SECRET_SENTINEL.encode()}}, "FlowSpeech headers must be a mapping"), + ({"headers": {"Authorization": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": {"Authorization": SECRET_SENTINEL.encode()}}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": {"Authorization": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), + ], +) +async def test_invalid_credentials_never_reach_errors_or_logs(asynchronous, invalid, message, monkeypatch, caplog, capsys): + caplog.set_level(logging.DEBUG, logger="LiteLLM") + recorder = FailureRecorder() + monkeypatch.setattr(litellm, "failure_callback", [recorder]) + monkeypatch.setattr(litellm, "_async_failure_callback", [recorder]) + requests = [] + + def respond(request): + requests.append(request) + return httpx.Response(200, json=success()) + + kwargs = {"model": "flowspeech/flowspeech-tts", "input": "Hello", "api_key": "test-key", **invalid} + if asynchronous: + async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: + with pytest.raises(litellm.APIConnectionError, match=message) as error: + await litellm.aspeech(**kwargs, client=client) + else: + with httpx.Client(transport=httpx.MockTransport(respond)) as client: + with pytest.raises(ValueError, match=message) as error: + litellm.speech(**kwargs, client=client) + captured = capsys.readouterr() + assert requests == [] + assert recorder.errors + assert SECRET_SENTINEL not in str(error.value) + assert SECRET_SENTINEL not in "".join(traceback.format_exception(error.value)) + assert SECRET_SENTINEL not in repr(recorder.errors) + assert SECRET_SENTINEL not in caplog.text + captured.out + captured.err + + def test_registers_provider(): from litellm.utils import ProviderConfigManager From c5e2a08a5ea69573726b34b84e8669ec5cb0ff06 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Tue, 27 Oct 2026 12:57:44 +0800 Subject: [PATCH 09/15] fix: redact positional credentials and malformed request headers --- .../sensitive_data_masker.py | 46 ++++- litellm/utils.py | 43 ++++- .../test_sensitive_data_masker.py | 83 +++++++++ .../test_text_to_speech_transformation.py | 175 +++++++++++++++++- tests/unit/test_utils.py | 119 ++++++++++++ 5 files changed, 457 insertions(+), 9 deletions(-) diff --git a/litellm/litellm_core_utils/sensitive_data_masker.py b/litellm/litellm_core_utils/sensitive_data_masker.py index 8c402fe9b44..6bc411e2319 100644 --- a/litellm/litellm_core_utils/sensitive_data_masker.py +++ b/litellm/litellm_core_utils/sensitive_data_masker.py @@ -1,7 +1,7 @@ from collections.abc import ItemsView, Mapping, Sequence from collections.abc import Set as AbstractSet from dataclasses import dataclass, field -from typing import Any, Final +from typing import Any, Final, cast from pydantic import BaseModel @@ -255,6 +255,50 @@ def mask_sensitive_keys(data: Mapping[str, object], sensitive_fields: set[str]) return masked +_REQUEST_LOG_HEADER_NAMES: Final = frozenset( + ( + "accept", + "accept-encoding", + "authorization", + "proxy-authorization", + "cookie", + "set-cookie", + "api-key", + "x-api-key", + "x-goog-api-key", + "content-type", + "content-length", + "user-agent", + "idempotency-key", + "x-request-id", + "x-correlation-id", + ) +) + + +def _redact_request_headers(value: object) -> object: + if value is None: + return None + if not isinstance(value, Mapping): + return REDACTED + headers: Final = cast(Mapping[object, object], value) # cast-ok: Mapping checked above, keys remain untrusted + if any( + not isinstance(name, str) or name.lower() not in _REQUEST_LOG_HEADER_NAMES or not isinstance(item, str) + for name, item in headers.items() + ): + return REDACTED + return headers + + +def redact_credentials_in_request(data: Mapping[str, object]) -> Mapping[str, object]: + return redact_credentials_in_payload( + { + key: _redact_request_headers(value) if key in ("headers", "extra_headers") else value + for key, value in data.items() + } + ) + + def redact_credentials_in_payload(data: Mapping[str, object]) -> Mapping[str, object]: """Return a copy of ``data`` where every value under a credential-named key is replaced by the shared ``REDACTED`` marker, nested mappings are recursed into, diff --git a/litellm/utils.py b/litellm/utils.py index da1bdf01ae8..a403300fe93 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -94,7 +94,11 @@ from litellm.litellm_core_utils.fallback_generalizations import ( from litellm.litellm_core_utils.get_model_cost_map import AliasedCostEntry from litellm.litellm_core_utils.model_param_helper import peek_reasoning_summary_aliases from litellm.litellm_core_utils.offline_mode import is_offline_mode -from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_payload +from litellm.litellm_core_utils.secret_redaction import REDACTED +from litellm.litellm_core_utils.sensitive_data_masker import ( + redact_credentials_in_payload, + redact_credentials_in_request, +) from litellm.litellm_core_utils.tokenizer import strip_special_tokens from litellm.litellm_core_utils.tool_fields import MalformedField, resolve_deployment_tool_fields from litellm.rust_bridge import tokenizer as tokenizer_dispatch @@ -8537,7 +8541,38 @@ def get_valid_models( return [] # NON-Blocking -def print_args_passed_to_litellm(original_function, args, kwargs): +def _request_logging_parameters(original_function: Callable[..., object]) -> tuple[str, ...]: + parameters: Final = inspect.signature(original_function).parameters.values() + positional: Final = tuple( + parameter.name + for parameter in parameters + if parameter.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD) + ) + if positional or not inspect.iscoroutinefunction(original_function): + return positional + if original_function.__name__.startswith("a"): + synchronous: Final = getattr(inspect.getmodule(original_function), original_function.__name__[1:], None) + if callable(synchronous) and not inspect.iscoroutinefunction(synchronous): + return _request_logging_parameters(synchronous) + return () + + +def _redact_positional_request_args( + original_function: Callable[..., object], args: tuple[object, ...] +) -> tuple[object, ...]: + if not args: + return () + try: + names: Final = _request_logging_parameters(original_function) + except (TypeError, ValueError): + return (REDACTED,) * len(args) + redacted: Final = redact_credentials_in_request(dict(zip(names, args))) + return tuple(redacted[name] for name in names[: len(args)]) + (REDACTED,) * max(0, len(args) - len(names)) + + +def print_args_passed_to_litellm( + original_function: Callable[..., object], args: tuple[object, ...], kwargs: Mapping[str, object] +) -> None: if not is_debugging_on(): return try: @@ -8557,8 +8592,8 @@ def print_args_passed_to_litellm(original_function, args, kwargs): ): return - args_str: Final = ", ".join(map(repr, args)) - redacted_kwargs: Final = redact_credentials_in_payload(kwargs) + args_str: Final = ", ".join(map(repr, _redact_positional_request_args(original_function, args))) + redacted_kwargs: Final = redact_credentials_in_request(kwargs) kwargs_str: Final = ", ".join(f"{key}={value!r}" for key, value in redacted_kwargs.items()) print_verbose( "\n", diff --git a/tests/unit/litellm_core_utils/test_sensitive_data_masker.py b/tests/unit/litellm_core_utils/test_sensitive_data_masker.py index 2182620164c..86010a79982 100644 --- a/tests/unit/litellm_core_utils/test_sensitive_data_masker.py +++ b/tests/unit/litellm_core_utils/test_sensitive_data_masker.py @@ -3,13 +3,96 @@ Unit tests for SensitiveDataMasker - List Preservation """ from functools import reduce +from types import MappingProxyType from typing import Final +import httpx import pytest from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker +@pytest.mark.parametrize("field", ["headers", "extra_headers"]) +@pytest.mark.parametrize( + "malformed", + [ + "synthetic-header-secret", + b"synthetic-header-secret", + [("Authorization", "synthetic-header-secret")], + {b"synthetic-header-secret": "unused"}, + {123: "synthetic-header-secret"}, + {"Bearer synthetic-header-secret": "unused"}, + {"synthetic-header-secret\r\n": "unused"}, + {"": "synthetic-header-secret"}, + {"\u2603": "synthetic-header-secret"}, + {"SYNTHETIC_KEY": "Bearer synthetic-header-secret"}, + {"q8m4p9x2": "synthetic-header-secret"}, + {"X-Request-Id": b"synthetic-header-secret"}, + {"X-Request-Id": {"value": "synthetic-header-secret"}}, + {"X-Request-Id": ["synthetic-header-secret"]}, + ], +) +def test_request_redaction_hides_malformed_headers_only(field: str, malformed: object) -> None: + from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_request + + payload: Final = {field: malformed, "model": "synthetic-model", "temperature": 0.25} + assert redact_credentials_in_request(payload) == { + field: "REDACTED", + "model": "synthetic-model", + "temperature": 0.25, + } + assert payload[field] is malformed + + +@pytest.mark.parametrize("factory", [dict, MappingProxyType, httpx.Headers]) +@pytest.mark.parametrize("field", ["headers", "extra_headers"]) +def test_request_redaction_preserves_normal_headers_and_tool_schema(factory, field: str) -> None: + from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_request + + headers: Final = factory( + { + "authorization": "synthetic-header-secret", + "cookie": "synthetic-cookie", + "x-request-id": "safe-correlation", + "content-type": "application/json", + } + ) + schema: Final = { + "type": "object", + "properties": {"headers": {"type": "string"}, "extra_headers": {"type": "array"}}, + } + result: Final = redact_credentials_in_request({field: headers, "tools": [{"parameters": schema}]}) + assert result == { + field: { + "authorization": "REDACTED", + "cookie": "REDACTED", + "x-request-id": "safe-correlation", + "content-type": "application/json", + }, + "tools": [{"parameters": schema}], + } + assert headers["authorization"] == "synthetic-header-secret" + + +@pytest.mark.parametrize("headers", [None, {}]) +def test_request_redaction_preserves_unset_headers(headers) -> None: + from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_request + + assert redact_credentials_in_request({"headers": headers}) == {"headers": headers} + + +def test_request_redaction_never_renders_non_string_header_values() -> None: + from litellm.litellm_core_utils.sensitive_data_masker import redact_credentials_in_request + + class SensitiveHeaderValue: + def __repr__(self) -> str: + pytest.fail("A non-string header value must not be rendered") + + assert redact_credentials_in_request({"headers": {"X-Request-Id": SensitiveHeaderValue()}}) == { + "headers": "REDACTED" + } + + def test_lists_are_preserved_not_converted_to_strings(): """ Regression test: Ensure lists are preserved as JSON arrays, not converted to strings. diff --git a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py index 6e8e75995cc..c60ba4bff82 100644 --- a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py @@ -3,6 +3,7 @@ import json import logging import traceback import wave +from typing import Final from uuid import UUID import httpx @@ -11,13 +12,26 @@ import pytest import litellm from litellm.integrations.custom_logger import CustomLogger from litellm.llms.custom_httpx.http_handler import HTTPHandler -from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechTextToSpeechConfig +from litellm.llms.flowspeech.text_to_speech.transformation import FlowSpeechException, FlowSpeechTextToSpeechConfig REQUEST_ID = "b698824b-de05-486d-8833-05d5c4522a39" JOB_ID = "11111111-2222-4333-8444-555555555555" SECRET_SENTINEL = "credential-value-must-not-appear-672911" +def assert_clean_exception_chain(error: BaseException | None, seen: frozenset[int] = frozenset()) -> None: + if error is None or id(error) in seen: + return + assert SECRET_SENTINEL not in repr(error.args) + assert SECRET_SENTINEL not in repr(vars(error)) + assert SECRET_SENTINEL not in "".join(traceback.format_exception(error)) + request: Final = getattr(error, "request", None) + if isinstance(request, httpx.Request): + assert SECRET_SENTINEL not in str(request.url) + repr(request.headers) + repr(request.content) + assert_clean_exception_chain(error.__cause__, seen | {id(error)}) + assert_clean_exception_chain(error.__context__, seen | {id(error)}) + + class FailureRecorder(CustomLogger): def __init__(self): super().__init__() @@ -237,6 +251,7 @@ def test_invalid_headers_raise_no_input_bearing_exception_chain(headers): @pytest.mark.asyncio @pytest.mark.parametrize("asynchronous", [False, True]) +@pytest.mark.parametrize("positional", [False, True]) @pytest.mark.parametrize( "invalid,message", [ @@ -246,9 +261,25 @@ def test_invalid_headers_raise_no_input_bearing_exception_chain(headers): ({"headers": {"Authorization": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), ({"extra_headers": {"Authorization": SECRET_SENTINEL.encode()}}, "FlowSpeech headers must be a mapping"), ({"extra_headers": {"Authorization": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), + ({"headers": SECRET_SENTINEL}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": SECRET_SENTINEL}, "FlowSpeech headers must be a mapping"), + ({"headers": {SECRET_SENTINEL.encode(): "unused"}}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": {SECRET_SENTINEL.encode(): "unused"}}, "FlowSpeech headers must be a mapping"), + ({"headers": {"X-Correlation-Id": SECRET_SENTINEL.encode()}}, "FlowSpeech headers must be a mapping"), + ({"headers": {"X-Correlation-Id": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": {"X-Correlation-Id": SECRET_SENTINEL.encode()}}, "FlowSpeech headers must be a mapping"), + ({"extra_headers": {"X-Correlation-Id": {"value": SECRET_SENTINEL}}}, "FlowSpeech headers must be a mapping"), ], ) -async def test_invalid_credentials_never_reach_errors_or_logs(asynchronous, invalid, message, monkeypatch, caplog, capsys): +async def test_invalid_credentials_never_reach_errors_or_logs( + asynchronous, + positional, + invalid, + message, + monkeypatch, + caplog, + capsys, +): caplog.set_level(logging.DEBUG, logger="LiteLLM") recorder = FailureRecorder() monkeypatch.setattr(litellm, "failure_callback", [recorder]) @@ -260,14 +291,20 @@ async def test_invalid_credentials_never_reach_errors_or_logs(asynchronous, inva return httpx.Response(200, json=success()) kwargs = {"model": "flowspeech/flowspeech-tts", "input": "Hello", "api_key": "test-key", **invalid} + args: Final = (kwargs["model"], kwargs["input"], None, kwargs["api_key"]) if positional else () + call_kwargs: Final = ( + {key: value for key, value in kwargs.items() if key not in ("model", "input", "api_key")} + if positional + else kwargs + ) if asynchronous: async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: with pytest.raises(litellm.APIConnectionError, match=message) as error: - await litellm.aspeech(**kwargs, client=client) + await litellm.aspeech(*args, **call_kwargs, client=client) else: with httpx.Client(transport=httpx.MockTransport(respond)) as client: with pytest.raises(ValueError, match=message) as error: - litellm.speech(**kwargs, client=client) + litellm.speech(*args, **call_kwargs, client=client) captured = capsys.readouterr() assert requests == [] assert recorder.errors @@ -275,6 +312,136 @@ async def test_invalid_credentials_never_reach_errors_or_logs(asynchronous, inva assert SECRET_SENTINEL not in "".join(traceback.format_exception(error.value)) assert SECRET_SENTINEL not in repr(recorder.errors) assert SECRET_SENTINEL not in caplog.text + captured.out + captured.err + assert_clean_exception_chain(error.value) + + +@pytest.mark.asyncio +@pytest.mark.parametrize("asynchronous", [False, True]) +@pytest.mark.parametrize("positional", [False, True]) +@pytest.mark.parametrize("successful", [False, True]) +@pytest.mark.parametrize("verbose", [False, True]) +@pytest.mark.parametrize("header_field", ["headers", "extra_headers"]) +@pytest.mark.parametrize("header_name", ["Authorization", SECRET_SENTINEL]) +async def test_request_log_redaction_preserves_speech_transport( + asynchronous: bool, + positional: bool, + successful: bool, + verbose: bool, + header_field: str, + header_name: str, + monkeypatch: pytest.MonkeyPatch, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], +) -> None: + monkeypatch.setattr(litellm, "set_verbose", verbose) + monkeypatch.setattr("litellm._logging.set_verbose", verbose) + caplog.set_level(logging.WARNING if verbose else logging.DEBUG, logger="LiteLLM") + headers: Final = {header_name: SECRET_SENTINEL, "X-Correlation-Id": "safe-correlation"} + args: Final = ("flowspeech/flowspeech-tts", "Hello", "Kore", SECRET_SENTINEL) if positional else () + kwargs: Final = ( + {} + if positional + else { + "model": "flowspeech/flowspeech-tts", + "input": "Hello", + "voice": "Kore", + "api_key": SECRET_SENTINEL, + } + ) + calls: Final = [] + + def respond(request: httpx.Request) -> httpx.Response: + calls.append(request.method) + if request.method == "POST": + assert request.headers["authorization"] == f"Bearer {SECRET_SENTINEL}" + assert request.headers["x-correlation-id"] == "safe-correlation" + assert request.headers["idempotency-key"] == REQUEST_ID + assert json.loads(request.content) == {"input": {"mode": "single", "text": "Hello", "voiceName": "Kore"}} + if not successful: + return httpx.Response( + 400, json={"error": {"code": "synthetic", "message": "synthetic", "retryable": False}} + ) + return httpx.Response(200, json=success()) + assert "authorization" not in request.headers + assert "cookie" not in request.headers + assert "x-correlation-id" not in request.headers + return httpx.Response(200, content=wav_bytes()) + + async def call(): + if asynchronous: + async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: + return await litellm.aspeech( + *args, + **kwargs, + **{header_field: headers}, + request_id=REQUEST_ID, + max_retries=0, + client=client, + ) + with httpx.Client(transport=httpx.MockTransport(respond)) as client: + return litellm.speech( + *args, + **kwargs, + **{header_field: headers}, + request_id=REQUEST_ID, + max_retries=0, + client=client, + ) + + if successful: + result: Final = await call() + assert result.content == wav_bytes() + else: + with pytest.raises(litellm.BadRequestError if asynchronous else FlowSpeechException) as error: + await call() + assert_clean_exception_chain(error.value) + assert error.value.status_code == 400 + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert SECRET_SENTINEL not in output + assert "REDACTED" in output + assert ("safe-correlation" in output) is (header_name == "Authorization") + assert "Hello" in output and "Kore" in output + assert calls == (["POST", "GET"] if successful else ["POST"]) + assert headers == {header_name: SECRET_SENTINEL, "X-Correlation-Id": "safe-correlation"} + + +@pytest.mark.asyncio +@pytest.mark.parametrize("asynchronous", [False, True]) +@pytest.mark.parametrize("debug", [False, True]) +async def test_positional_key_debug_controls( + asynchronous: bool, + debug: bool, + monkeypatch: pytest.MonkeyPatch, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], +) -> None: + monkeypatch.setattr(litellm, "set_verbose", False) + monkeypatch.setattr("litellm._logging.set_verbose", False) + caplog.set_level(logging.DEBUG if debug else logging.ERROR, logger="LiteLLM") + calls: Final = [] + + def respond(request: httpx.Request) -> httpx.Response: + calls.append(request.method) + assert request.headers["authorization"] == f"Bearer {SECRET_SENTINEL}" + return httpx.Response(400, json={"error": {"code": "synthetic", "message": "synthetic", "retryable": False}}) + + with pytest.raises(litellm.BadRequestError if asynchronous else FlowSpeechException) as error: + if asynchronous: + async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: + await litellm.aspeech( + "flowspeech/flowspeech-tts", "Hello", "Kore", SECRET_SENTINEL, client=client, max_retries=0 + ) + else: + with httpx.Client(transport=httpx.MockTransport(respond)) as client: + litellm.speech( + "flowspeech/flowspeech-tts", "Hello", "Kore", SECRET_SENTINEL, client=client, max_retries=0 + ) + captured: Final = capsys.readouterr() + assert SECRET_SENTINEL not in caplog.text + captured.out + captured.err + assert ("Request to litellm:" in caplog.text) is debug + assert calls == ["POST"] + assert_clean_exception_chain(error.value) def test_registers_provider(): diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 55b7bc78a11..8fc72fc748b 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -4,6 +4,7 @@ import base64 import copy import contextlib import contextvars +import inspect import io import json import logging @@ -6946,6 +6947,124 @@ class TestVerboseRequestLineRedaction: FAKE_API_KEY: Final = "sk-fake-lit6823-0000000000000000" + @pytest.mark.parametrize( + "function_name", ["speech", "aspeech", "embedding", "aembedding", "completion", "acompletion"] + ) + @pytest.mark.parametrize("verbose", [False, True]) + def test_positional_credentials_follow_public_signatures( + self, + function_name: str, + verbose: bool, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + function: Final = getattr(litellm, function_name) + signature_name: Final = function_name[1:] if function_name in ("aspeech", "aembedding") else function_name + signature_function: Final = getattr(litellm, signature_name) + sentinel: Final = "SYNTHETIC-POSITIONAL-KEY-ONLY" + input_value: Final = "synthetic-input" if signature_name in ("speech", "embedding") else [] + bound: Final = inspect.signature(signature_function).bind_partial( + "synthetic-model", input_value, api_key=sentinel + ) + bound.apply_defaults() + args: Final = bound.args + monkeypatch.setattr(litellm, "set_verbose", verbose) + monkeypatch.setattr("litellm._logging.set_verbose", verbose) + with caplog.at_level(logging.DEBUG if not verbose else logging.WARNING, logger=verbose_logger.name): + print_args_passed_to_litellm(function, args, {"max_retries": 0}) + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert f"litellm.{function_name}(" in output + assert "synthetic-model" in output + assert "max_retries=0" in output + assert "REDACTED" in output + assert sentinel not in output + assert sentinel in args + + @pytest.mark.parametrize("field", ["headers", "extra_headers"]) + @pytest.mark.parametrize("malformed", ["synthetic-header-value", {b"synthetic-header-value": "unused"}]) + def test_malformed_headers_do_not_reach_request_line( + self, + field: str, + malformed: object, + caplog: pytest.LogCaptureFixture, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + print_args_passed_to_litellm(litellm.completion, (), {"model": "synthetic-model", field: malformed}) + assert "synthetic-header-value" not in caplog.text + assert f"{field}='REDACTED'" in caplog.text + assert "model='synthetic-model'" in caplog.text + + @pytest.mark.asyncio + @pytest.mark.parametrize("asynchronous", [False, True]) + @pytest.mark.parametrize("positional", [False, True]) + async def test_non_speech_mock_completion_preserves_result_and_context( + self, + asynchronous: bool, + positional: bool, + caplog: pytest.LogCaptureFixture, + ) -> None: + function: Final = litellm.acompletion if asynchronous else litellm.completion + params: Final = { + "model": "openai/synthetic-model", + "messages": [{"role": "user", "content": "synthetic input"}], + "api_key": self.FAKE_API_KEY, + "temperature": 0.25, + "extra_headers": {"Authorization": self.FAKE_API_KEY, "X-Request-Id": "safe-correlation"}, + } + bound: Final = inspect.signature(function).bind_partial(**params) + bound.apply_defaults() + args: Final = bound.args if positional else () + kwargs: Final = bound.kwargs if positional else params + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + response: Final = ( + await litellm.acompletion(*args, **kwargs, mock_response="synthetic output") + if asynchronous + else litellm.completion(*args, **kwargs, mock_response="synthetic output") + ) + assert response.choices[0].message.content == "synthetic output" + assert self.FAKE_API_KEY not in caplog.text + assert "safe-correlation" in caplog.text + assert "synthetic input" in caplog.text + assert "0.25" in caplog.text + assert params["api_key"] == self.FAKE_API_KEY + assert params["extra_headers"]["Authorization"] == self.FAKE_API_KEY + + def test_unidentified_varargs_are_hidden_without_losing_keyword_context( + self, + caplog: pytest.LogCaptureFixture, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + def opaque(*args: object, **kwargs: object) -> None: + pass + + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + print_args_passed_to_litellm(opaque, (self.FAKE_API_KEY,), {"model": "synthetic-model"}) + assert self.FAKE_API_KEY not in caplog.text + assert "litellm.opaque('REDACTED', model='synthetic-model')" in caplog.text + + def test_positional_only_and_surplus_arguments_are_sanitized( + self, + caplog: pytest.LogCaptureFixture, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + def endpoint(model: str, api_key: str, /, *, timeout: int = 10) -> None: + pass + + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + print_args_passed_to_litellm( + endpoint, ("synthetic-model", self.FAKE_API_KEY, self.FAKE_API_KEY), {"timeout": 2} + ) + assert self.FAKE_API_KEY not in caplog.text + assert "litellm.endpoint('synthetic-model', 'REDACTED', 'REDACTED', timeout=2)" in caplog.text + def _verbose_request_line(self, capsys, monkeypatch, **kwargs) -> str: monkeypatch.setattr(litellm, "set_verbose", True) monkeypatch.setattr("litellm._logging.set_verbose", True) From d91c66bcd7d8ab0b80c10c77abd146bb925eab98 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Tue, 27 Oct 2026 13:07:32 +0800 Subject: [PATCH 10/15] fix: avoid recursion in request log signature detection --- litellm/utils.py | 10 +++-- .../test_text_to_speech_transformation.py | 9 +++- tests/unit/test_utils.py | 45 +++++++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index a403300fe93..1923b67a648 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -8541,19 +8541,23 @@ def get_valid_models( return [] # NON-Blocking -def _request_logging_parameters(original_function: Callable[..., object]) -> tuple[str, ...]: +def _positional_request_parameter_names(original_function: Callable[..., object]) -> tuple[str, ...]: parameters: Final = inspect.signature(original_function).parameters.values() - positional: Final = tuple( + return tuple( parameter.name for parameter in parameters if parameter.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD) ) + + +def _request_logging_parameters(original_function: Callable[..., object]) -> tuple[str, ...]: + positional: Final = _positional_request_parameter_names(original_function) if positional or not inspect.iscoroutinefunction(original_function): return positional if original_function.__name__.startswith("a"): synchronous: Final = getattr(inspect.getmodule(original_function), original_function.__name__[1:], None) if callable(synchronous) and not inspect.iscoroutinefunction(synchronous): - return _request_logging_parameters(synchronous) + return _positional_request_parameter_names(synchronous) return () diff --git a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py index c60ba4bff82..c2d5fba1340 100644 --- a/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py +++ b/tests/unit/llms/flowspeech/test_text_to_speech_transformation.py @@ -232,7 +232,9 @@ def test_gateway_base_preserves_prefix_without_duplicating_endpoint(base, expect @pytest.mark.parametrize("prefix", ["/p%2Fq", "/p%2fq", "/p%252Fq", "/p%3Fq", "/p%23q"]) @pytest.mark.parametrize("suffix", ["/", "/api/v1/tts/jobs", "/api/v1/tts/jobs/"]) def test_gateway_prefix_preserves_encoded_path(prefix, suffix): - url = FlowSpeechTextToSpeechConfig().get_complete_url("flowspeech-tts", f"https://gateway.example{prefix}{suffix}", {}) + url = FlowSpeechTextToSpeechConfig().get_complete_url( + "flowspeech-tts", f"https://gateway.example{prefix}{suffix}", {} + ) assert httpx.URL(url).raw_path == f"{prefix}/api/v1/tts/jobs".encode("ascii") assert httpx.URL(url).query == b"" assert httpx.URL(url).fragment == "" @@ -426,7 +428,7 @@ async def test_positional_key_debug_controls( assert request.headers["authorization"] == f"Bearer {SECRET_SENTINEL}" return httpx.Response(400, json={"error": {"code": "synthetic", "message": "synthetic", "retryable": False}}) - with pytest.raises(litellm.BadRequestError if asynchronous else FlowSpeechException) as error: + async def call() -> None: if asynchronous: async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as client: await litellm.aspeech( @@ -437,6 +439,9 @@ async def test_positional_key_debug_controls( litellm.speech( "flowspeech/flowspeech-tts", "Hello", "Kore", SECRET_SENTINEL, client=client, max_retries=0 ) + + with pytest.raises(litellm.BadRequestError if asynchronous else FlowSpeechException) as error: + await call() captured: Final = capsys.readouterr() assert SECRET_SENTINEL not in caplog.text + captured.out + captured.err assert ("Request to litellm:" in caplog.text) is debug diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 8fc72fc748b..b6f97e64049 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -7049,6 +7049,51 @@ class TestVerboseRequestLineRedaction: assert self.FAKE_API_KEY not in caplog.text assert "litellm.opaque('REDACTED', model='synthetic-model')" in caplog.text + @pytest.mark.parametrize("async_prefix", [False, True]) + def test_async_varargs_without_sync_signature_hide_credentials( + self, + async_prefix: bool, + caplog: pytest.LogCaptureFixture, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + async def opaque_async(*args: object, **kwargs: object) -> None: + pass + + async def aopaque(*args: object, **kwargs: object) -> None: + pass + + function: Final = aopaque if async_prefix else opaque_async + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + print_args_passed_to_litellm(function, (self.FAKE_API_KEY,), {"model": "synthetic-model"}) + assert self.FAKE_API_KEY not in caplog.text + assert f"litellm.{function.__name__}('REDACTED', model='synthetic-model')" in caplog.text + + @pytest.mark.parametrize("error_type", [TypeError, ValueError]) + def test_unavailable_signature_hides_all_positional_values( + self, + error_type: type[Exception], + caplog: pytest.LogCaptureFixture, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + class OpaqueCallable: + __name__ = "opaque" + + @property + def __signature__(self) -> inspect.Signature: + raise error_type("signature unavailable") + + def __call__(self, *args: object, **kwargs: object) -> None: + pass + + with caplog.at_level(logging.DEBUG, logger=verbose_logger.name): + print_args_passed_to_litellm( + OpaqueCallable(), (self.FAKE_API_KEY, self.FAKE_API_KEY), {"model": "synthetic-model"} + ) + assert self.FAKE_API_KEY not in caplog.text + assert "litellm.opaque('REDACTED', 'REDACTED', model='synthetic-model')" in caplog.text + def test_positional_only_and_surplus_arguments_are_sanitized( self, caplog: pytest.LogCaptureFixture, From 6e17296938f5c9174f06612bc7d2a54e5b3b0f44 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Tue, 27 Oct 2026 13:16:07 +0800 Subject: [PATCH 11/15] fix: validate request logging headers without unchecked casts --- litellm/litellm_core_utils/sensitive_data_masker.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/sensitive_data_masker.py b/litellm/litellm_core_utils/sensitive_data_masker.py index 6bc411e2319..cc753696fcd 100644 --- a/litellm/litellm_core_utils/sensitive_data_masker.py +++ b/litellm/litellm_core_utils/sensitive_data_masker.py @@ -1,9 +1,9 @@ from collections.abc import ItemsView, Mapping, Sequence from collections.abc import Set as AbstractSet from dataclasses import dataclass, field -from typing import Any, Final, cast +from typing import Any, Final -from pydantic import BaseModel +from pydantic import BaseModel, TypeAdapter from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH, DEFAULT_MAX_RECURSE_DEPTH_SENSITIVE_DATA_MASKER from litellm.litellm_core_utils.secret_redaction import REDACTED @@ -274,6 +274,7 @@ _REQUEST_LOG_HEADER_NAMES: Final = frozenset( "x-correlation-id", ) ) +_REQUEST_LOG_HEADER_ADAPTER: Final = TypeAdapter(Mapping[object, object]) def _redact_request_headers(value: object) -> object: @@ -281,7 +282,7 @@ def _redact_request_headers(value: object) -> object: return None if not isinstance(value, Mapping): return REDACTED - headers: Final = cast(Mapping[object, object], value) # cast-ok: Mapping checked above, keys remain untrusted + headers: Final = _REQUEST_LOG_HEADER_ADAPTER.validate_python(value) if any( not isinstance(name, str) or name.lower() not in _REQUEST_LOG_HEADER_NAMES or not isinstance(item, str) for name, item in headers.items() From d126721bd858e4bf480b44cea72cad37379f1437 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Wed, 28 Oct 2026 12:29:17 +0800 Subject: [PATCH 12/15] fix: validate debug logging inputs at typed boundaries --- litellm/utils.py | 48 +++++++++++++++++++++++------------ tests/unit/test_utils.py | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 16 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 1923b67a648..17d2166e0eb 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1904,7 +1904,15 @@ def client(original_function): return result # Prints Exactly what was passed to litellm function - don't execute any logic here - it should just print - print_args_passed_to_litellm(original_function, args, kwargs) + if is_debugging_on(): + try: + print_args_passed_to_litellm( + original_function, + TypeAdapter(tuple[object, ...]).validate_python(args, strict=True), + TypeAdapter(Mapping[str, object]).validate_python(kwargs, strict=True), + ) + except Exception: + pass start_time: Final = datetime.datetime.now() result = None logging_obj: LiteLLMLoggingObject | None = kwargs.get("litellm_logging_obj", None) @@ -2173,7 +2181,15 @@ def client(original_function): @wraps(original_function) async def wrapper_async(*args, **kwargs): - print_args_passed_to_litellm(original_function, args, kwargs) + if is_debugging_on(): + try: + print_args_passed_to_litellm( + original_function, + TypeAdapter(tuple[object, ...]).validate_python(args, strict=True), + TypeAdapter(Mapping[str, object]).validate_python(kwargs, strict=True), + ) + except Exception: + pass start_time: Final = datetime.datetime.now() call_type: Final = _get_call_type_from_public_name(original_function.__name__) result = None @@ -8574,30 +8590,30 @@ def _redact_positional_request_args( return tuple(redacted[name] for name in names[: len(args)]) + (REDACTED,) * max(0, len(args) - len(names)) -def print_args_passed_to_litellm( - original_function: Callable[..., object], args: tuple[object, ...], kwargs: Mapping[str, object] -) -> None: +def print_args_passed_to_litellm(original_function: Callable[..., object], args: object, kwargs: object) -> None: if not is_debugging_on(): return try: + request_args: Final = TypeAdapter(tuple[object, ...]).validate_python(args, strict=True) + request_kwargs: Final = TypeAdapter(Mapping[str, object]).validate_python(kwargs, strict=True) # we've already printed this for acompletion, don't print for completion if ( - "acompletion" in kwargs - and kwargs["acompletion"] is True + "acompletion" in request_kwargs + and request_kwargs["acompletion"] is True and original_function.__name__ == "completion" - or "aembedding" in kwargs - and kwargs["aembedding"] is True + or "aembedding" in request_kwargs + and request_kwargs["aembedding"] is True and original_function.__name__ == "embedding" or ( - "aimg_generation" in kwargs - and kwargs["aimg_generation"] is True + "aimg_generation" in request_kwargs + and request_kwargs["aimg_generation"] is True and original_function.__name__ == "img_generation" ) ): return - args_str: Final = ", ".join(map(repr, _redact_positional_request_args(original_function, args))) - redacted_kwargs: Final = redact_credentials_in_request(kwargs) + args_str: Final = ", ".join(map(repr, _redact_positional_request_args(original_function, request_args))) + redacted_kwargs: Final = redact_credentials_in_request(request_kwargs) kwargs_str: Final = ", ".join(f"{key}={value!r}" for key, value in redacted_kwargs.items()) print_verbose( "\n", @@ -8605,11 +8621,11 @@ def print_args_passed_to_litellm( print_verbose( "\033[92mRequest to litellm:\033[0m", ) - if args and kwargs: + if request_args and request_kwargs: print_verbose(f"\033[92mlitellm.{original_function.__name__}({args_str}, {kwargs_str})\033[0m") - elif args: + elif request_args: print_verbose(f"\033[92mlitellm.{original_function.__name__}({args_str})\033[0m") - elif kwargs: + elif request_kwargs: print_verbose(f"\033[92mlitellm.{original_function.__name__}({kwargs_str})\033[0m") else: print_verbose(f"\033[92mlitellm.{original_function.__name__}()\033[0m") diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index b6f97e64049..047518512b2 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -6947,6 +6947,61 @@ class TestVerboseRequestLineRedaction: FAKE_API_KEY: Final = "sk-fake-lit6823-0000000000000000" + @pytest.mark.parametrize("verbose", [False, True]) + @pytest.mark.parametrize( + "args, kwargs", + [ + (["synthetic-model", "SYNTHETIC-BOUNDARY-SECRET"], {"api_key": "SYNTHETIC-BOUNDARY-SECRET"}), + ("SYNTHETIC-BOUNDARY-SECRET", {"model": "synthetic-model"}), + (None, {"api_key": "SYNTHETIC-BOUNDARY-SECRET"}), + ((), [("api_key", "SYNTHETIC-BOUNDARY-SECRET")]), + ((), {123: "SYNTHETIC-BOUNDARY-SECRET"}), + ((), {b"api_key": "SYNTHETIC-BOUNDARY-SECRET"}), + ], + ) + def test_malformed_request_containers_do_not_emit_or_raise( + self, + args: object, + kwargs: object, + verbose: bool, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + monkeypatch.setattr(litellm, "set_verbose", verbose) + monkeypatch.setattr("litellm._logging.set_verbose", verbose) + with caplog.at_level(logging.DEBUG if not verbose else logging.WARNING, logger=verbose_logger.name): + print_args_passed_to_litellm(litellm.completion, args, kwargs) + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert "litellm.completion(" not in output + assert "SYNTHETIC-BOUNDARY-SECRET" not in output + + def test_disabled_logging_does_not_validate_or_emit_request_containers( + self, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + ) -> None: + from litellm.utils import print_args_passed_to_litellm + + adapter: Final = Mock(side_effect=RuntimeError("Disabled logging constructed a validator")) + monkeypatch.setattr(litellm, "set_verbose", False) + monkeypatch.setattr("litellm._logging.set_verbose", False) + with monkeypatch.context() as validation: + validation.setattr("litellm.utils.TypeAdapter", adapter) + with caplog.at_level(logging.WARNING, logger=verbose_logger.name): + print_args_passed_to_litellm( + litellm.completion, (self.FAKE_API_KEY,), {"api_key": self.FAKE_API_KEY} + ) + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert adapter.call_count == 0 + assert "litellm.completion(" not in output + assert self.FAKE_API_KEY not in output + @pytest.mark.parametrize( "function_name", ["speech", "aspeech", "embedding", "aembedding", "completion", "acompletion"] ) From 875c97e5495de047f6d95fdd1854f076c7ef2a66 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Wed, 28 Oct 2026 13:10:43 +0800 Subject: [PATCH 13/15] fix: narrow debug logging validation error handling --- litellm/utils.py | 8 +-- tests/unit/test_utils.py | 121 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 4 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 17d2166e0eb..456df4f19ac 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1911,8 +1911,8 @@ def client(original_function): TypeAdapter(tuple[object, ...]).validate_python(args, strict=True), TypeAdapter(Mapping[str, object]).validate_python(kwargs, strict=True), ) - except Exception: - pass + except (TypeError, ValueError): + print_verbose("Skipped malformed request debug logging") start_time: Final = datetime.datetime.now() result = None logging_obj: LiteLLMLoggingObject | None = kwargs.get("litellm_logging_obj", None) @@ -2188,8 +2188,8 @@ def client(original_function): TypeAdapter(tuple[object, ...]).validate_python(args, strict=True), TypeAdapter(Mapping[str, object]).validate_python(kwargs, strict=True), ) - except Exception: - pass + except (TypeError, ValueError): + print_verbose("Skipped malformed request debug logging") start_time: Final = datetime.datetime.now() call_type: Final = _get_call_type_from_public_name(original_function.__name__) result = None diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 047518512b2..f514cfe2b2a 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -23,6 +23,7 @@ import httpx import pytest import respx from jsonschema import Draft7Validator, validate +from pydantic import ValidationError import litellm from litellm.exceptions import MidStreamFallbackError @@ -7002,6 +7003,126 @@ class TestVerboseRequestLineRedaction: assert "litellm.completion(" not in output assert self.FAKE_API_KEY not in output + @pytest.mark.asyncio + @pytest.mark.parametrize("asynchronous", [False, True]) + @pytest.mark.parametrize("verbose", [False, True]) + @pytest.mark.parametrize("stage", ["args", "kwargs"]) + @pytest.mark.parametrize("error_type", [TypeError, ValueError, ValidationError]) + async def test_shape_validation_failure_keeps_mock_operation_and_drops_error_details( + self, + asynchronous: bool, + verbose: bool, + stage: str, + error_type: type[Exception], + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + ) -> None: + from pydantic import TypeAdapter + + rendered: Final = Mock() + + class UnrenderedInput: + def __repr__(self) -> str: + rendered() + return "SYNTHETIC-INPUT-REPR" + + signed_url: Final = "https://audio.example.test/result.wav?sig=SYNTHETIC-URL-SECRET" + diagnostic: Final = f"SYNTHETIC-INPUT-REPR {self.FAKE_API_KEY} {signed_url}" + unrendered: Final = UnrenderedInput() + + def fail_validation(value: object, *, strict: bool) -> None: + assert strict is True + assert isinstance(value, tuple if stage == "args" else dict) + if error_type is ValidationError: + TypeAdapter(int).validate_python({"diagnostic": diagnostic, "input": unrendered}, strict=True) + pytest.fail("Expected a real Pydantic validation failure") + raise error_type(diagnostic, unrendered) + + broken: Final = Mock() + broken.validate_python.side_effect = fail_validation + + def adapter_factory(annotation: object) -> object: + if annotation == (tuple[object, ...] if stage == "args" else Mapping[str, object]): + return broken + return TypeAdapter(annotation) + + monkeypatch.setattr(litellm, "set_verbose", verbose) + monkeypatch.setattr("litellm._logging.set_verbose", verbose) + with monkeypatch.context() as validation: + validation.setattr("litellm.utils.TypeAdapter", adapter_factory) + with caplog.at_level(logging.DEBUG if not verbose else logging.WARNING, logger=verbose_logger.name): + response: Final = ( + await litellm.acompletion( + model="openai/synthetic-model", + messages=[{"role": "user", "content": "synthetic input"}], + api_key=self.FAKE_API_KEY, + mock_response="synthetic output", + ) + if asynchronous + else litellm.completion( + model="openai/synthetic-model", + messages=[{"role": "user", "content": "synthetic input"}], + api_key=self.FAKE_API_KEY, + mock_response="synthetic output", + ) + ) + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert response.choices[0].message.content == "synthetic output" + assert broken.validate_python.call_count >= 1 + assert rendered.call_count == 0 + assert "Skipped malformed request debug logging" in output + assert self.FAKE_API_KEY not in output + assert signed_url not in output + assert "SYNTHETIC-INPUT-REPR" not in output + assert all(record.exc_info is None for record in caplog.records) + + @pytest.mark.asyncio + @pytest.mark.parametrize("asynchronous", [False, True]) + async def test_disabled_wrapper_logging_does_not_construct_shape_validators( + self, + asynchronous: bool, + caplog: pytest.LogCaptureFixture, + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + ) -> None: + from pydantic import TypeAdapter + + constructed: Final = Mock() + + def adapter_factory(annotation: object) -> object: + if annotation in (tuple[object, ...], Mapping[str, object]): + constructed(annotation) + return TypeAdapter(annotation) + + monkeypatch.setattr(litellm, "set_verbose", False) + monkeypatch.setattr("litellm._logging.set_verbose", False) + with monkeypatch.context() as validation: + validation.setattr("litellm.utils.TypeAdapter", adapter_factory) + with caplog.at_level(logging.WARNING, logger=verbose_logger.name): + response: Final = ( + await litellm.acompletion( + model="openai/synthetic-model", + messages=[{"role": "user", "content": "synthetic input"}], + api_key=self.FAKE_API_KEY, + mock_response="synthetic output", + ) + if asynchronous + else litellm.completion( + model="openai/synthetic-model", + messages=[{"role": "user", "content": "synthetic input"}], + api_key=self.FAKE_API_KEY, + mock_response="synthetic output", + ) + ) + captured: Final = capsys.readouterr() + output: Final = caplog.text + captured.out + captured.err + assert response.choices[0].message.content == "synthetic output" + assert constructed.call_count == 0 + assert "Skipped malformed request debug logging" not in output + assert self.FAKE_API_KEY not in output + @pytest.mark.parametrize( "function_name", ["speech", "aspeech", "embedding", "aembedding", "completion", "acompletion"] ) From 842f9464c51ce0481d167b8ee66a8ecc65b00b76 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Wed, 28 Oct 2026 15:05:41 +0800 Subject: [PATCH 14/15] fix: synchronize generated FlowSpeech endpoint metadata --- .../provider_endpoints_support_backup.json | 26 +++++++++++++++++++ provider_endpoints_support.json | 16 +++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index f95b553c2b4..cc9eaa221ba 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -904,6 +904,32 @@ "interactions": true } }, + "flowspeech": { + "display_name": "FlowSpeech (`flowspeech`)", + "url": "https://docs.litellm.ai/docs/providers/flowspeech", + "endpoints": { + "chat_completions": false, + "responses": false, + "text_completion": false, + "embeddings": false, + "image_generations": false, + "image_edits": false, + "audio_transcriptions": false, + "audio_speech": true, + "rerank": false, + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": false, + "interactions": false, + "systemone": false, + "a2a": false, + "generateContent": false + } + }, "exa_ai": { "display_name": "Exa AI (`exa_ai`)", "url": "https://docs.litellm.ai/docs/search/exa_ai", diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 5f4f76c5e27..7213182b598 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -1002,17 +1002,25 @@ "url": "https://docs.litellm.ai/docs/providers/flowspeech", "endpoints": { "chat_completions": false, - "messages": false, "responses": false, + "text_completion": false, "embeddings": false, "image_generations": false, + "image_edits": false, "audio_transcriptions": false, "audio_speech": true, - "moderations": false, - "batches": false, "rerank": false, + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": false, + "interactions": false, + "systemone": false, "a2a": false, - "interactions": false + "generateContent": false } }, "exa_ai": { From 78e7cbe2bb21e61da69ea0f441da6a053d87e367 Mon Sep 17 00:00:00 2001 From: waeckerlinfederowicz66-sketch Date: Wed, 28 Oct 2026 15:57:30 +0800 Subject: [PATCH 15/15] fix: apply compatible dependency security patches --- pyproject.toml | 2 +- uv.lock | 144 +++++++++++++++-------------- vscode-extension/package-lock.json | 6 +- 3 files changed, 77 insertions(+), 75 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 817c50df90b..ac3dac8b30b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -291,7 +291,7 @@ ci = [ "anthropic==0.84.0", "blockbuster==1.5.26", "beautifulsoup4==4.14.3", - "pylint==4.0.5", + "pylint==4.0.9", "langchain-openai==1.1.14", "langgraph>=1.2.4,<1.3.0", "langgraph-prebuilt>=1.1.0,<1.3.0", diff --git a/uv.lock b/uv.lock index 531082730bb..e2488e7bc6c 100644 --- a/uv.lock +++ b/uv.lock @@ -5046,7 +5046,7 @@ ci = [ { name = "psycopg2-binary", specifier = "==2.9.11" }, { name = "pyarrow", specifier = "==23.0.1" }, { name = "pygithub", specifier = "==2.8.1" }, - { name = "pylint", specifier = "==4.0.5" }, + { name = "pylint", specifier = "==4.0.9" }, { name = "pytest-codspeed", specifier = "==4.3.0" }, { name = "pytest-retry", specifier = "==1.7.0" }, { name = "tenacity", specifier = "==8.5.0" }, @@ -5815,75 +5815,77 @@ wheels = [ [[package]] name = "msgpack" -version = "1.2.1" +version = "1.2.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/31/f9/c0a1c127f9049db9155afc316952ea571720dd01833ff5e4d7e8e6352dbb/msgpack-1.2.1.tar.gz", hash = "sha256:04c721c2c7448767e9e3f2520a475663d8ee0f09c31890f6d2bd70fd636a9647", size = 183960, upload-time = "2026-06-18T16:13:52.594Z" } +sdist = { url = "https://files.pythonhosted.org/packages/0a/e7/bb605a7bab2d8425a64b3fa762b39dc1bf1c7e3f11ba6fb5413d6db0ff8c/msgpack-1.2.3.tar.gz", hash = "sha256:32edb81a2b5eb7cd7c9d941b2bfbbb082fd2cd09e0e725930316af6b708db186", size = 196517, upload-time = "2026-09-29T02:33:52.276Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/5b/16/f70100614b69feb3ade7285f08c9c52d6cda0a5c03f3f5e2facd63acb211/msgpack-1.2.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8c7b398c56ff125feae96c2737abfec5595f1fa0aa186df60c56040b8accb95c", size = 82926, upload-time = "2026-06-18T16:12:31.531Z" }, - { url = "https://files.pythonhosted.org/packages/e4/3c/08ecd5cdfe4e2de43aec79062028ad0f7b2d9b1fea5430068c198ba570da/msgpack-1.2.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1548006a91aa93c5da81f3bdcebc1a0d10cea2d25969754fbe848da622b2b895", size = 82730, upload-time = "2026-06-18T16:12:32.894Z" }, - { url = "https://files.pythonhosted.org/packages/19/9f/a70c9cb1a04ecc134005149367dcfe35d167284e8f65035a1e4156ad17b5/msgpack-1.2.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1dabedcd0f23559f3596428c6589c1cd8c6eaed3a0d720795b07b0225d769203", size = 400729, upload-time = "2026-06-18T16:12:34.052Z" }, - { url = "https://files.pythonhosted.org/packages/fa/7f/5ce020168cf0439041526e95aa068c722c016aee21624e331aeabeee2e8e/msgpack-1.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:83efa1c898e0fc5380fc0cabbf75164c52e3b5cbb45973710d75821928380c73", size = 407625, upload-time = "2026-06-18T16:12:35.239Z" }, - { url = "https://files.pythonhosted.org/packages/79/70/fb7668ce0386819303047057aef6fc1da73b584291d9cff82b821744e2ef/msgpack-1.2.1-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:01e2dd6c9b19d333a00282330cc8a73d38d8dabc306dc5b42cd668c3ac82e833", size = 377891, upload-time = "2026-06-18T16:12:36.684Z" }, - { url = "https://files.pythonhosted.org/packages/3d/dc/9ebe654a73c3aed2e40aa6b52e3c2a02b5f53ef0085fa235a45d5b367f87/msgpack-1.2.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:350cb813d0af6e65d2f7ef0d729f7ff5be5a8bce03665892f43e5883d4ecc1b8", size = 391987, upload-time = "2026-06-18T16:12:37.839Z" }, - { url = "https://files.pythonhosted.org/packages/42/eb/b67cf64218a2fa25e1c671fe1d3dbb06cbeb973e71bc4b822da079862d0b/msgpack-1.2.1-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:ee1d9ed27d0497b848923746cf762ed2e7db24f4be7eec8e5cbe8c766aa707b7", size = 374603, upload-time = "2026-06-18T16:12:39.221Z" }, - { url = "https://files.pythonhosted.org/packages/a2/2e/9ee200cde32fd1a0101b4006202fde554c1860adfb9bf7bff31ea4c08df8/msgpack-1.2.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:633727297ed063441fd1cda2288865487f33ad14eeb8831afb5f0c396a62cfce", size = 405121, upload-time = "2026-06-18T16:12:40.524Z" }, - { url = "https://files.pythonhosted.org/packages/43/b6/f10117be7ca7a51e8feed699a907b8e663a8cd66e115ae6b4fb30cc7945c/msgpack-1.2.1-cp310-cp310-win32.whl", hash = "sha256:298872ecf9e61950f1c6af4ca969b859ee91783bb920ef6e6172697d0c8aad74", size = 64088, upload-time = "2026-06-18T16:12:41.762Z" }, - { url = "https://files.pythonhosted.org/packages/ba/93/89976c696fb0224662239d952c47b4d1661b34d79a332ef5584facaa8579/msgpack-1.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:2ff164c1b0bcb740b073b99e945234d0212852fa378e44a208c425379140dbeb", size = 70113, upload-time = "2026-06-18T16:12:42.78Z" }, - { url = "https://files.pythonhosted.org/packages/f4/6b/e9b1cdc042c4458801d2545ed782a95f3d6ba8e270cce8745b8603c7f748/msgpack-1.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:29a3f6e9667868429d8240dfd063ea5ffdc1321c13d783aa23827a38de0dcb22", size = 82812, upload-time = "2026-06-18T16:12:45.022Z" }, - { url = "https://files.pythonhosted.org/packages/0c/3a/dd518a1bf78ed1e9ad8afe57307c079a00eafe4b3068932a27ca1ea56b4f/msgpack-1.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aded5bdf32609dc7987a49bbbd15a8ef096193f96dd8bbeb791de729e650acf5", size = 82739, upload-time = "2026-06-18T16:12:46.025Z" }, - { url = "https://files.pythonhosted.org/packages/70/e0/7ba9e1542bf0771a27b8b37c1316e3f95ae9d748fd765284655c476ad4ef/msgpack-1.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:146ee4e9ce80b365c6d4c47073da9da7bcec473e58194ceee5dd7620ace77e06", size = 414233, upload-time = "2026-06-18T16:12:47.029Z" }, - { url = "https://files.pythonhosted.org/packages/03/8d/671d81534ea0e2b0e8a121be100020da09eb78861fe3aa8f3ef7dcd3bed1/msgpack-1.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a28d076ca7c82b9c8728ad90b7147489449557038bed50e4241eb832395169b4", size = 423843, upload-time = "2026-06-18T16:12:48.19Z" }, - { url = "https://files.pythonhosted.org/packages/d2/b6/e5c737515ed1f166664b87601b532f58cbb73d8aa6a90b99f7c2c5037e8e/msgpack-1.2.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:7d31c0ac0c640f877804c67cb2bc9f4e23dc2db97e96c2e67fa27d38283b41f8", size = 390772, upload-time = "2026-06-18T16:12:49.624Z" }, - { url = "https://files.pythonhosted.org/packages/a8/46/62ed8c2e87d7021eab19921594d961ef3aa3794eec76c716dc30f3bfd433/msgpack-1.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8ff92d7feeaf5bc26c51495b69e2f99ed97ab79346fb6555f44be7dd2ac6503b", size = 409559, upload-time = "2026-06-18T16:12:50.936Z" }, - { url = "https://files.pythonhosted.org/packages/70/ff/59aa3887b860bbf43532835e192b1c388a17590d6068ae4f8b2bc74c906e/msgpack-1.2.1-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:779197a6513bab3c3632265e3d0f7cb3227e62510841a6f34f1eaa37efbb345e", size = 387838, upload-time = "2026-06-18T16:12:52.161Z" }, - { url = "https://files.pythonhosted.org/packages/09/11/f8563e471093420cf6478cb3271a0175d8402b82d879783d4035d2d03360/msgpack-1.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:67f6dd22fa72a93752643f07889796d62739a13415ee630169a8ce764f86cf9f", size = 421732, upload-time = "2026-06-18T16:12:53.556Z" }, - { url = "https://files.pythonhosted.org/packages/57/cf/e673683c4c6c90c1022b24c65af4b03eda72b182a1176ef6449069d66acc/msgpack-1.2.1-cp311-cp311-win32.whl", hash = "sha256:91054a783328e0ea7954b8771095705c8d2243b814743fbaadf14552c9c52c5d", size = 64091, upload-time = "2026-06-18T16:12:54.821Z" }, - { url = "https://files.pythonhosted.org/packages/3f/07/ca212739d179f9083bff2c7c08c24101c3555a334fadc2b876b18768a3ae/msgpack-1.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2eda0b7ebb1283a98d3e4492ac933c8af6aff59fd3df1c3ed024f536af4b1dc8", size = 70462, upload-time = "2026-06-18T16:12:55.898Z" }, - { url = "https://files.pythonhosted.org/packages/6d/be/6798347b425e26f35db82e69dd83c09716c856a3714e7bffc4c0860fd830/msgpack-1.2.1-cp311-cp311-win_arm64.whl", hash = "sha256:6ee967f7c7e1df2890c671ff2ee51a28ded0efc95da3e507176dee881ce36c66", size = 65059, upload-time = "2026-06-18T16:12:57.053Z" }, - { url = "https://files.pythonhosted.org/packages/bc/dd/9e8cbd8f5582ca4b590336f2b91ee5662f6a6ca562b565abaf696a0f81ff/msgpack-1.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:2ef59c659f289eddf8aa6623823f19fa2f40a4029266889eac7a2505dd210c35", size = 83531, upload-time = "2026-06-18T16:12:58.249Z" }, - { url = "https://files.pythonhosted.org/packages/50/2e/ebdb85a8da151397a2790363676b7ed7c125924fe618e4c6d8befb0cc62c/msgpack-1.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d3567748a5107cb40cdf66a275430c2f87c07777698f4bfd25c35f44d533258c", size = 82657, upload-time = "2026-06-18T16:12:59.396Z" }, - { url = "https://files.pythonhosted.org/packages/26/aa/753ad8b007b464e1d8aa0c8e650b9c5f4f725e658fc5ac8a7635c55b7f6e/msgpack-1.2.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:60926b75d00c8e816ef98f3034f484a8bc64242d66839cef4cf7e503142316a0", size = 410634, upload-time = "2026-06-18T16:13:00.383Z" }, - { url = "https://files.pythonhosted.org/packages/6a/fd/6adabd4f6d5e686f97dd02ce7fce3fe4cf672cbac36b8f67ff4040e8ad8b/msgpack-1.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:020e881a764b20d8d7ca1a54fc01b8175519d108e3c3f194fddc200bda95951a", size = 419989, upload-time = "2026-06-18T16:13:01.776Z" }, - { url = "https://files.pythonhosted.org/packages/5a/cc/85039b7b0eb168aaad7383a23c97e291a11f08351cb45a606ce865e4e3f1/msgpack-1.2.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:4202c74688ca06591f78cb18988228bd4cca2cc75d57b60008372892d2f1e6e6", size = 377544, upload-time = "2026-06-18T16:13:03.637Z" }, - { url = "https://files.pythonhosted.org/packages/ed/bf/35963899493b32030c85fc513b723ae66144ac70c11ebc52e889e16e3d99/msgpack-1.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8b267ce94efb76fbd1b3373511420074ee3187f0f7811bf394531de13294735a", size = 400842, upload-time = "2026-06-18T16:13:05.012Z" }, - { url = "https://files.pythonhosted.org/packages/a6/df/8e2ac970c8f99264cd9997d1c73df5466bc19da3301d7dc5500862a9b089/msgpack-1.2.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:e4f1d0f8f98ade9634e01fb704a408f9336c0a8f1117b369f5db83dc7551d8b1", size = 374108, upload-time = "2026-06-18T16:13:06.232Z" }, - { url = "https://files.pythonhosted.org/packages/17/dd/fa8bd265110dfa51c20cb529f9e6d240a16fafe7e645004c6af2d01353ba/msgpack-1.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:f02cf17a6ca1abe29b5f980644f7551f94d71f2011509b26d8625ce038f0df64", size = 414939, upload-time = "2026-06-18T16:13:07.478Z" }, - { url = "https://files.pythonhosted.org/packages/2e/b9/8377a5ad8953fc0437c70cc98d9ae29f27fe5ac5109fbec0812085865735/msgpack-1.2.1-cp312-cp312-win32.whl", hash = "sha256:0c0d9802354507bcba62af19c17918e3eb437cc25e6f50657d511b5856a77aac", size = 64504, upload-time = "2026-06-18T16:13:08.822Z" }, - { url = "https://files.pythonhosted.org/packages/57/7f/ce1e377df7e62461fefd9eb23bfb93a4a523f40a517b377b8f844d836828/msgpack-1.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:5c24aa15d5963051e1a5c62b12c50cd705992502b5ec1f3bece6046f33c9fc24", size = 71421, upload-time = "2026-06-18T16:13:09.828Z" }, - { url = "https://files.pythonhosted.org/packages/8f/32/ebfe84c9929f08f188d56c7a2fd913406a9ddad76a634697c1c43b8112e6/msgpack-1.2.1-cp312-cp312-win_arm64.whl", hash = "sha256:4227224aaec8f7fbcbfbd4272319347b2bb4030366502600f8c45588c5187b07", size = 64775, upload-time = "2026-06-18T16:13:11.056Z" }, - { url = "https://files.pythonhosted.org/packages/b0/ac/dcddcab6f6c20ecb387ca5e980371cdb3f87ff69aeca388be97eebc4c074/msgpack-1.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0a70e3cf2804a300d921bb0940426e35f4e489a23adfb77a808892241db0a064", size = 83151, upload-time = "2026-06-18T16:13:12.173Z" }, - { url = "https://files.pythonhosted.org/packages/64/71/fbcfa83a1d6a9c6091942d1cfd070962244664b87427a9a49a6897b1b219/msgpack-1.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:491cc39455ca765fad51fb451bf2915eb2cf41192ab5801ce8d67c1d614fe056", size = 82351, upload-time = "2026-06-18T16:13:13.194Z" }, - { url = "https://files.pythonhosted.org/packages/e3/10/ddf7b06db879e8792d13934ddda09ff20bd2a583fd84c9b59aae9b0e650b/msgpack-1.2.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f310233ef7fb9c14e201c93639fe5f5260b005f56f0b29048e999c30935596cc", size = 407518, upload-time = "2026-06-18T16:13:14.233Z" }, - { url = "https://files.pythonhosted.org/packages/79/d3/36a46a8ed992b781acbc05928bd5bee3c810cb0c3563bf81a7b0c04a1a76/msgpack-1.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:787c9bebb5833e8f6fc8abca3c0597683d8d87f56a8842b6b89c75a5f3176e2d", size = 416405, upload-time = "2026-06-18T16:13:15.435Z" }, - { url = "https://files.pythonhosted.org/packages/f9/84/e8e9598b557c0ba6ddae901a73780a4c75ac667dddf59414b1e56a42fb34/msgpack-1.2.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:dc871b997a9370d855b7394465f2f350e847a5b806dd38dcc9c989e7d87da155", size = 376257, upload-time = "2026-06-18T16:13:17.022Z" }, - { url = "https://files.pythonhosted.org/packages/40/16/738fe6d875ad7e2a9429c165322a4ec088f4f273cdfae63d96a89c467961/msgpack-1.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:85f57e960d877f2977f6430896191b04a21f8901b3b4baf2e4604329f4db5402", size = 397469, upload-time = "2026-06-18T16:13:18.287Z" }, - { url = "https://files.pythonhosted.org/packages/ca/be/6d5952df75a7f24f35833af764c3a6860780364cb3a0030beb8099e1b2b4/msgpack-1.2.1-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:1233ee2dd0cefba127583de50ea654677277047d238303521db35def3d7b2e7c", size = 372802, upload-time = "2026-06-18T16:13:19.685Z" }, - { url = "https://files.pythonhosted.org/packages/e1/39/e2ef7dbf0473bcb8dc7c50bf782a892d67414877b63e47fc88eb189ef5e6/msgpack-1.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e3dc2feb0876209d9c38aa56cb1de169bd6c4348f1aa48271f241226590993e6", size = 411273, upload-time = "2026-06-18T16:13:21.028Z" }, - { url = "https://files.pythonhosted.org/packages/ef/c5/133f4512a56e983a93445c836c9d94d88f3bc2e0980ff4b9e577bd8416ce/msgpack-1.2.1-cp313-cp313-win32.whl", hash = "sha256:6d09badf350af2be9d189184e04e64cf54ad93569ab3d96fca58bd3e84aad707", size = 64471, upload-time = "2026-06-18T16:13:22.293Z" }, - { url = "https://files.pythonhosted.org/packages/e2/98/577e10b055096a7dd40732358cabaf7180a20c79ed1dcdbb618e4b9deac7/msgpack-1.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:33f14fba63278b714efe6ad07e50ea5f03d91537aa6a1c5f1ceca4cf44013ca9", size = 71274, upload-time = "2026-06-18T16:13:23.455Z" }, - { url = "https://files.pythonhosted.org/packages/ba/ee/0c0048e7cfbef23c6a94791b8959ab28155232e7956de8a305b5ff588f05/msgpack-1.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:afc5febcd4c99effbc02b528e49d6fd0760b2b7d48c05239e345a5fa6e743d9a", size = 64795, upload-time = "2026-06-18T16:13:24.687Z" }, - { url = "https://files.pythonhosted.org/packages/77/58/cce442852c6b9e1639c7c8ac8fd9143121cb32dab0f308df4d1426a8eb9c/msgpack-1.2.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:05f340e47e7e47d2da8db9b53e1bb1d294369e9ef45a747441309f6650b8351d", size = 83610, upload-time = "2026-06-18T16:13:25.724Z" }, - { url = "https://files.pythonhosted.org/packages/60/5c/15b4c7a0182f75ffa90751958ba36a9c01cafee367d49a3edc10ed140b01/msgpack-1.2.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:810b916696c86ef0deb3b74588480224df4c1b071136c34183e4a2a4284d7ac7", size = 83138, upload-time = "2026-06-18T16:13:26.781Z" }, - { url = "https://files.pythonhosted.org/packages/b8/a6/99e58722feaffc5f2fbcc0c8c0d1451ab9f84097f7af87291b46af2390f4/msgpack-1.2.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ca0dacff965c47afdc3749a8469d7302a8f801d6a28758d55120d75e66ce6889", size = 406090, upload-time = "2026-06-18T16:13:28.072Z" }, - { url = "https://files.pythonhosted.org/packages/19/03/8c63e8cf52958534ef688625965ab04c269a6cadd8caef16758b380a821a/msgpack-1.2.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e2bf9280bceb5efca998435904b5d3e9fdbcc11d90dc9df30aec7973252b720", size = 412106, upload-time = "2026-06-18T16:13:29.427Z" }, - { url = "https://files.pythonhosted.org/packages/63/d2/155d9e71b40e41fd934bc0c48b9b2770f22263e1ac20aad8e29fdca7be3f/msgpack-1.2.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:aa6c4be5d1c02a42b066ca6ddb71adf36432868fdcdb6ee87e634e86e0674190", size = 374851, upload-time = "2026-06-18T16:13:30.631Z" }, - { url = "https://files.pythonhosted.org/packages/98/48/deaf2326262a8d5ea3295ce9649912ecd3f551ba7ec8e33c665d2ba583f3/msgpack-1.2.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec0e675d59150a6269ddc9139087c722292664a37d071a849c05c473350f1f2d", size = 396168, upload-time = "2026-06-18T16:13:31.977Z" }, - { url = "https://files.pythonhosted.org/packages/10/2a/b4410f906c2ec0008f1608d3ab5143afc3ad3f4e6da0fed3ea2231d0bef4/msgpack-1.2.1-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:dd3bfe82d53edfe4b7fc9a7ec9761e23a7a5b1dac22264505af428253c29ed24", size = 371959, upload-time = "2026-06-18T16:13:33.282Z" }, - { url = "https://files.pythonhosted.org/packages/59/86/1edc67270099a528fa2093ea60fe191233cd238e4bd30cfacf7db79fc959/msgpack-1.2.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5ad5467fc3f68b5468e06c5f788d712e9f8ffc8b0cd1bcb160c105c1ee92dae7", size = 408457, upload-time = "2026-06-18T16:13:34.567Z" }, - { url = "https://files.pythonhosted.org/packages/82/90/8b630fef07d8c5ab457b71ff2c217910c83d333c7a68472c186e87cc504a/msgpack-1.2.1-cp314-cp314-win32.whl", hash = "sha256:98b58bdb89c46190e4609bb36abe17c6d4105ad13f9c5f8f6f64d320f8ced3fb", size = 65942, upload-time = "2026-06-18T16:13:36.056Z" }, - { url = "https://files.pythonhosted.org/packages/16/f1/467b81e98b24dd3885d7b1857728797b4ffc76a7a7483af4fb321a07de3c/msgpack-1.2.1-cp314-cp314-win_amd64.whl", hash = "sha256:74847557e28ce71bd3c438a447ca90e4b507e997ddbdef8a12a7b283b86c156b", size = 72627, upload-time = "2026-06-18T16:13:37.079Z" }, - { url = "https://files.pythonhosted.org/packages/a7/1d/5d8c4c89985feb6acefb82a09e501c60392261856d2408d20bfe4f0360b1/msgpack-1.2.1-cp314-cp314-win_arm64.whl", hash = "sha256:b50b727bd652bdc37d950336c848ef20ec54a4cafc38dce19b1cd86ad625d0f7", size = 66908, upload-time = "2026-06-18T16:13:38.23Z" }, - { url = "https://files.pythonhosted.org/packages/1b/02/ad2afb678b4de94496cd432b581759b756a92c1192d8c767edd6b132efdc/msgpack-1.2.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:8d00f177ca88a77c1cf848d204a38f249751650b601cb6532acc68805d8a8273", size = 86000, upload-time = "2026-06-18T16:13:39.44Z" }, - { url = "https://files.pythonhosted.org/packages/54/74/0b797484013128837f3b1cbb6cea019277c4de4e377dc512b4d9a0f92940/msgpack-1.2.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:5bb9c386f0a329c035ddbab4b72d1028bf9627add8dda41070288563d57ed1b1", size = 86544, upload-time = "2026-06-18T16:13:40.447Z" }, - { url = "https://files.pythonhosted.org/packages/a9/b4/b774d7eb95561739907fec675582f83203cf41c597a418c2589b4bfb8e9d/msgpack-1.2.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:20466cca18c49c7292a8984bc15d65857b171e7264bdcb5f96baf8be238791fc", size = 427661, upload-time = "2026-06-18T16:13:41.574Z" }, - { url = "https://files.pythonhosted.org/packages/b2/f9/3243191dc9937e00756c8bc1b0272fed8f23758e43df2a3b46f533e5090f/msgpack-1.2.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:196300e7e5d6e74d50f1607ab9c06c4a1484c383cd22defd727902591f7e8dde", size = 426375, upload-time = "2026-06-18T16:13:42.936Z" }, - { url = "https://files.pythonhosted.org/packages/23/c7/1693111db9944ba4ad4b67a1e788400d78a0b6af7a6523dc7e4e58f8274b/msgpack-1.2.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:575957e79cd51903a4e8495a242442949641e08f1efd5197b43bebd3ea7682b4", size = 380495, upload-time = "2026-06-18T16:13:44.306Z" }, - { url = "https://files.pythonhosted.org/packages/3e/2b/92f86956a0c13e8662f7e2ad630c4eb4db07497b967589bd5245e018b2c1/msgpack-1.2.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8c2ed1e48cc0f460bf3c7780e7137ff21a4e18433451916f2442c1b21036cd7d", size = 410897, upload-time = "2026-06-18T16:13:45.629Z" }, - { url = "https://files.pythonhosted.org/packages/da/ea/1479f72d200313a76fc2f823a79d1e07ed052ab7b8a0280640aa7b95de42/msgpack-1.2.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:5f6277e5f783c36786a145e0247fc189a03f35f84b251646e53592d2bc12b355", size = 378519, upload-time = "2026-06-18T16:13:46.998Z" }, - { url = "https://files.pythonhosted.org/packages/f5/4d/fa006060ffa1011d32bfae826fe766fe73e02982183601633b7121058ab3/msgpack-1.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f9389552ecf4784886345ead0647e4edc96bee37cbab05b75540f542f766c48c", size = 419815, upload-time = "2026-06-18T16:13:48.205Z" }, - { url = "https://files.pythonhosted.org/packages/2f/e1/aab6c946570496b78e67804721f3d5e2d62a93081b9b37df77764ef56347/msgpack-1.2.1-cp314-cp314t-win32.whl", hash = "sha256:c1c79a604a2969a868a78b6ebd27a887e00c624f14f66b3038e0590cb23332d1", size = 70914, upload-time = "2026-06-18T16:13:49.385Z" }, - { url = "https://files.pythonhosted.org/packages/13/0a/e608956488a2af014cfe6e3d665e090b8ee42aa14b07f8f95b8880d66b09/msgpack-1.2.1-cp314-cp314t-win_amd64.whl", hash = "sha256:f12038a35fabd52e56a3547bab42401af49a45caa6dd00b34c44de235bc93ee2", size = 77999, upload-time = "2026-06-18T16:13:50.467Z" }, - { url = "https://files.pythonhosted.org/packages/d2/8a/27e2e57055176e366a46b85d02d68e7a5bcfbdd8474c9706375d965f24d3/msgpack-1.2.1-cp314-cp314t-win_arm64.whl", hash = "sha256:0adcf06ffde0777c0e1a9b771a2b1c4226ba1bbf748c8efcc02fcdeca3299107", size = 71160, upload-time = "2026-06-18T16:13:51.498Z" }, + { url = "https://files.pythonhosted.org/packages/6d/aa/5b6b09f835791045282dc5d08431db599a5f4743a69fe2f6670045a2cd85/msgpack-1.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ec0030361cc861ac699b2ef1c695b741fa145c88f8667fa3d7e3f73deeb648a3", size = 90927, upload-time = "2026-09-29T02:31:28.286Z" }, + { url = "https://files.pythonhosted.org/packages/c9/91/7b288e9133bd1ba92ca0ca4e7f2a4cfc53cf467d99d8d2f57b9939908fac/msgpack-1.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5c1efdd9181cb1b719ee46865f368a927f1c0c65d577798340b1194545b7515a", size = 89798, upload-time = "2026-09-29T02:31:30.028Z" }, + { url = "https://files.pythonhosted.org/packages/71/9b/5c3dbc450d14645dcec987970692d6ab24008cc33d2155474b1d818486f9/msgpack-1.2.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c309a7abae1d14ba29a8bd0ddbd704a5e469d8e9bd9c3dee0e4ff53d7ae01d56", size = 450687, upload-time = "2026-09-29T02:31:32.407Z" }, + { url = "https://files.pythonhosted.org/packages/2b/21/ea60a8fd0d9e0897fce823e9fd9bf6742567784b35c7eee8f4a18a56eb19/msgpack-1.2.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5bf390259cb25a6a1cd197c65810999b811f64cd38683251538bcc5a1e41f7d3", size = 459808, upload-time = "2026-09-29T02:31:34.282Z" }, + { url = "https://files.pythonhosted.org/packages/ee/f7/42140e6afdac8e94bfedae4cfb67ee004b6ad5c4cadd024df42f759bf3b5/msgpack-1.2.3-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:39b6986c19e1f2dfa549d185dba6ccf1de2e4c0ba10d8cfc0048935b1c5f9109", size = 423845, upload-time = "2026-09-29T02:31:35.713Z" }, + { url = "https://files.pythonhosted.org/packages/19/7b/cd54f27b59dfbdc438a12361fbb6798b66d377a978f946bc9512598290e9/msgpack-1.2.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:fcc6800daac4922960f6eeb7a0dda3dd4105e0bf7bce0e83ebc465a78cb7bdba", size = 445608, upload-time = "2026-09-29T02:31:37.65Z" }, + { url = "https://files.pythonhosted.org/packages/57/38/52bc0dc44cc9f7c2339b632f93d02f8badc78cfb0bb070f2a50a51945e53/msgpack-1.2.3-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:968583e956d0427878050b371308c5f8647088732ef3e66a117dbe1192ec91e0", size = 421721, upload-time = "2026-09-29T02:31:39.151Z" }, + { url = "https://files.pythonhosted.org/packages/89/e6/451c9a42274fb2be82d8ba8b76a5219c613e20f8de1da521d10cb758a9ef/msgpack-1.2.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1d6bcec3dbbdb89ca385d3a73e63ceae7b841fa0d7ca7c676f1a7bfe7fb2cdb8", size = 460430, upload-time = "2026-09-29T02:31:40.843Z" }, + { url = "https://files.pythonhosted.org/packages/57/bb/663e3100327b58caaa5fb66379e557a2717dac08bb586f22f885756bee47/msgpack-1.2.3-cp310-cp310-win32.whl", hash = "sha256:a6b63917d60d6df451f328bd6afba8565e33c4afe1f62ec4ad758b78731c827b", size = 67987, upload-time = "2026-09-29T02:31:42.157Z" }, + { url = "https://files.pythonhosted.org/packages/28/7a/a00d5d7abc5601099260e0d0af8fadc54fbfac2191315aa56eaee3641d9d/msgpack-1.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:4c0780095871ecc49a58b2ff6b1b43b25214704da67646557ca287a3f49fb2dd", size = 75572, upload-time = "2026-09-29T02:31:43.544Z" }, + { url = "https://files.pythonhosted.org/packages/2a/95/b9c651ccb9d720b2e2c8d537954dff528ab869a03bf89598145716db823c/msgpack-1.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ec90a9ae3e1169fa1171147340f0e97d941aa19fcd3b34e8339a55933ed042af", size = 90404, upload-time = "2026-09-29T02:31:44.826Z" }, + { url = "https://files.pythonhosted.org/packages/50/cd/fc9e2e367e80f1493e2ec5f610dda558b344eeede296f88976db133e8f2c/msgpack-1.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9d7e9cbb0998bbfd363fd9a09c330520d5e9cb323c05b5a1a05865d23ccf2226", size = 89683, upload-time = "2026-09-29T02:31:46.413Z" }, + { url = "https://files.pythonhosted.org/packages/19/9e/1028485c6886c1c117f777cc9b053e541eff0fedb3292dfb1da95040edb5/msgpack-1.2.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6707d2fa2aa1bb5424ea0b05f44ffc989b15ab41a73ff5855bff4944fec7c8ac", size = 465347, upload-time = "2026-09-29T02:31:47.934Z" }, + { url = "https://files.pythonhosted.org/packages/aa/83/800570e6a22376eb8d599920f70aead4779a63611696f567477c4e85a70f/msgpack-1.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:382b219de3d436de3baba0f4b0c6d4336e8f5858d0eb047918b13b69a71c6c55", size = 477820, upload-time = "2026-09-29T02:31:49.479Z" }, + { url = "https://files.pythonhosted.org/packages/ab/ff/817e4a2052f848d3fb67726908d6e4e7c19f68ee7c19553a82ce7b0ed415/msgpack-1.2.3-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:186e6c602b8a9968b8e864c67d622a69279f7d1e55ae25f40e3bff7e815b2b62", size = 436656, upload-time = "2026-09-29T02:31:51.18Z" }, + { url = "https://files.pythonhosted.org/packages/3d/42/040cc55dde6a7d92057baac8d1fc9cfb9f4fd4162900e2ec16dc33917a7d/msgpack-1.2.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:9276ba88891338f2617044429dfd080ae008c9868a25f6f1a7d004a35dc9ac0a", size = 460939, upload-time = "2026-09-29T02:31:53.026Z" }, + { url = "https://files.pythonhosted.org/packages/09/93/4dc007bdef930eed247346773bc0189b710078961d3218d5ee7ba59f322c/msgpack-1.2.3-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:c942c21a93f36b3a69e828c8945bb72c94dc2ffe488a2086950c812f3edf046c", size = 433608, upload-time = "2026-09-29T02:31:54.981Z" }, + { url = "https://files.pythonhosted.org/packages/c0/97/a1b944046f283ec89445cb2a982c42233b5b07cc630f9be739f4f1d469a3/msgpack-1.2.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:18a6ed513023001b28dcd3ba54966f6bb90a38274ba8d2640464bcab3a1b81d4", size = 477373, upload-time = "2026-09-29T02:31:56.713Z" }, + { url = "https://files.pythonhosted.org/packages/59/79/ab411d0d172743732ab2503f4c32a22dd1a7d1436a6feecbb160e4b6376a/msgpack-1.2.3-cp311-cp311-win32.whl", hash = "sha256:d0238cd05dec9ffbe0de1071df685ba63e30a36ac155285b1a094e727c38cbe9", size = 67514, upload-time = "2026-09-29T02:31:58.267Z" }, + { url = "https://files.pythonhosted.org/packages/63/8d/6f0cb2b84e484e96278455c26870196d025bb0cec312b226a663f1fa9000/msgpack-1.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:30e1522e4173230dca4d9ad896f038f73c0da6c1edd42f4dbad88ac583cf5d46", size = 75850, upload-time = "2026-09-29T02:31:59.449Z" }, + { url = "https://files.pythonhosted.org/packages/aa/25/f99e13a2c1d3f5a1dcaa5aab27f474e8c4358188bbc68ad79fecb0d1aefe/msgpack-1.2.3-cp311-cp311-win_arm64.whl", hash = "sha256:8ca67f77938ea6a3663aa9bd22b3e031f6da84d665be850abab910ee90728dfd", size = 72338, upload-time = "2026-09-29T02:32:00.885Z" }, + { url = "https://files.pythonhosted.org/packages/af/12/4d7c6d6203416d9fbf0f59ebaa805e70fb929b93a41b611bc821ec5964a0/msgpack-1.2.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:89c930aece4e972b208ba589c8410b4167b05e411a5ea2cb25fd96f8bc47ee43", size = 91577, upload-time = "2026-09-29T02:32:02.141Z" }, + { url = "https://files.pythonhosted.org/packages/eb/c7/8576ad39f4ca42ddad26f68eb8621d2d0a60501193d480f504bd9d7f36c4/msgpack-1.2.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:905a189853d6bdb204c7ae5f4ab77fb857448abfff574d3d93c62e2815b24b4f", size = 90027, upload-time = "2026-09-29T02:32:03.508Z" }, + { url = "https://files.pythonhosted.org/packages/0a/3a/aa9c580aea1314529a0f3562461479780b0d254b064f0880956bfbcc74a8/msgpack-1.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f3d7b3d0018746b5997dd6b14a1870b07cc4c327d9101145d94a1fc264a51a06", size = 460343, upload-time = "2026-09-29T02:32:04.906Z" }, + { url = "https://files.pythonhosted.org/packages/3a/cf/9c2e4d6c179529d5bf4a64cff76fa581486569e9fbdd35bd98f51cb624bf/msgpack-1.2.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ede33b2892ceb976283e009ad12fa1834cfdf1f9c43ee9c97849fc588d00a618", size = 472998, upload-time = "2026-09-29T02:32:06.69Z" }, + { url = "https://files.pythonhosted.org/packages/7b/41/915c81fe6df2d3cbdb0dece4f1a5cd313e1cd2abd9f501d0f50c0582517e/msgpack-1.2.3-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:666ef5601ab0e6e345e47febc96aa81143cc932201543480cbb9499164f05ffb", size = 423216, upload-time = "2026-09-29T02:32:08.739Z" }, + { url = "https://files.pythonhosted.org/packages/a2/e7/7dda8b1039abfd9bba4c5068172c67135c9e33089f503512db9226f23c24/msgpack-1.2.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:87cf2ef05ff2f2493ba29fcdaef27e960ca64dacfd13460ae29e6f92e0ed05bb", size = 451218, upload-time = "2026-09-29T02:32:10.517Z" }, + { url = "https://files.pythonhosted.org/packages/16/5b/ce995c1ed4a0522b7f2d034bc2034fd63005f240b945961b70fb56fbaf3d/msgpack-1.2.3-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:b774ff994d844e541439ac5d2d49a14def4104830c3465e9394c153f86200ffb", size = 422453, upload-time = "2026-09-29T02:32:11.956Z" }, + { url = "https://files.pythonhosted.org/packages/d2/3f/ce191fb87e2650d0166b34c437e499ee4a7f9db9c1eb164f41725eb6160e/msgpack-1.2.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:eaf7e82249837e3aa97297b34a0bb9ff562027381631e057cea6e1367f10b438", size = 469003, upload-time = "2026-09-29T02:32:13.663Z" }, + { url = "https://files.pythonhosted.org/packages/42/35/539123407fe200fb16609c835675496fbeb6017ace9fc93909f0613223ae/msgpack-1.2.3-cp312-cp312-win32.whl", hash = "sha256:7c047250096f9fc19dba26e3d1639b5e7a84114003605c94def667149a70ced1", size = 68303, upload-time = "2026-09-29T02:32:15.02Z" }, + { url = "https://files.pythonhosted.org/packages/6f/4c/331b45f9b86fbda6b9e103244d189068e51f726d8c40021ed66e1f2c415e/msgpack-1.2.3-cp312-cp312-win_amd64.whl", hash = "sha256:3ec409b0d6aa8e9eec6eaf881b893caa215dbe68c5319ca96e8a271d81bb111d", size = 76744, upload-time = "2026-09-29T02:32:16.344Z" }, + { url = "https://files.pythonhosted.org/packages/13/9f/fb572dc42b9fac06c7ea848aaee6e140d84469743bd1402bc07089fc4566/msgpack-1.2.3-cp312-cp312-win_arm64.whl", hash = "sha256:59612b4ed48a04cf024584218e813562f3b30a3bafa5f55abe300b15da314751", size = 71580, upload-time = "2026-09-29T02:32:17.617Z" }, + { url = "https://files.pythonhosted.org/packages/1f/8b/3824d65e912e925d09ce30d9130fa9970d6d2855d7888b13639a6604967f/msgpack-1.2.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:21bfa4d2aa0b04c1806ef778a1199e9e53ea2441bcbf284420a32083896320b8", size = 91728, upload-time = "2026-09-29T02:32:18.949Z" }, + { url = "https://files.pythonhosted.org/packages/05/e6/df7f2c9ebb94760113debbcea2bd3afe5fdab88a4f7bec1b618755517460/msgpack-1.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:db84203b13aecc222f465061397fdd5b53b7ae73d2c95ffc1c8dc5be0153a709", size = 89955, upload-time = "2026-09-29T02:32:20.224Z" }, + { url = "https://files.pythonhosted.org/packages/08/6a/e5fc57136e8bacccb2b39627dea2cd546540a06181e22fe6db90e15b3ae4/msgpack-1.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5e0d7950ca3c1bbae291d0552dd3bb2792fc680629c4c0d44e47e5bab969f3ca", size = 454930, upload-time = "2026-09-29T02:32:21.771Z" }, + { url = "https://files.pythonhosted.org/packages/b0/30/c394d37898db9212d1693456cdf363c7e1a097d0b63e10664007f3df3ec1/msgpack-1.2.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:07c9733089d1b176c3dd2f7fa268452f9d5d784d076473499d754a58e8d1fbbb", size = 466866, upload-time = "2026-09-29T02:32:23.742Z" }, + { url = "https://files.pythonhosted.org/packages/4a/c8/1e4ddf6f6b829b3ee6c530c79dfae89cb609d2b0eedb5e0ae716851c52d1/msgpack-1.2.3-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f24a43b3560e20f825b807fe1e874bd73d53abaf8bbdcf258a6eb152cddbc1f5", size = 418715, upload-time = "2026-09-29T02:32:25.262Z" }, + { url = "https://files.pythonhosted.org/packages/11/a5/f460ba6d7a12d4301002f3efbb8f841e8bdc9c5fc98d771689677a352885/msgpack-1.2.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6576f348ed6cc4f31db6fd915a8e94245f042f50eae08d48732425e70638ea37", size = 446489, upload-time = "2026-09-29T02:32:26.988Z" }, + { url = "https://files.pythonhosted.org/packages/49/23/adface88db909bed321c85dd673655152d4a514c67e1f0800eb51c777d07/msgpack-1.2.3-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:cd5a9f9f86a52c24713679aa2631956835f3842512964ff93f736ff76f1f530d", size = 416998, upload-time = "2026-09-29T02:32:28.606Z" }, + { url = "https://files.pythonhosted.org/packages/36/00/5bb3a239ccfc3763c4d0fa49b13b1b7010b00182c499ab3c1fecfe6294bc/msgpack-1.2.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f9ddd28d3e9bbc602a9dced1591882c7fb9ab776eef8837da2c326fde19e2853", size = 463288, upload-time = "2026-09-29T02:32:30.375Z" }, + { url = "https://files.pythonhosted.org/packages/29/8c/456df77f00d701df9d6980ffb80291bce6e4e2e112e25a4dfae216f0715a/msgpack-1.2.3-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:62cc1a4ef0e553bac32c8342e1f04834aca7de276b92744eb7307db77759b890", size = 53347, upload-time = "2026-09-29T02:32:31.867Z" }, + { url = "https://files.pythonhosted.org/packages/9d/22/ce780be666f89b77cdb855daa9ec62e87bb7f69e9f403e4a5d83a2b2208f/msgpack-1.2.3-cp313-cp313-win32.whl", hash = "sha256:d2f9c4f85e47a44d26d5baf3b041eef23436e224d44eed273f01bd8a12048d9f", size = 68258, upload-time = "2026-09-29T02:32:33.163Z" }, + { url = "https://files.pythonhosted.org/packages/51/06/c3def9bc4db283103c5901b302ee2a4305cb1e69729244f94d9bd8f8e8e7/msgpack-1.2.3-cp313-cp313-win_amd64.whl", hash = "sha256:bb89b5dc30469c84bbf8684826eb851d82412ca95690e111b9ac5e8fb343961a", size = 76569, upload-time = "2026-09-29T02:32:34.412Z" }, + { url = "https://files.pythonhosted.org/packages/12/9f/cef344073858b80adb92d6ea342e20b0eae7a8f6fe70281b69cf03707270/msgpack-1.2.3-cp313-cp313-win_arm64.whl", hash = "sha256:471e12a6a42498a31490c206e0069e343b6a7c35db540be73a879eb06f5be047", size = 71530, upload-time = "2026-09-29T02:32:35.892Z" }, + { url = "https://files.pythonhosted.org/packages/3f/8e/f777f74e38731c428857933c8011596f2d2f3160c821152f23b6ffba862f/msgpack-1.2.3-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:3a31905206722103a84c1f72633fe30692cff6732c9d262e09a27dbc468797c8", size = 92042, upload-time = "2026-09-29T02:32:37.464Z" }, + { url = "https://files.pythonhosted.org/packages/a0/71/551608543ee5d590f7e8d522267665d6d9946866ad2a2a70a770f7c70793/msgpack-1.2.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3372475211a9ce1a23acefe512cb3e121d18c95dc74ed56cb1819ef40836ebf4", size = 90578, upload-time = "2026-09-29T02:32:38.883Z" }, + { url = "https://files.pythonhosted.org/packages/ea/11/6d78ce5a9a58bf9ba7b1b6a8f649173b030e6770c8019cf330b91825ee5d/msgpack-1.2.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9324c54995641c3d1f92a9d55093c8cde0ffa2fbc87a467a688ef60428393220", size = 454352, upload-time = "2026-09-29T02:32:40.34Z" }, + { url = "https://files.pythonhosted.org/packages/3d/08/feb9a196269ba7809f44f9117d9e4a601c41c313f6144fd0c337293a5488/msgpack-1.2.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d8ef3a66e4b52d2d7fdd90df2984670124b2ff7546d76bb25dcf68ef47f7df58", size = 462562, upload-time = "2026-09-29T02:32:42.176Z" }, + { url = "https://files.pythonhosted.org/packages/f5/77/3a674f366def24140b103d1ffd4fd27b3d912a13e47da67422afa16bebb3/msgpack-1.2.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:902f3490db0e07a7d40b48536a85c9b28fbf1397e7e1658a45a55f958e303620", size = 418134, upload-time = "2026-09-29T02:32:43.693Z" }, + { url = "https://files.pythonhosted.org/packages/48/82/944e71f280577490d99a3951cbce21aa4cbe04e7ab42cb373fd668af883c/msgpack-1.2.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8e51eca14fbb65c4e0a5a9657346962bd3dca78c08e04e3d4dee70ef48687d30", size = 445937, upload-time = "2026-09-29T02:32:45.739Z" }, + { url = "https://files.pythonhosted.org/packages/b1/ec/feddd629c4a3edf1395313680450c525086cceab56dec0d4de9da9ccb618/msgpack-1.2.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:f42f146752eedb6765f07dcc04d72dab0a25779ec8d4a88c0085263ce114f22c", size = 416450, upload-time = "2026-09-29T02:32:47.558Z" }, + { url = "https://files.pythonhosted.org/packages/e4/59/263a10f8c4613ba0713f48cbda7695ac8dd6d6fab2fcbc9168f03f23a94d/msgpack-1.2.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:0ed5823c4efc20fe87d3530665f40ec18a002be003114814c21235cc8d256207", size = 459546, upload-time = "2026-09-29T02:32:49.145Z" }, + { url = "https://files.pythonhosted.org/packages/1e/21/addcfa1e583cfc8a22fbdc57526621b5decd7ad676ae12e9150b7be1be5d/msgpack-1.2.3-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:2487453ca1b6104442c6442f9a1a8fee1fe8f428a70d99d4cba799108b304150", size = 53462, upload-time = "2026-09-29T02:32:50.708Z" }, + { url = "https://files.pythonhosted.org/packages/8d/2c/3cb5c8524a1335ee27ca952c7ab78d375a16fea8e18ae3767ba0c880416c/msgpack-1.2.3-cp314-cp314-win32.whl", hash = "sha256:6df430419f2338cb71e4a34d6e64f83c88ccd321f91f40ba4513400b36d864ec", size = 70294, upload-time = "2026-09-29T02:32:52.037Z" }, + { url = "https://files.pythonhosted.org/packages/23/f9/9172ff3cdb85d160ad06df5e2708a5fce7682982a5eee8d31869b9f69d2e/msgpack-1.2.3-cp314-cp314-win_amd64.whl", hash = "sha256:84a6616d396ec1bc18a1e83e67c96a393ec35dfe5e17434a5be7b9aa0fe988ab", size = 77778, upload-time = "2026-09-29T02:32:53.429Z" }, + { url = "https://files.pythonhosted.org/packages/04/e8/b4c23178bcf605ae17cec48a75530dd69d49b0a5a6f5f4df5c47d59f746e/msgpack-1.2.3-cp314-cp314-win_arm64.whl", hash = "sha256:7a003b02c6ee2eea6dfe0bb08818631e3597e69f0131f2a8250488a1cc553290", size = 73794, upload-time = "2026-09-29T02:32:54.763Z" }, + { url = "https://files.pythonhosted.org/packages/66/b1/92704be352c4f428b7e0a0e0fb210cb1aa2b1c42c102b8dc22d34b82fac0/msgpack-1.2.3-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:ccea05b5542f6d283fef3f0a8e93a7f0be90af0ddeeef84c25c0216ba76dcae1", size = 93721, upload-time = "2026-09-29T02:32:56.342Z" }, + { url = "https://files.pythonhosted.org/packages/49/78/9c91f1e86cadcbc100b3780fd429c3715648704032a612e77a00646ebe79/msgpack-1.2.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b1631e12fe572e181cd77e831f69335d6cd5278eac22e3db3f33cf264ac2ac18", size = 94256, upload-time = "2026-09-29T02:32:58.056Z" }, + { url = "https://files.pythonhosted.org/packages/91/4d/270f9725921ae88a29d37a774a77ac24f0ef1411fc960a63f5a4665e81b4/msgpack-1.2.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e54394b7dbe2e12ab032d9d21feef7bb61a90a150a2623633ba3781ba69dcb1f", size = 471673, upload-time = "2026-09-29T02:32:59.886Z" }, + { url = "https://files.pythonhosted.org/packages/48/b8/eaa8d930f72dc1d1dd79511dc2ccf965922b059f2f0ed3b30aebac8c4b11/msgpack-1.2.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63bb7448a1e9111319ae2430c09a5596140c160422830d6271bc75730ff2ff9a", size = 466257, upload-time = "2026-09-29T02:33:01.517Z" }, + { url = "https://files.pythonhosted.org/packages/5b/5a/97adc805037bc7e24c4e2f711bbcd3b28be8ec9aea3e778f18208cfbdb46/msgpack-1.2.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:382bc88fe90f29f5ac8a0b65c7046ff255356f2f2f3186c30e370215736fa1dc", size = 418484, upload-time = "2026-09-29T02:33:03.402Z" }, + { url = "https://files.pythonhosted.org/packages/0d/7e/1c53302606fe436ab48ba539ebafafe4a6a9efe12c4f04dc7eb36912d93e/msgpack-1.2.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c77e27790ad72989db783d5303825fba0b71550f00a490efba35cde7dc4b719f", size = 454064, upload-time = "2026-09-29T02:33:04.977Z" }, + { url = "https://files.pythonhosted.org/packages/00/2d/9ee0170f638907b396c15c6cd26b3e54f869159efc6206683acfd8f696e1/msgpack-1.2.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:700bc0fc9e968a292b9137ee70e7a012f7e115bf0107ce45e3a88202788dfc1e", size = 417901, upload-time = "2026-09-29T02:33:06.489Z" }, + { url = "https://files.pythonhosted.org/packages/cc/d2/905c84490a75cd15a27065407cd085d201f7d392e1e0411f49f03fd31ade/msgpack-1.2.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5bd5f91ea75c45cafcc5433ba8fae59b708b736ec178d2441c40c499e9e079db", size = 459896, upload-time = "2026-09-29T02:33:08.361Z" }, + { url = "https://files.pythonhosted.org/packages/37/cd/4ce5809b9ab3b114d7cca64863e436820fa1614b49d55ccb93d49824ac2d/msgpack-1.2.3-cp314-cp314t-win32.whl", hash = "sha256:7995a7c6a62a1d6e7df211b4a16de513bd99fd053525050a319f80f44fb8015e", size = 75983, upload-time = "2026-09-29T02:33:10.023Z" }, + { url = "https://files.pythonhosted.org/packages/8a/31/853bb580744c24be0dbd8b090c3e6987dce466a1fc840fe50c0ac2ef9044/msgpack-1.2.3-cp314-cp314t-win_amd64.whl", hash = "sha256:bfe7d5b62cbe7aa664f0b3e2c49077f10fcdd06183d3014f8271ff3c5edbfbf9", size = 83757, upload-time = "2026-09-29T02:33:11.441Z" }, + { url = "https://files.pythonhosted.org/packages/0d/49/9f1b2ee484414eef9e21ee2b2b23b482bb71433ab9bac1da03cbda15ebf5/msgpack-1.2.3-cp314-cp314t-win_arm64.whl", hash = "sha256:1f585407f740a9eac04a3bb82c61d68a0ea78f90e29e670bfb086b9ce3a518dd", size = 78128, upload-time = "2026-09-29T02:33:13.063Z" }, ] [[package]] @@ -8162,7 +8164,7 @@ crypto = [ [[package]] name = "pylint" -version = "4.0.5" +version = "4.0.9" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "astroid" }, @@ -8174,9 +8176,9 @@ dependencies = [ { name = "tomli", marker = "python_full_version < '3.11'" }, { name = "tomlkit" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e4/b6/74d9a8a68b8067efce8d07707fe6a236324ee1e7808d2eb3646ec8517c7d/pylint-4.0.5.tar.gz", hash = "sha256:8cd6a618df75deb013bd7eb98327a95f02a6fb839205a6bbf5456ef96afb317c", size = 1572474, upload-time = "2026-02-20T09:07:33.621Z" } +sdist = { url = "https://files.pythonhosted.org/packages/e0/5e/d5ec2c861010cf8577a3e5baaf2405fdf1004f1657d9245c4efb006c1dfd/pylint-4.0.9.tar.gz", hash = "sha256:6f1305780229ae720e89b8aff2b3ff857cbb268fbab98c8b586960267667ad34", size = 1604187, upload-time = "2026-09-23T15:26:43.144Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d5/6f/9ac2548e290764781f9e7e2aaf0685b086379dabfb29ca38536985471eaf/pylint-4.0.5-py3-none-any.whl", hash = "sha256:00f51c9b14a3b3ae08cff6b2cdd43f28165c78b165b628692e428fb1f8dc2cf2", size = 536694, upload-time = "2026-02-20T09:07:31.028Z" }, + { url = "https://files.pythonhosted.org/packages/66/46/12e94ae1f9db89152223bdb17920b12c79e94ac51e19dce1da9fb63627b0/pylint-4.0.9-py3-none-any.whl", hash = "sha256:c4ba5bbaf1e70ecf05f08cd7d6091ea04824b79a2b2d9f5b10dc25fc34cb1124", size = 542068, upload-time = "2026-09-23T15:26:41.626Z" }, ] [[package]] diff --git a/vscode-extension/package-lock.json b/vscode-extension/package-lock.json index 81e9425ef4e..5b749c1d091 100644 --- a/vscode-extension/package-lock.json +++ b/vscode-extension/package-lock.json @@ -2920,9 +2920,9 @@ } }, "node_modules/qs": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", - "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "version": "6.16.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz", + "integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==", "dev": true, "license": "BSD-3-Clause", "dependencies": {