The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test: fix assemblyai passthrough transcription request format
Krrish Dholakia89091e4f293b
diff --git a/tests/store_model_in_db_tests/test_adding_passthrough_model.py b/tests/store_model_in_db_tests/test_adding_passthrough_model.pyindex 80cd7e1aabf..c8212b849a1 100644--- a/tests/store_model_in_db_tests/test_adding_passthrough_model.py+++ b/tests/store_model_in_db_tests/test_adding_passthrough_model.py@@ -11,7 +11,6 @@ Cases to cover"""import time-import assemblyai as aaiimport pytestimport httpximport os@@ -175,28 +174,56 @@ def make_assemblyai_basic_transcribe_request(virtual_key: str, assemblyai_base_url: str):print("making basic transcribe request to assemblyai passthrough")+ file_url = "https://assembly.ai/wildfires.mp3"+ headers = {+ "Authorization": f"Bearer {virtual_key}",+ "Content-Type": "application/json",+ }+ create_payload = {+ "audio_url": file_url,+ "speech_models": ["universal-2"],+ }- # Replace with your API key- aai.settings.api_key = f"Bearer {virtual_key}"- aai.settings.base_url = assemblyai_base_url+ create_response = httpx.post(+ url=f"{assemblyai_base_url}/v2/transcript",+ headers=headers,+ json=create_payload,+ timeout=60.0,+ )+ if create_response.status_code != 200:+ pytest.fail(+ "Failed to create transcript request: "+ f"status={create_response.status_code}, body={create_response.text}"+ )- # URL of the file to transcribe- FILE_URL = "https://assembly.ai/wildfires.mp3"+ transcript = create_response.json()+ transcript_id = transcript.get("id")+ if not transcript_id:+ pytest.fail("Failed to get transcript id")- # You can also transcribe a local file by passing in a file path- # FILE_URL = './path/to/file.mp3'+ for _ in range(60):+ poll_response = httpx.get(+ url=f"{assemblyai_base_url}/v2/transcript/{transcript_id}",+ headers=headers,+ timeout=30.0,+ )+ if poll_response.status_code != 200:+ pytest.fail(+ "Failed to poll transcript status: "+ f"status={poll_response.status_code}, body={poll_response.text}"+ )+ transcript = poll_response.json()+ if transcript.get("status") in ("completed", "error"):+ break+ time.sleep(1)++ httpx.delete(+ url=f"{assemblyai_base_url}/v2/transcript/{transcript_id}",+ headers=headers,+ timeout=30.0,+ )- transcriber = aai.Transcriber()- transcript = transcriber.transcribe(FILE_URL)- print(transcript)- print(transcript.id)- if transcript.id:- transcript.delete_by_id(transcript.id)- else:- pytest.fail("Failed to get transcript id")+ if transcript.get("status") == "error":+ pytest.fail(f"Failed to transcribe file error: {transcript.get('error')}")- if transcript.status == aai.TranscriptStatus.error:- print(transcript.error)- pytest.fail(f"Failed to transcribe file error: {transcript.error}")- else:- print(transcript.text)+ print(transcript.get("text"))