diff --git a/src/cloudflare/types/workers/ai_run_response.py b/src/cloudflare/types/workers/ai_run_response.py index d39141bda32..5877761e02c 100644 --- a/src/cloudflare/types/workers/ai_run_response.py +++ b/src/cloudflare/types/workers/ai_run_response.py @@ -43,6 +43,8 @@ class SpeechRecognitionWord(BaseModel): class SpeechRecognition(BaseModel): text: str + vtt: Optional[str] = None + word_count: Optional[float] = None words: Optional[List[SpeechRecognitionWord]] = None diff --git a/tests/api_resources/workers/test_ai.py b/tests/api_resources/workers/test_ai.py index 70a3311e1bb..d4580b77ba0 100644 --- a/tests/api_resources/workers/test_ai.py +++ b/tests/api_resources/workers/test_ai.py @@ -23,7 +23,7 @@ def test_method_run_overload_1(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -33,7 +33,7 @@ def test_raw_response_run_overload_1(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert response.is_closed is True @@ -47,7 +47,7 @@ def test_streaming_response_run_overload_1(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -64,14 +64,14 @@ def test_path_params_run_overload_1(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) @pytest.mark.skip() @@ -80,7 +80,7 @@ def test_method_run_overload_2(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -90,7 +90,7 @@ def test_method_run_with_all_params_overload_2(self, client: Cloudflare) -> None ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", guidance=0, image=[0, 0, 0], mask=[0, 0, 0], @@ -105,7 +105,7 @@ def test_raw_response_run_overload_2(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert response.is_closed is True @@ -119,7 +119,7 @@ def test_streaming_response_run_overload_2(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -136,14 +136,14 @@ def test_path_params_run_overload_2(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - prompt="string", + prompt="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) @pytest.mark.skip() @@ -152,8 +152,8 @@ def test_method_run_overload_3(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -163,8 +163,8 @@ def test_raw_response_run_overload_3(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) assert response.is_closed is True @@ -178,8 +178,8 @@ def test_streaming_response_run_overload_3(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -196,16 +196,16 @@ def test_path_params_run_overload_3(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) @pytest.mark.skip() @@ -214,7 +214,7 @@ def test_method_run_overload_4(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -224,7 +224,7 @@ def test_raw_response_run_overload_4(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert response.is_closed is True @@ -238,7 +238,7 @@ def test_streaming_response_run_overload_4(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -255,14 +255,14 @@ def test_path_params_run_overload_4(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) @pytest.mark.skip() @@ -628,7 +628,7 @@ def test_method_run_overload_11(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -638,7 +638,7 @@ def test_method_run_with_all_params_overload_11(self, client: Cloudflare) -> Non ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", lora="string", max_tokens=0, raw=True, @@ -652,7 +652,7 @@ def test_raw_response_run_overload_11(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert response.is_closed is True @@ -666,7 +666,7 @@ def test_streaming_response_run_overload_11(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -683,14 +683,14 @@ def test_path_params_run_overload_11(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - prompt="string", + prompt="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) @pytest.mark.skip() @@ -847,7 +847,7 @@ def test_method_run_overload_13(self, client: Cloudflare) -> None: "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -858,7 +858,7 @@ def test_method_run_with_all_params_overload_13(self, client: Cloudflare) -> Non "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", source_lang="string", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -870,7 +870,7 @@ def test_raw_response_run_overload_13(self, client: Cloudflare) -> None: "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) assert response.is_closed is True @@ -885,7 +885,7 @@ def test_streaming_response_run_overload_13(self, client: Cloudflare) -> None: "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -903,7 +903,7 @@ def test_path_params_run_overload_13(self, client: Cloudflare) -> None: "string", account_id="", target_lang="string", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): @@ -911,7 +911,7 @@ def test_path_params_run_overload_13(self, client: Cloudflare) -> None: "", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) @pytest.mark.skip() @@ -920,7 +920,7 @@ def test_method_run_overload_14(self, client: Cloudflare) -> None: ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -930,7 +930,7 @@ def test_method_run_with_all_params_overload_14(self, client: Cloudflare) -> Non ai = client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", max_length=0, ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -941,7 +941,7 @@ def test_raw_response_run_overload_14(self, client: Cloudflare) -> None: response = client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) assert response.is_closed is True @@ -955,7 +955,7 @@ def test_streaming_response_run_overload_14(self, client: Cloudflare) -> None: with client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -972,14 +972,14 @@ def test_path_params_run_overload_14(self, client: Cloudflare) -> None: client.workers.ai.with_raw_response.run( "string", account_id="", - input_text="string", + input_text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) @pytest.mark.skip() @@ -1113,7 +1113,7 @@ async def test_method_run_overload_1(self, async_client: AsyncCloudflare) -> Non ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1123,7 +1123,7 @@ async def test_raw_response_run_overload_1(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert response.is_closed is True @@ -1137,7 +1137,7 @@ async def test_streaming_response_run_overload_1(self, async_client: AsyncCloudf async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1154,14 +1154,14 @@ async def test_path_params_run_overload_1(self, async_client: AsyncCloudflare) - await async_client.workers.ai.with_raw_response.run( "string", account_id="", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) @pytest.mark.skip() @@ -1170,7 +1170,7 @@ async def test_method_run_overload_2(self, async_client: AsyncCloudflare) -> Non ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1180,7 +1180,7 @@ async def test_method_run_with_all_params_overload_2(self, async_client: AsyncCl ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", guidance=0, image=[0, 0, 0], mask=[0, 0, 0], @@ -1195,7 +1195,7 @@ async def test_raw_response_run_overload_2(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert response.is_closed is True @@ -1209,7 +1209,7 @@ async def test_streaming_response_run_overload_2(self, async_client: AsyncCloudf async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1226,14 +1226,14 @@ async def test_path_params_run_overload_2(self, async_client: AsyncCloudflare) - await async_client.workers.ai.with_raw_response.run( "string", account_id="", - prompt="string", + prompt="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) @pytest.mark.skip() @@ -1242,8 +1242,8 @@ async def test_method_run_overload_3(self, async_client: AsyncCloudflare) -> Non ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1253,8 +1253,8 @@ async def test_raw_response_run_overload_3(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) assert response.is_closed is True @@ -1268,8 +1268,8 @@ async def test_streaming_response_run_overload_3(self, async_client: AsyncCloudf async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1286,16 +1286,16 @@ async def test_path_params_run_overload_3(self, async_client: AsyncCloudflare) - await async_client.workers.ai.with_raw_response.run( "string", account_id="", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - sentences=["string", "string", "string"], - source="string", + sentences=["x", "x", "x"], + source="x", ) @pytest.mark.skip() @@ -1304,7 +1304,7 @@ async def test_method_run_overload_4(self, async_client: AsyncCloudflare) -> Non ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1314,7 +1314,7 @@ async def test_raw_response_run_overload_4(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) assert response.is_closed is True @@ -1328,7 +1328,7 @@ async def test_streaming_response_run_overload_4(self, async_client: AsyncCloudf async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1345,14 +1345,14 @@ async def test_path_params_run_overload_4(self, async_client: AsyncCloudflare) - await async_client.workers.ai.with_raw_response.run( "string", account_id="", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - text="string", + text="x", ) @pytest.mark.skip() @@ -1718,7 +1718,7 @@ async def test_method_run_overload_11(self, async_client: AsyncCloudflare) -> No ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1728,7 +1728,7 @@ async def test_method_run_with_all_params_overload_11(self, async_client: AsyncC ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", lora="string", max_tokens=0, raw=True, @@ -1742,7 +1742,7 @@ async def test_raw_response_run_overload_11(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) assert response.is_closed is True @@ -1756,7 +1756,7 @@ async def test_streaming_response_run_overload_11(self, async_client: AsyncCloud async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1773,14 +1773,14 @@ async def test_path_params_run_overload_11(self, async_client: AsyncCloudflare) await async_client.workers.ai.with_raw_response.run( "string", account_id="", - prompt="string", + prompt="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - prompt="string", + prompt="x", ) @pytest.mark.skip() @@ -1937,7 +1937,7 @@ async def test_method_run_overload_13(self, async_client: AsyncCloudflare) -> No "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1948,7 +1948,7 @@ async def test_method_run_with_all_params_overload_13(self, async_client: AsyncC "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", source_lang="string", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -1960,7 +1960,7 @@ async def test_raw_response_run_overload_13(self, async_client: AsyncCloudflare) "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) assert response.is_closed is True @@ -1975,7 +1975,7 @@ async def test_streaming_response_run_overload_13(self, async_client: AsyncCloud "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1993,7 +1993,7 @@ async def test_path_params_run_overload_13(self, async_client: AsyncCloudflare) "string", account_id="", target_lang="string", - text="string", + text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): @@ -2001,7 +2001,7 @@ async def test_path_params_run_overload_13(self, async_client: AsyncCloudflare) "", account_id="023e105f4ecef8ad9ca31a8372d0c353", target_lang="string", - text="string", + text="x", ) @pytest.mark.skip() @@ -2010,7 +2010,7 @@ async def test_method_run_overload_14(self, async_client: AsyncCloudflare) -> No ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -2020,7 +2020,7 @@ async def test_method_run_with_all_params_overload_14(self, async_client: AsyncC ai = await async_client.workers.ai.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", max_length=0, ) assert_matches_type(Optional[AIRunResponse], ai, path=["response"]) @@ -2031,7 +2031,7 @@ async def test_raw_response_run_overload_14(self, async_client: AsyncCloudflare) response = await async_client.workers.ai.with_raw_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) assert response.is_closed is True @@ -2045,7 +2045,7 @@ async def test_streaming_response_run_overload_14(self, async_client: AsyncCloud async with async_client.workers.ai.with_streaming_response.run( "string", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -2062,14 +2062,14 @@ async def test_path_params_run_overload_14(self, async_client: AsyncCloudflare) await async_client.workers.ai.with_raw_response.run( "string", account_id="", - input_text="string", + input_text="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `model_name` but received ''"): await async_client.workers.ai.with_raw_response.run( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - input_text="string", + input_text="x", ) @pytest.mark.skip()