mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix(perf): add missing shared_sessions to audio/transcriptions (#16858)
This took longer than expected because the fake LLM endpoint on railway was deliverying bad performance when deployed due to some issue with railway.
This commit is contained in:
parent
d22ea6f15f
commit
7a84469605
3 changed files with 15 additions and 1 deletions
|
|
@ -1140,6 +1140,7 @@ class BaseLLMHTTPHandler:
|
|||
atranscription: bool = False,
|
||||
headers: Optional[Dict[str, Any]] = None,
|
||||
provider_config: Optional[BaseAudioTranscriptionConfig] = None,
|
||||
shared_session: Optional["ClientSession"] = None,
|
||||
) -> Union[TranscriptionResponse, Coroutine[Any, Any, TranscriptionResponse]]:
|
||||
if provider_config is None:
|
||||
raise ValueError(
|
||||
|
|
@ -1162,6 +1163,7 @@ class BaseLLMHTTPHandler:
|
|||
client=client,
|
||||
headers=headers,
|
||||
provider_config=provider_config,
|
||||
shared_session=shared_session,
|
||||
)
|
||||
|
||||
# Prepare the request
|
||||
|
|
@ -1226,6 +1228,7 @@ class BaseLLMHTTPHandler:
|
|||
client: Optional[Union[HTTPHandler, AsyncHTTPHandler]] = None,
|
||||
headers: Optional[Dict[str, Any]] = None,
|
||||
provider_config: Optional[BaseAudioTranscriptionConfig] = None,
|
||||
shared_session: Optional["ClientSession"] = None,
|
||||
) -> TranscriptionResponse:
|
||||
if provider_config is None:
|
||||
raise ValueError(
|
||||
|
|
@ -1254,6 +1257,7 @@ class BaseLLMHTTPHandler:
|
|||
async_httpx_client = get_async_httpx_client(
|
||||
llm_provider=litellm.LlmProviders(custom_llm_provider),
|
||||
params={"ssl_verify": litellm_params.get("ssl_verify", None)},
|
||||
shared_session=shared_session,
|
||||
)
|
||||
else:
|
||||
async_httpx_client = client
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
from typing import Optional, Union, cast
|
||||
from typing import TYPE_CHECKING, Optional, Union, cast
|
||||
|
||||
import httpx
|
||||
from openai import AsyncOpenAI, OpenAI
|
||||
from pydantic import BaseModel
|
||||
|
||||
import litellm
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from aiohttp import ClientSession
|
||||
from litellm.litellm_core_utils.audio_utils.utils import get_audio_file_name
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
|
||||
from litellm.llms.base_llm.audio_transcription.transformation import (
|
||||
|
|
@ -89,6 +92,7 @@ class OpenAIAudioTranscription(OpenAIChatCompletion):
|
|||
client=None,
|
||||
atranscription: bool = False,
|
||||
provider_config: Optional[BaseAudioTranscriptionConfig] = None,
|
||||
shared_session: Optional["ClientSession"] = None,
|
||||
) -> TranscriptionResponse:
|
||||
"""
|
||||
Handle audio transcription request
|
||||
|
|
@ -116,6 +120,7 @@ class OpenAIAudioTranscription(OpenAIChatCompletion):
|
|||
client=client,
|
||||
max_retries=max_retries,
|
||||
logging_obj=logging_obj,
|
||||
shared_session=shared_session,
|
||||
)
|
||||
|
||||
openai_client: OpenAI = self._get_openai_client( # type: ignore
|
||||
|
|
@ -170,6 +175,7 @@ class OpenAIAudioTranscription(OpenAIChatCompletion):
|
|||
api_base: Optional[str] = None,
|
||||
client=None,
|
||||
max_retries=None,
|
||||
shared_session: Optional["ClientSession"] = None,
|
||||
):
|
||||
try:
|
||||
openai_aclient: AsyncOpenAI = self._get_openai_client( # type: ignore
|
||||
|
|
@ -179,6 +185,7 @@ class OpenAIAudioTranscription(OpenAIChatCompletion):
|
|||
timeout=timeout,
|
||||
max_retries=max_retries,
|
||||
client=client,
|
||||
shared_session=shared_session,
|
||||
)
|
||||
|
||||
## LOGGING
|
||||
|
|
|
|||
|
|
@ -5516,6 +5516,7 @@ def transcription(
|
|||
atranscription = kwargs.pop("atranscription", False)
|
||||
litellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignore
|
||||
extra_headers = kwargs.get("extra_headers", None)
|
||||
shared_session = kwargs.get("shared_session", None)
|
||||
kwargs.pop("tags", [])
|
||||
non_default_params = get_non_default_transcription_params(kwargs)
|
||||
|
||||
|
|
@ -5653,6 +5654,7 @@ def transcription(
|
|||
api_key=api_key,
|
||||
provider_config=provider_config,
|
||||
litellm_params=litellm_params_dict,
|
||||
shared_session=shared_session,
|
||||
)
|
||||
elif provider_config is not None:
|
||||
response = base_llm_http_handler.audio_transcriptions(
|
||||
|
|
@ -5679,6 +5681,7 @@ def transcription(
|
|||
custom_llm_provider=custom_llm_provider,
|
||||
headers={},
|
||||
provider_config=provider_config,
|
||||
shared_session=shared_session,
|
||||
)
|
||||
|
||||
# Calculate and add duration if response is missing it
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue