From 7c203118363c6a28fe1e1559afa3cf15a295d36a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:35:34 +0000 Subject: [PATCH 1/2] feat(api): manual updates --- .stats.yml | 8 +- api.md | 2 + src/perplexity/resources/chat/completions.py | 34 +++++++ .../resources/responses/responses.py | 93 +++++++++++++++++++ src/perplexity/types/__init__.py | 1 + .../async_/chat/completion_create_params.py | 7 ++ .../types/chat/completion_create_params.py | 7 ++ .../types/response_cancel_response.py | 18 ++++ .../types/response_create_response.py | 13 +++ .../types/response_retrieve_response.py | 13 +++ src/perplexity/types/response_stream_chunk.py | 39 ++++++++ src/perplexity/types/shared/usage_info.py | 5 + .../async_/chat/test_completions.py | 2 + tests/api_resources/chat/test_completions.py | 4 + tests/api_resources/test_responses.py | 90 +++++++++++++++++- 15 files changed, 331 insertions(+), 5 deletions(-) create mode 100644 src/perplexity/types/response_cancel_response.py diff --git a/.stats.yml b/.stats.yml index 8659912..63a07a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 13 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-f15eee99fec8579d1a543c4dfdc74f7633cc8e82004634be302f9c053cdc3934.yml -openapi_spec_hash: 5fe9895246acf0b07b2283b938a018fe -config_hash: 3f1487a29a16f85810ba4d77134da232 +configured_endpoints: 14 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-0503b4a7abdf2cb4ad14af7b17bca179796f868729dfdfc8e09692e0dca99dda.yml +openapi_spec_hash: 629684ee997a5334c38080865371b0fa +config_hash: 25a3795c176e58c4127154760d603480 diff --git a/api.md b/api.md index dd1c80f..1587b0d 100644 --- a/api.md +++ b/api.md @@ -65,6 +65,7 @@ from perplexity.types import ( ResponsesUsage, ResponseCreateResponse, ResponseRetrieveResponse, + ResponseCancelResponse, ) ``` @@ -72,6 +73,7 @@ Methods: - client.responses.create(\*\*params) -> ResponseCreateResponse - client.responses.retrieve(response_id) -> ResponseRetrieveResponse +- client.responses.cancel(response_id) -> ResponseCancelResponse ## Files diff --git a/src/perplexity/resources/chat/completions.py b/src/perplexity/resources/chat/completions.py index 5931b13..4040b5b 100644 --- a/src/perplexity/resources/chat/completions.py +++ b/src/perplexity/resources/chat/completions.py @@ -83,6 +83,7 @@ def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -121,6 +122,10 @@ def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -168,6 +173,7 @@ def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -205,6 +211,10 @@ def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -252,6 +262,7 @@ def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -289,6 +300,10 @@ def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -335,6 +350,7 @@ def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -405,6 +421,7 @@ def create( "ranking_model": ranking_model, "reasoning_effort": reasoning_effort, "response_format": response_format, + "response_formatting_locale": response_formatting_locale, "response_metadata": response_metadata, "return_images": return_images, "return_related_questions": return_related_questions, @@ -502,6 +519,7 @@ async def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -540,6 +558,10 @@ async def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -587,6 +609,7 @@ async def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -624,6 +647,10 @@ async def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -671,6 +698,7 @@ async def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -708,6 +736,10 @@ async def create( Generate a chat completion response for the given conversation. Args: + response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style + values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical + form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -754,6 +786,7 @@ async def create( ranking_model: Optional[str] | Omit = omit, reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit, response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit, + response_formatting_locale: Optional[str] | Omit = omit, response_metadata: Optional[Dict[str, object]] | Omit = omit, return_images: Optional[bool] | Omit = omit, return_related_questions: Optional[bool] | Omit = omit, @@ -824,6 +857,7 @@ async def create( "ranking_model": ranking_model, "reasoning_effort": reasoning_effort, "response_format": response_format, + "response_formatting_locale": response_formatting_locale, "response_metadata": response_metadata, "return_images": return_images, "return_related_questions": return_related_questions, diff --git a/src/perplexity/resources/responses/responses.py b/src/perplexity/resources/responses/responses.py index d70a05c..5fb702f 100644 --- a/src/perplexity/resources/responses/responses.py +++ b/src/perplexity/resources/responses/responses.py @@ -30,6 +30,7 @@ from ..._base_client import make_request_options from ...types.input_item_param import InputItemParam from ...types.response_stream_chunk import ResponseStreamChunk +from ...types.response_cancel_response import ResponseCancelResponse from ...types.response_create_response import ResponseCreateResponse from ...types.response_retrieve_response import ResponseRetrieveResponse from ...types.shared_params.response_format import ResponseFormat @@ -405,6 +406,46 @@ def retrieve( cast_to=ResponseRetrieveResponse, ) + def cancel( + self, + response_id: 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, + ) -> ResponseCancelResponse: + """Request cancellation of a response. + + Acts on durable state, so it works for + background responses that outlive the client connection as well as durably + routed foreground responses. The cancel is asynchronous: a 200 acknowledges the + request (status `cancelling`) and the run stops shortly after. Poll the retrieve + endpoint for the terminal status. Cancelling a run that is already terminal + returns 400. Ownership is enforced server side; an unknown id, or a response + belonging to a different account, returns 404. + + Args: + 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 + """ + if not response_id: + raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}") + return self._post( + path_template("/v1/responses/{response_id}/cancel", response_id=response_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResponseCancelResponse, + ) + class AsyncResponsesResource(AsyncAPIResource): @cached_property @@ -774,6 +815,46 @@ async def retrieve( cast_to=ResponseRetrieveResponse, ) + async def cancel( + self, + response_id: 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, + ) -> ResponseCancelResponse: + """Request cancellation of a response. + + Acts on durable state, so it works for + background responses that outlive the client connection as well as durably + routed foreground responses. The cancel is asynchronous: a 200 acknowledges the + request (status `cancelling`) and the run stops shortly after. Poll the retrieve + endpoint for the terminal status. Cancelling a run that is already terminal + returns 400. Ownership is enforced server side; an unknown id, or a response + belonging to a different account, returns 404. + + Args: + 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 + """ + if not response_id: + raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}") + return await self._post( + path_template("/v1/responses/{response_id}/cancel", response_id=response_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResponseCancelResponse, + ) + class ResponsesResourceWithRawResponse: def __init__(self, responses: ResponsesResource) -> None: @@ -785,6 +866,9 @@ def __init__(self, responses: ResponsesResource) -> None: self.retrieve = to_raw_response_wrapper( responses.retrieve, ) + self.cancel = to_raw_response_wrapper( + responses.cancel, + ) @cached_property def files(self) -> FilesResourceWithRawResponse: @@ -801,6 +885,9 @@ def __init__(self, responses: AsyncResponsesResource) -> None: self.retrieve = async_to_raw_response_wrapper( responses.retrieve, ) + self.cancel = async_to_raw_response_wrapper( + responses.cancel, + ) @cached_property def files(self) -> AsyncFilesResourceWithRawResponse: @@ -817,6 +904,9 @@ def __init__(self, responses: ResponsesResource) -> None: self.retrieve = to_streamed_response_wrapper( responses.retrieve, ) + self.cancel = to_streamed_response_wrapper( + responses.cancel, + ) @cached_property def files(self) -> FilesResourceWithStreamingResponse: @@ -833,6 +923,9 @@ def __init__(self, responses: AsyncResponsesResource) -> None: self.retrieve = async_to_streamed_response_wrapper( responses.retrieve, ) + self.cancel = async_to_streamed_response_wrapper( + responses.cancel, + ) @cached_property def files(self) -> AsyncFilesResourceWithStreamingResponse: diff --git a/src/perplexity/types/__init__.py b/src/perplexity/types/__init__.py index eb8c539..fca3c2d 100644 --- a/src/perplexity/types/__init__.py +++ b/src/perplexity/types/__init__.py @@ -33,6 +33,7 @@ from .response_create_params import ResponseCreateParams as ResponseCreateParams from .search_create_response import SearchCreateResponse as SearchCreateResponse from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams +from .response_cancel_response import ResponseCancelResponse as ResponseCancelResponse from .response_create_response import ResponseCreateResponse as ResponseCreateResponse from .embedding_create_response import EmbeddingCreateResponse as EmbeddingCreateResponse from .function_call_output_item import FunctionCallOutputItem as FunctionCallOutputItem diff --git a/src/perplexity/types/async_/chat/completion_create_params.py b/src/perplexity/types/async_/chat/completion_create_params.py index 0f8e38d..4a1ec7b 100644 --- a/src/perplexity/types/async_/chat/completion_create_params.py +++ b/src/perplexity/types/async_/chat/completion_create_params.py @@ -164,6 +164,13 @@ class Request(TypedDict, total=False): response_format: Optional[RequestResponseFormat] + response_formatting_locale: Optional[str] + """Optional locale tag used for response formatting conventions. + + Locale-style values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the + canonical form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + """ + response_metadata: Optional[Dict[str, object]] return_images: Optional[bool] diff --git a/src/perplexity/types/chat/completion_create_params.py b/src/perplexity/types/chat/completion_create_params.py index d574574..9c90727 100644 --- a/src/perplexity/types/chat/completion_create_params.py +++ b/src/perplexity/types/chat/completion_create_params.py @@ -90,6 +90,13 @@ class CompletionCreateParamsBase(TypedDict, total=False): response_format: Optional[ResponseFormat] + response_formatting_locale: Optional[str] + """Optional locale tag used for response formatting conventions. + + Locale-style values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the + canonical form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored. + """ + response_metadata: Optional[Dict[str, object]] return_images: Optional[bool] diff --git a/src/perplexity/types/response_cancel_response.py b/src/perplexity/types/response_cancel_response.py new file mode 100644 index 0000000..5fe9de3 --- /dev/null +++ b/src/perplexity/types/response_cancel_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["ResponseCancelResponse"] + + +class ResponseCancelResponse(BaseModel): + response_id: str + """The response id (resp\\__...).""" + + status: Literal["cancelling"] + """Always `cancelling`: the cancel was accepted and the run stops asynchronously. + + An already terminal run returns 400 instead, so no terminal status appears here. + """ diff --git a/src/perplexity/types/response_create_response.py b/src/perplexity/types/response_create_response.py index d54a9c0..1da2d7e 100644 --- a/src/perplexity/types/response_create_response.py +++ b/src/perplexity/types/response_create_response.py @@ -33,6 +33,19 @@ class ResponseCreateResponse(BaseModel): error: Optional[ErrorInfo] = None + previous_response_id: Optional[str] = None + """ + ID of the previous response in the chain, when the response was created with + previous_response_id. + """ + + store: Optional[bool] = None + """Whether the response is stored and visible to later retrieve calls. + + A response created with store=false can still be used as a previous_response_id + continuation source. + """ + usage: Optional[ResponsesUsage] = None @property diff --git a/src/perplexity/types/response_retrieve_response.py b/src/perplexity/types/response_retrieve_response.py index 97ac4c8..a7dad0a 100644 --- a/src/perplexity/types/response_retrieve_response.py +++ b/src/perplexity/types/response_retrieve_response.py @@ -33,4 +33,17 @@ class ResponseRetrieveResponse(BaseModel): error: Optional[ErrorInfo] = None + previous_response_id: Optional[str] = None + """ + ID of the previous response in the chain, when the response was created with + previous_response_id. + """ + + store: Optional[bool] = None + """Whether the response is stored and visible to later retrieve calls. + + A response created with store=false can still be used as a previous_response_id + continuation source. + """ + usage: Optional[ResponsesUsage] = None diff --git a/src/perplexity/types/response_stream_chunk.py b/src/perplexity/types/response_stream_chunk.py index 0f0d5c7..af05c2f 100644 --- a/src/perplexity/types/response_stream_chunk.py +++ b/src/perplexity/types/response_stream_chunk.py @@ -55,6 +55,19 @@ class ResponseCreatedEventResponse(BaseModel): error: Optional[ErrorInfo] = None + previous_response_id: Optional[str] = None + """ + ID of the previous response in the chain, when the response was created with + previous_response_id. + """ + + store: Optional[bool] = None + """Whether the response is stored and visible to later retrieve calls. + + A response created with store=false can still be used as a previous_response_id + continuation source. + """ + usage: Optional[ResponsesUsage] = None @@ -96,6 +109,19 @@ class ResponseInProgressEventResponse(BaseModel): error: Optional[ErrorInfo] = None + previous_response_id: Optional[str] = None + """ + ID of the previous response in the chain, when the response was created with + previous_response_id. + """ + + store: Optional[bool] = None + """Whether the response is stored and visible to later retrieve calls. + + A response created with store=false can still be used as a previous_response_id + continuation source. + """ + usage: Optional[ResponsesUsage] = None @@ -137,6 +163,19 @@ class ResponseCompletedEventResponse(BaseModel): error: Optional[ErrorInfo] = None + previous_response_id: Optional[str] = None + """ + ID of the previous response in the chain, when the response was created with + previous_response_id. + """ + + store: Optional[bool] = None + """Whether the response is stored and visible to later retrieve calls. + + A response created with store=false can still be used as a previous_response_id + continuation source. + """ + usage: Optional[ResponsesUsage] = None diff --git a/src/perplexity/types/shared/usage_info.py b/src/perplexity/types/shared/usage_info.py index ff4e941..8a25854 100644 --- a/src/perplexity/types/shared/usage_info.py +++ b/src/perplexity/types/shared/usage_info.py @@ -19,6 +19,11 @@ class Cost(BaseModel): reasoning_tokens_cost: Optional[float] = None request_cost: Optional[float] = None + """Flat request cost for the chat completion. + + Present on completed (terminal) responses and omitted from the zero cost + skeleton on interim streaming chunks. + """ search_queries_cost: Optional[float] = None diff --git a/tests/api_resources/async_/chat/test_completions.py b/tests/api_resources/async_/chat/test_completions.py index 7f7cead..584d9a2 100644 --- a/tests/api_resources/async_/chat/test_completions.py +++ b/tests/api_resources/async_/chat/test_completions.py @@ -125,6 +125,7 @@ def test_method_create_with_all_params(self, client: Perplexity) -> None: "ranking_model": "ranking_model", "reasoning_effort": "minimal", "response_format": {"type": "text"}, + "response_formatting_locale": "response_formatting_locale", "response_metadata": {"foo": "bar"}, "return_images": True, "return_related_questions": True, @@ -420,6 +421,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncPerplexity "ranking_model": "ranking_model", "reasoning_effort": "minimal", "response_format": {"type": "text"}, + "response_formatting_locale": "response_formatting_locale", "response_metadata": {"foo": "bar"}, "return_images": True, "return_related_questions": True, diff --git a/tests/api_resources/chat/test_completions.py b/tests/api_resources/chat/test_completions.py index d46424b..f99b3c0 100644 --- a/tests/api_resources/chat/test_completions.py +++ b/tests/api_resources/chat/test_completions.py @@ -118,6 +118,7 @@ def test_method_create_with_all_params_overload_1(self, client: Perplexity) -> N ranking_model="ranking_model", reasoning_effort="minimal", response_format={"type": "text"}, + response_formatting_locale="response_formatting_locale", response_metadata={"foo": "bar"}, return_images=True, return_related_questions=True, @@ -315,6 +316,7 @@ def test_method_create_with_all_params_overload_2(self, client: Perplexity) -> N ranking_model="ranking_model", reasoning_effort="minimal", response_format={"type": "text"}, + response_formatting_locale="response_formatting_locale", response_metadata={"foo": "bar"}, return_images=True, return_related_questions=True, @@ -516,6 +518,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn ranking_model="ranking_model", reasoning_effort="minimal", response_format={"type": "text"}, + response_formatting_locale="response_formatting_locale", response_metadata={"foo": "bar"}, return_images=True, return_related_questions=True, @@ -713,6 +716,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn ranking_model="ranking_model", reasoning_effort="minimal", response_format={"type": "text"}, + response_formatting_locale="response_formatting_locale", response_metadata={"foo": "bar"}, return_images=True, return_related_questions=True, diff --git a/tests/api_resources/test_responses.py b/tests/api_resources/test_responses.py index db5bfdc..9ecf32c 100644 --- a/tests/api_resources/test_responses.py +++ b/tests/api_resources/test_responses.py @@ -9,7 +9,11 @@ from perplexity import Perplexity, AsyncPerplexity from tests.utils import assert_matches_type -from perplexity.types import ResponseCreateResponse, ResponseRetrieveResponse +from perplexity.types import ( + ResponseCancelResponse, + ResponseCreateResponse, + ResponseRetrieveResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -233,6 +237,48 @@ def test_path_params_retrieve(self, client: Perplexity) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_cancel(self, client: Perplexity) -> None: + response = client.responses.cancel( + "response_id", + ) + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_cancel(self, client: Perplexity) -> None: + http_response = client.responses.with_raw_response.cancel( + "response_id", + ) + + assert http_response.is_closed is True + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + response = http_response.parse() + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_cancel(self, client: Perplexity) -> None: + with client.responses.with_streaming_response.cancel( + "response_id", + ) as http_response: + assert not http_response.is_closed + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + + response = http_response.parse() + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + assert cast(Any, http_response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_cancel(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `response_id` but received ''"): + client.responses.with_raw_response.cancel( + "", + ) + class TestAsyncResponses: parametrize = pytest.mark.parametrize( @@ -454,3 +500,45 @@ async def test_path_params_retrieve(self, async_client: AsyncPerplexity) -> None await async_client.responses.with_raw_response.retrieve( "", ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_cancel(self, async_client: AsyncPerplexity) -> None: + response = await async_client.responses.cancel( + "response_id", + ) + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_cancel(self, async_client: AsyncPerplexity) -> None: + http_response = await async_client.responses.with_raw_response.cancel( + "response_id", + ) + + assert http_response.is_closed is True + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + response = await http_response.parse() + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_cancel(self, async_client: AsyncPerplexity) -> None: + async with async_client.responses.with_streaming_response.cancel( + "response_id", + ) as http_response: + assert not http_response.is_closed + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + + response = await http_response.parse() + assert_matches_type(ResponseCancelResponse, response, path=["response"]) + + assert cast(Any, http_response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_cancel(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `response_id` but received ''"): + await async_client.responses.with_raw_response.cancel( + "", + ) From 804e4abe671cc9d5b91d1213ef5b68018263604c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:35:55 +0000 Subject: [PATCH 2/2] release: 0.41.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/perplexity/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0a40b9d..ea2682c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.40.0" + ".": "0.41.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7751864..5b1fbfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.41.0 (2026-07-15) + +Full Changelog: [v0.40.0...v0.41.0](https://github.com/perplexityai/perplexity-py/compare/v0.40.0...v0.41.0) + +### Features + +* **api:** manual updates ([7c20311](https://github.com/perplexityai/perplexity-py/commit/7c203118363c6a28fe1e1559afa3cf15a295d36a)) + ## 0.40.0 (2026-07-09) Full Changelog: [v0.39.0...v0.40.0](https://github.com/perplexityai/perplexity-py/compare/v0.39.0...v0.40.0) diff --git a/pyproject.toml b/pyproject.toml index 636d54b..396a6b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "perplexityai" -version = "0.40.0" +version = "0.41.0" description = "The official Python library for the perplexity API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/perplexity/_version.py b/src/perplexity/_version.py index 0561cde..e322a7f 100644 --- a/src/perplexity/_version.py +++ b/src/perplexity/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "perplexity" -__version__ = "0.40.0" # x-release-please-version +__version__ = "0.41.0" # x-release-please-version