diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4191c889..f7e9ba85 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.0.0" + ".": "3.0.1-rc1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 45b858e1..eced2fee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai/writer-275de8f7afa2d37404ebebc082dda35e70ab94437de270b5bc6e2fdc94c9fdae.yml -openapi_spec_hash: 4d4a9ba232d19a6180e6d4a7d5566103 -config_hash: 8701b1a467238f1afdeceeb7feb1adc6 +configured_endpoints: 29 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai/writer-c998c7cab6c43a698deb813179849e0379db494eef2a34f751616486d6bb0e25.yml +openapi_spec_hash: aba09dae66d0e96b08ea2ac4e9113f09 +config_hash: 85d9c08b6b71fad459240bc6f401eac7 diff --git a/CHANGELOG.md b/CHANGELOG.md index e3939bd4..3d42ceb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 3.0.1-rc1 (2026-07-13) + +Full Changelog: [v3.0.0...v3.0.1-rc1](https://github.com/writer/writer-python/compare/v3.0.0...v3.0.1-rc1) + +### Chores + +* **deps:** bump idna in the uv group across 1 directory ([#259](https://github.com/writer/writer-python/issues/259)) ([a01835e](https://github.com/writer/writer-python/commit/a01835e46b00ae3c13497bc816fa59dba5079ea2)) + + +### Documentation + +* **api:** updates to API spec ([3215a51](https://github.com/writer/writer-python/commit/3215a513ababca91f8ba90df70bd4e2f991f5d60)) + ## 3.0.0 (2026-06-02) Full Changelog: [v3.0.0-rc1...v3.0.0](https://github.com/writer/writer-python/compare/v3.0.0-rc1...v3.0.0) diff --git a/README.md b/README.md index 736aaee2..fe96e5ab 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To install the package from PyPI, use `pip`: ```sh # install from PyPI -pip install writer-sdk +pip install --pre writer-sdk ``` ## Prequisites @@ -125,7 +125,7 @@ You can enable this by installing `aiohttp`: ```sh # install from PyPI -pip install writer-sdk[aiohttp] +pip install --pre writer-sdk[aiohttp] ``` Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: diff --git a/api.md b/api.md index 7377b2f1..04fb552d 100644 --- a/api.md +++ b/api.md @@ -170,18 +170,6 @@ Methods: - client.tools.parse_pdf(file_id, \*\*params) -> ToolParsePdfResponse - client.tools.web_search(\*\*params) -> ToolWebSearchResponse -# Translation - -Types: - -```python -from writerai.types import TranslationRequest, TranslationResponse -``` - -Methods: - -- client.translation.translate(\*\*params) -> TranslationResponse - # Vision Types: diff --git a/pyproject.toml b/pyproject.toml index f8b0f546..b8f322e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "writer-sdk" -version = "3.0.0" +version = "3.0.1-rc1" description = "The official Python library for the writer API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/writerai/_client.py b/src/writerai/_client.py index ce49f5f2..78fdf068 100644 --- a/src/writerai/_client.py +++ b/src/writerai/_client.py @@ -36,7 +36,7 @@ ) if TYPE_CHECKING: - from .resources import chat, files, tools, graphs, models, vision, completions, translation, applications + from .resources import chat, files, tools, graphs, models, vision, completions, applications from .resources.chat import ChatResource, AsyncChatResource from .resources.files import FilesResource, AsyncFilesResource from .resources.tools import ToolsResource, AsyncToolsResource @@ -44,7 +44,6 @@ from .resources.models import ModelsResource, AsyncModelsResource from .resources.vision import VisionResource, AsyncVisionResource from .resources.completions import CompletionsResource, AsyncCompletionsResource - from .resources.translation import TranslationResource, AsyncTranslationResource from .resources.applications.applications import ApplicationsResource, AsyncApplicationsResource __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Writer", "AsyncWriter", "Client", "AsyncClient"] @@ -158,12 +157,6 @@ def tools(self) -> ToolsResource: return ToolsResource(self) - @cached_property - def translation(self) -> TranslationResource: - from .resources.translation import TranslationResource - - return TranslationResource(self) - @cached_property def vision(self) -> VisionResource: from .resources.vision import VisionResource @@ -391,12 +384,6 @@ def tools(self) -> AsyncToolsResource: return AsyncToolsResource(self) - @cached_property - def translation(self) -> AsyncTranslationResource: - from .resources.translation import AsyncTranslationResource - - return AsyncTranslationResource(self) - @cached_property def vision(self) -> AsyncVisionResource: from .resources.vision import AsyncVisionResource @@ -564,12 +551,6 @@ def tools(self) -> tools.ToolsResourceWithRawResponse: return ToolsResourceWithRawResponse(self._client.tools) - @cached_property - def translation(self) -> translation.TranslationResourceWithRawResponse: - from .resources.translation import TranslationResourceWithRawResponse - - return TranslationResourceWithRawResponse(self._client.translation) - @cached_property def vision(self) -> vision.VisionResourceWithRawResponse: from .resources.vision import VisionResourceWithRawResponse @@ -625,12 +606,6 @@ def tools(self) -> tools.AsyncToolsResourceWithRawResponse: return AsyncToolsResourceWithRawResponse(self._client.tools) - @cached_property - def translation(self) -> translation.AsyncTranslationResourceWithRawResponse: - from .resources.translation import AsyncTranslationResourceWithRawResponse - - return AsyncTranslationResourceWithRawResponse(self._client.translation) - @cached_property def vision(self) -> vision.AsyncVisionResourceWithRawResponse: from .resources.vision import AsyncVisionResourceWithRawResponse @@ -686,12 +661,6 @@ def tools(self) -> tools.ToolsResourceWithStreamingResponse: return ToolsResourceWithStreamingResponse(self._client.tools) - @cached_property - def translation(self) -> translation.TranslationResourceWithStreamingResponse: - from .resources.translation import TranslationResourceWithStreamingResponse - - return TranslationResourceWithStreamingResponse(self._client.translation) - @cached_property def vision(self) -> vision.VisionResourceWithStreamingResponse: from .resources.vision import VisionResourceWithStreamingResponse @@ -747,12 +716,6 @@ def tools(self) -> tools.AsyncToolsResourceWithStreamingResponse: return AsyncToolsResourceWithStreamingResponse(self._client.tools) - @cached_property - def translation(self) -> translation.AsyncTranslationResourceWithStreamingResponse: - from .resources.translation import AsyncTranslationResourceWithStreamingResponse - - return AsyncTranslationResourceWithStreamingResponse(self._client.translation) - @cached_property def vision(self) -> vision.AsyncVisionResourceWithStreamingResponse: from .resources.vision import AsyncVisionResourceWithStreamingResponse diff --git a/src/writerai/_version.py b/src/writerai/_version.py index 450bd395..2faa4d69 100644 --- a/src/writerai/_version.py +++ b/src/writerai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "writerai" -__version__ = "3.0.0" # x-release-please-version +__version__ = "3.0.1-rc1" # x-release-please-version diff --git a/src/writerai/resources/__init__.py b/src/writerai/resources/__init__.py index 767c0120..40417904 100644 --- a/src/writerai/resources/__init__.py +++ b/src/writerai/resources/__init__.py @@ -56,14 +56,6 @@ CompletionsResourceWithStreamingResponse, AsyncCompletionsResourceWithStreamingResponse, ) -from .translation import ( - TranslationResource, - AsyncTranslationResource, - TranslationResourceWithRawResponse, - AsyncTranslationResourceWithRawResponse, - TranslationResourceWithStreamingResponse, - AsyncTranslationResourceWithStreamingResponse, -) from .applications import ( ApplicationsResource, AsyncApplicationsResource, @@ -116,12 +108,6 @@ "AsyncToolsResourceWithRawResponse", "ToolsResourceWithStreamingResponse", "AsyncToolsResourceWithStreamingResponse", - "TranslationResource", - "AsyncTranslationResource", - "TranslationResourceWithRawResponse", - "AsyncTranslationResourceWithRawResponse", - "TranslationResourceWithStreamingResponse", - "AsyncTranslationResourceWithStreamingResponse", "VisionResource", "AsyncVisionResource", "VisionResourceWithRawResponse", diff --git a/src/writerai/resources/translation.py b/src/writerai/resources/translation.py deleted file mode 100644 index 36166407..00000000 --- a/src/writerai/resources/translation.py +++ /dev/null @@ -1,278 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import typing_extensions -from typing_extensions import Literal - -import httpx - -from ..types import translation_translate_params -from .._types import Body, Query, Headers, NotGiven, not_given -from .._utils import maybe_transform, async_maybe_transform -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .._base_client import make_request_options -from ..types.translation_response import TranslationResponse - -__all__ = ["TranslationResource", "AsyncTranslationResource"] - - -class TranslationResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> TranslationResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/writer/writer-python#accessing-raw-response-data-eg-headers - """ - return TranslationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> TranslationResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/writer/writer-python#with_streaming_response - """ - return TranslationResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "Will be removed in a future release. Migrate to `chat.chat` with the translate tool for translation capabilities. See documentation at dev.writer.com for more information." - ) - def translate( - self, - *, - formality: bool, - length_control: bool, - mask_profanity: bool, - model: Literal["palmyra-translate"], - source_language_code: str, - target_language_code: str, - text: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TranslationResponse: - """ - Translate text from one language to another. - - Args: - formality: Whether to use formal or informal language in the translation. See the - [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality). - If the language does not support formality, this parameter is ignored. - - length_control: Whether to control the length of the translated text. See the - [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control). - If the language does not support length control, this parameter is ignored. - - mask_profanity: Whether to mask profane words in the translated text. See the - [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking). - If the language does not support profanity masking, this parameter is ignored. - - model: The model to use for translation. - - source_language_code: The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the original text to translate. For example, `en` for English, - `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a - variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - - target_language_code: The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the target language for the translation. For example, `en` for - English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language - has a variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - - text: The text to translate. Maximum of 100,000 words. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/v1/translation", - body=maybe_transform( - { - "formality": formality, - "length_control": length_control, - "mask_profanity": mask_profanity, - "model": model, - "source_language_code": source_language_code, - "target_language_code": target_language_code, - "text": text, - }, - translation_translate_params.TranslationTranslateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=TranslationResponse, - ) - - -class AsyncTranslationResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncTranslationResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/writer/writer-python#accessing-raw-response-data-eg-headers - """ - return AsyncTranslationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncTranslationResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/writer/writer-python#with_streaming_response - """ - return AsyncTranslationResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "Will be removed in a future release. Migrate to `chat.chat` with the translate tool for translation capabilities. See documentation at dev.writer.com for more information." - ) - async def translate( - self, - *, - formality: bool, - length_control: bool, - mask_profanity: bool, - model: Literal["palmyra-translate"], - source_language_code: str, - target_language_code: str, - text: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TranslationResponse: - """ - Translate text from one language to another. - - Args: - formality: Whether to use formal or informal language in the translation. See the - [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality). - If the language does not support formality, this parameter is ignored. - - length_control: Whether to control the length of the translated text. See the - [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control). - If the language does not support length control, this parameter is ignored. - - mask_profanity: Whether to mask profane words in the translated text. See the - [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking). - If the language does not support profanity masking, this parameter is ignored. - - model: The model to use for translation. - - source_language_code: The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the original text to translate. For example, `en` for English, - `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a - variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - - target_language_code: The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the target language for the translation. For example, `en` for - English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language - has a variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - - text: The text to translate. Maximum of 100,000 words. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/v1/translation", - body=await async_maybe_transform( - { - "formality": formality, - "length_control": length_control, - "mask_profanity": mask_profanity, - "model": model, - "source_language_code": source_language_code, - "target_language_code": target_language_code, - "text": text, - }, - translation_translate_params.TranslationTranslateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=TranslationResponse, - ) - - -class TranslationResourceWithRawResponse: - def __init__(self, translation: TranslationResource) -> None: - self._translation = translation - - self.translate = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - translation.translate, # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncTranslationResourceWithRawResponse: - def __init__(self, translation: AsyncTranslationResource) -> None: - self._translation = translation - - self.translate = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - translation.translate, # pyright: ignore[reportDeprecated], - ) - ) - - -class TranslationResourceWithStreamingResponse: - def __init__(self, translation: TranslationResource) -> None: - self._translation = translation - - self.translate = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - translation.translate, # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncTranslationResourceWithStreamingResponse: - def __init__(self, translation: AsyncTranslationResource) -> None: - self._translation = translation - - self.translate = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - translation.translate, # pyright: ignore[reportDeprecated], - ) - ) diff --git a/src/writerai/types/__init__.py b/src/writerai/types/__init__.py index 195d442a..b703d4bb 100644 --- a/src/writerai/types/__init__.py +++ b/src/writerai/types/__init__.py @@ -34,7 +34,6 @@ from .graph_update_params import GraphUpdateParams as GraphUpdateParams from .model_list_response import ModelListResponse as ModelListResponse from .file_delete_response import FileDeleteResponse as FileDeleteResponse -from .translation_response import TranslationResponse as TranslationResponse from .chat_completion_chunk import ChatCompletionChunk as ChatCompletionChunk from .chat_completion_usage import ChatCompletionUsage as ChatCompletionUsage from .graph_create_response import GraphCreateResponse as GraphCreateResponse @@ -52,7 +51,6 @@ from .completion_create_params import CompletionCreateParams as CompletionCreateParams from .tool_web_search_response import ToolWebSearchResponse as ToolWebSearchResponse from .application_list_response import ApplicationListResponse as ApplicationListResponse -from .translation_translate_params import TranslationTranslateParams as TranslationTranslateParams from .application_retrieve_response import ApplicationRetrieveResponse as ApplicationRetrieveResponse from .graph_add_file_to_graph_params import GraphAddFileToGraphParams as GraphAddFileToGraphParams from .application_generate_content_chunk import ApplicationGenerateContentChunk as ApplicationGenerateContentChunk diff --git a/src/writerai/types/translation_response.py b/src/writerai/types/translation_response.py deleted file mode 100644 index 9d947d8b..00000000 --- a/src/writerai/types/translation_response.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .._models import BaseModel - -__all__ = ["TranslationResponse"] - - -class TranslationResponse(BaseModel): - data: str - """The result of the translation.""" diff --git a/src/writerai/types/translation_translate_params.py b/src/writerai/types/translation_translate_params.py deleted file mode 100644 index 26de74d7..00000000 --- a/src/writerai/types/translation_translate_params.py +++ /dev/null @@ -1,61 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["TranslationTranslateParams"] - - -class TranslationTranslateParams(TypedDict, total=False): - formality: Required[bool] - """Whether to use formal or informal language in the translation. - - See the - [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality). - If the language does not support formality, this parameter is ignored. - """ - - length_control: Required[bool] - """Whether to control the length of the translated text. - - See the - [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control). - If the language does not support length control, this parameter is ignored. - """ - - mask_profanity: Required[bool] - """Whether to mask profane words in the translated text. - - See the - [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking). - If the language does not support profanity masking, this parameter is ignored. - """ - - model: Required[Literal["palmyra-translate"]] - """The model to use for translation.""" - - source_language_code: Required[str] - """ - The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the original text to translate. For example, `en` for English, - `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a - variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - """ - - target_language_code: Required[str] - """ - The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) - language code of the target language for the translation. For example, `en` for - English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language - has a variant, the code appends the two-digit - [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). - For example, Mexican Spanish is `es-MX`. See the - [list of supported languages and language codes](https://dev.writer.com/api-reference/translation-api/language-support). - """ - - text: Required[str] - """The text to translate. Maximum of 100,000 words.""" diff --git a/tests/api_resources/test_translation.py b/tests/api_resources/test_translation.py deleted file mode 100644 index 12497e7a..00000000 --- a/tests/api_resources/test_translation.py +++ /dev/null @@ -1,132 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from writerai import Writer, AsyncWriter -from tests.utils import assert_matches_type -from writerai.types import TranslationResponse - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestTranslation: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_translate(self, client: Writer) -> None: - with pytest.warns(DeprecationWarning): - translation = client.translation.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) - - assert_matches_type(TranslationResponse, translation, path=["response"]) - - @parametrize - def test_raw_response_translate(self, client: Writer) -> None: - with pytest.warns(DeprecationWarning): - response = client.translation.with_raw_response.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - translation = response.parse() - assert_matches_type(TranslationResponse, translation, path=["response"]) - - @parametrize - def test_streaming_response_translate(self, client: Writer) -> None: - with pytest.warns(DeprecationWarning): - with client.translation.with_streaming_response.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - translation = response.parse() - assert_matches_type(TranslationResponse, translation, path=["response"]) - - assert cast(Any, response.is_closed) is True - - -class TestAsyncTranslation: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @parametrize - async def test_method_translate(self, async_client: AsyncWriter) -> None: - with pytest.warns(DeprecationWarning): - translation = await async_client.translation.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) - - assert_matches_type(TranslationResponse, translation, path=["response"]) - - @parametrize - async def test_raw_response_translate(self, async_client: AsyncWriter) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.translation.with_raw_response.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - translation = await response.parse() - assert_matches_type(TranslationResponse, translation, path=["response"]) - - @parametrize - async def test_streaming_response_translate(self, async_client: AsyncWriter) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.translation.with_streaming_response.translate( - formality=True, - length_control=True, - mask_profanity=True, - model="palmyra-translate", - source_language_code="en", - target_language_code="es", - text="Hello, world!", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - translation = await response.parse() - assert_matches_type(TranslationResponse, translation, path=["response"]) - - assert cast(Any, response.is_closed) is True