(feat): Add timestamp_granularities parameter to transcription API (#6457)

* Add timestamp_granularities parameter to transcription API

* add param to the local test
This commit is contained in:
Show 2024-11-20 00:04:33 +01:00 committed by GitHub
parent f4ec93fbc3
commit e89dcccdd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View file

@ -4729,6 +4729,7 @@ def transcription(
response_format: Optional[
Literal["json", "text", "srt", "verbose_json", "vtt"]
] = None,
timestamp_granularities: List[Literal["word", "segment"]] = None,
temperature: Optional[int] = None, # openai defaults this to 0
## LITELLM PARAMS ##
user: Optional[str] = None,
@ -4778,6 +4779,7 @@ def transcription(
language=language,
prompt=prompt,
response_format=response_format,
timestamp_granularities=timestamp_granularities,
temperature=temperature,
custom_llm_provider=custom_llm_provider,
drop_params=drop_params,

View file

@ -2125,6 +2125,7 @@ def get_optional_params_transcription(
prompt: Optional[str] = None,
response_format: Optional[str] = None,
temperature: Optional[int] = None,
timestamp_granularities: Optional[List[Literal["word", "segment"]]] = None,
custom_llm_provider: Optional[str] = None,
drop_params: Optional[bool] = None,
**kwargs,

View file

@ -53,8 +53,9 @@ from litellm import Router
)
@pytest.mark.parametrize("response_format", ["json", "vtt"])
@pytest.mark.parametrize("sync_mode", [True, False])
@pytest.mark.parametrize("timestamp_granularities", [["word"], ["segment"]])
@pytest.mark.asyncio
async def test_transcription(model, api_key, api_base, response_format, sync_mode):
async def test_transcription(model, api_key, api_base, response_format, sync_mode, timestamp_granularities):
if sync_mode:
transcript = litellm.transcription(
model=model,
@ -62,6 +63,7 @@ async def test_transcription(model, api_key, api_base, response_format, sync_mod
api_key=api_key,
api_base=api_base,
response_format=response_format,
timestamp_granularities=timestamp_granularities,
drop_params=True,
)
else: