From ee59c342ee5a1a3673f0957c92db284367cdabb6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:28:14 +0000 Subject: [PATCH 1/4] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f4db3cd..a3268f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-78325ecc9bdc8e9850866fcdd3be3d209b06f151059c774afc7e6005a1775f09.yml openapi_spec_hash: 19a34c8ddd46f81dd0b0850af5ee42f3 -config_hash: c3b93f1bb8fa365d5a83e83b7e13e6c4 +config_hash: 51107ec8a7775b3e6ce142f8d0f5a5ac From 3b6d44408d2706824c3b8f7217af67cdb5ab71d7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:31:39 +0000 Subject: [PATCH 2/4] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a3268f9..e1dcb32 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-78325ecc9bdc8e9850866fcdd3be3d209b06f151059c774afc7e6005a1775f09.yml openapi_spec_hash: 19a34c8ddd46f81dd0b0850af5ee42f3 -config_hash: 51107ec8a7775b3e6ce142f8d0f5a5ac +config_hash: 620d4d190431b939dd17ac5d442918e6 From f5c3e58836feb37a6b9ba366a55811513a8cd28c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:59:19 +0000 Subject: [PATCH 3/4] feat(api): Add browser and sandbox API endpoints --- .stats.yml | 8 +- api.md | 65 +++ src/perplexity/_client.py | 76 ++- src/perplexity/resources/__init__.py | 28 + src/perplexity/resources/browser/__init__.py | 33 ++ src/perplexity/resources/browser/browser.py | 102 ++++ src/perplexity/resources/browser/sessions.py | 217 ++++++++ src/perplexity/resources/sandbox/__init__.py | 33 ++ src/perplexity/resources/sandbox/sandbox.py | 102 ++++ .../resources/sandbox/sessions/__init__.py | 89 ++++ .../resources/sandbox/sessions/execute.py | 209 ++++++++ .../resources/sandbox/sessions/files.py | 478 +++++++++++++++++ .../resources/sandbox/sessions/pause.py | 163 ++++++ .../resources/sandbox/sessions/processes.py | 326 ++++++++++++ .../resources/sandbox/sessions/resume.py | 175 +++++++ .../resources/sandbox/sessions/sessions.py | 487 ++++++++++++++++++ src/perplexity/types/__init__.py | 11 + src/perplexity/types/browser/__init__.py | 3 + src/perplexity/types/sandbox/__init__.py | 5 + .../types/sandbox/session_create_params.py | 12 + .../types/sandbox/sessions/__init__.py | 9 + .../sandbox/sessions/execute_create_params.py | 21 + .../sandbox/sessions/file_list_params.py | 15 + .../sandbox/sessions/file_read_params.py | 12 + .../sandbox/sessions/file_write_params.py | 15 + .../sandbox/sessions/resume_create_params.py | 12 + src/perplexity/types/shared/__init__.py | 11 + .../types/shared/browser_session_response.py | 18 + .../types/shared/execute_code_response.py | 46 ++ src/perplexity/types/shared/file_entry.py | 21 + .../types/shared/list_files_response.py | 15 + .../types/shared/list_processes_response.py | 15 + .../types/shared/modified_files_response.py | 14 + .../types/shared/pause_sandbox_response.py | 32 ++ src/perplexity/types/shared/process_info.py | 20 + .../types/shared/read_file_response.py | 20 + .../types/shared/sandbox_session_response.py | 24 + .../types/shared/write_file_response.py | 17 + tests/api_resources/browser/__init__.py | 1 + tests/api_resources/browser/test_sessions.py | 164 ++++++ tests/api_resources/sandbox/__init__.py | 1 + .../sandbox/sessions/__init__.py | 1 + .../sandbox/sessions/test_execute.py | 148 ++++++ .../sandbox/sessions/test_files.py | 404 +++++++++++++++ .../sandbox/sessions/test_pause.py | 108 ++++ .../sandbox/sessions/test_processes.py | 292 +++++++++++ .../sandbox/sessions/test_resume.py | 126 +++++ tests/api_resources/sandbox/test_sessions.py | 264 ++++++++++ 48 files changed, 4463 insertions(+), 5 deletions(-) create mode 100644 src/perplexity/resources/browser/__init__.py create mode 100644 src/perplexity/resources/browser/browser.py create mode 100644 src/perplexity/resources/browser/sessions.py create mode 100644 src/perplexity/resources/sandbox/__init__.py create mode 100644 src/perplexity/resources/sandbox/sandbox.py create mode 100644 src/perplexity/resources/sandbox/sessions/__init__.py create mode 100644 src/perplexity/resources/sandbox/sessions/execute.py create mode 100644 src/perplexity/resources/sandbox/sessions/files.py create mode 100644 src/perplexity/resources/sandbox/sessions/pause.py create mode 100644 src/perplexity/resources/sandbox/sessions/processes.py create mode 100644 src/perplexity/resources/sandbox/sessions/resume.py create mode 100644 src/perplexity/resources/sandbox/sessions/sessions.py create mode 100644 src/perplexity/types/browser/__init__.py create mode 100644 src/perplexity/types/sandbox/__init__.py create mode 100644 src/perplexity/types/sandbox/session_create_params.py create mode 100644 src/perplexity/types/sandbox/sessions/__init__.py create mode 100644 src/perplexity/types/sandbox/sessions/execute_create_params.py create mode 100644 src/perplexity/types/sandbox/sessions/file_list_params.py create mode 100644 src/perplexity/types/sandbox/sessions/file_read_params.py create mode 100644 src/perplexity/types/sandbox/sessions/file_write_params.py create mode 100644 src/perplexity/types/sandbox/sessions/resume_create_params.py create mode 100644 src/perplexity/types/shared/browser_session_response.py create mode 100644 src/perplexity/types/shared/execute_code_response.py create mode 100644 src/perplexity/types/shared/file_entry.py create mode 100644 src/perplexity/types/shared/list_files_response.py create mode 100644 src/perplexity/types/shared/list_processes_response.py create mode 100644 src/perplexity/types/shared/modified_files_response.py create mode 100644 src/perplexity/types/shared/pause_sandbox_response.py create mode 100644 src/perplexity/types/shared/process_info.py create mode 100644 src/perplexity/types/shared/read_file_response.py create mode 100644 src/perplexity/types/shared/sandbox_session_response.py create mode 100644 src/perplexity/types/shared/write_file_response.py create mode 100644 tests/api_resources/browser/__init__.py create mode 100644 tests/api_resources/browser/test_sessions.py create mode 100644 tests/api_resources/sandbox/__init__.py create mode 100644 tests/api_resources/sandbox/sessions/__init__.py create mode 100644 tests/api_resources/sandbox/sessions/test_execute.py create mode 100644 tests/api_resources/sandbox/sessions/test_files.py create mode 100644 tests/api_resources/sandbox/sessions/test_pause.py create mode 100644 tests/api_resources/sandbox/sessions/test_processes.py create mode 100644 tests/api_resources/sandbox/sessions/test_resume.py create mode 100644 tests/api_resources/sandbox/test_sessions.py diff --git a/.stats.yml b/.stats.yml index e1dcb32..dc04f86 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-78325ecc9bdc8e9850866fcdd3be3d209b06f151059c774afc7e6005a1775f09.yml -openapi_spec_hash: 19a34c8ddd46f81dd0b0850af5ee42f3 -config_hash: 620d4d190431b939dd17ac5d442918e6 +configured_endpoints: 23 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-e7ac06ada1aa9e0a37a95c1aa5927efe563fc2683c7a144638fa8bd6f68012ac.yml +openapi_spec_hash: 3ced2367a3f063e4eddce3a3253a4087 +config_hash: 12ef310e24ea5bae135eacbbe1a391ca diff --git a/api.md b/api.md index 9884d1d..2ac8f04 100644 --- a/api.md +++ b/api.md @@ -3,18 +3,29 @@ ```python from perplexity.types import ( APIPublicSearchResult, + BrowserSessionResponse, ChatMessageInput, ChatMessageOutput, Choice, ContextualizedEmbeddingObject, EmbeddingObject, EmbeddingsUsage, + ExecuteCodeResponse, + FileEntry, JsonSchemaFormat, + ListFilesResponse, + ListProcessesResponse, + ModifiedFilesResponse, + PauseSandboxResponse, + ProcessInfo, + ReadFileResponse, ResponseFormat, + SandboxSessionResponse, SearchResult, UsageInfo, UserLocation, WebSearchOptions, + WriteFileResponse, ) ``` @@ -92,6 +103,60 @@ Methods: - client.contextualized_embeddings.create(\*\*params) -> ContextualizedEmbeddingCreateResponse +# Browser + +## Sessions + +Methods: + +- client.browser.sessions.create() -> BrowserSessionResponse +- client.browser.sessions.delete(session_id) -> None + +# Sandbox + +## Sessions + +Methods: + +- client.sandbox.sessions.create(\*\*params) -> SandboxSessionResponse +- client.sandbox.sessions.delete(session_id) -> None +- client.sandbox.sessions.get(session_id) -> SandboxSessionResponse + +### Execute + +Methods: + +- client.sandbox.sessions.execute.create(session_id, \*\*params) -> ExecuteCodeResponse + +### Pause + +Methods: + +- client.sandbox.sessions.pause.create(session_id) -> PauseSandboxResponse + +### Resume + +Methods: + +- client.sandbox.sessions.resume.create(session_id, \*\*params) -> SandboxSessionResponse + +### Files + +Methods: + +- client.sandbox.sessions.files.list(session_id, \*\*params) -> ListFilesResponse +- client.sandbox.sessions.files.modified(session_id) -> ModifiedFilesResponse +- client.sandbox.sessions.files.read(session_id, \*\*params) -> ReadFileResponse +- client.sandbox.sessions.files.write(session_id, \*\*params) -> WriteFileResponse + +### Processes + +Methods: + +- client.sandbox.sessions.processes.list(session_id) -> ListProcessesResponse +- client.sandbox.sessions.processes.delete(pid, \*, session_id) -> None +- client.sandbox.sessions.processes.get(pid, \*, session_id) -> ProcessInfo + # Async ## Chat diff --git a/src/perplexity/_client.py b/src/perplexity/_client.py index bd84502..3ef259f 100644 --- a/src/perplexity/_client.py +++ b/src/perplexity/_client.py @@ -31,12 +31,14 @@ ) if TYPE_CHECKING: - from .resources import chat, async_, search, responses, embeddings, contextualized_embeddings + from .resources import chat, async_, search, browser, sandbox, responses, embeddings, contextualized_embeddings from .resources.search import SearchResource, AsyncSearchResource from .resources.chat.chat import ChatResource, AsyncChatResource from .resources.responses import ResponsesResource, AsyncResponsesResource from .resources.embeddings import EmbeddingsResource, AsyncEmbeddingsResource from .resources.async_.async_ import AsyncResource, AsyncAsyncResource + from .resources.browser.browser import BrowserResource, AsyncBrowserResource + from .resources.sandbox.sandbox import SandboxResource, AsyncSandboxResource from .resources.contextualized_embeddings import ( ContextualizedEmbeddingsResource, AsyncContextualizedEmbeddingsResource, @@ -141,6 +143,18 @@ def contextualized_embeddings(self) -> ContextualizedEmbeddingsResource: return ContextualizedEmbeddingsResource(self) + @cached_property + def browser(self) -> BrowserResource: + from .resources.browser import BrowserResource + + return BrowserResource(self) + + @cached_property + def sandbox(self) -> SandboxResource: + from .resources.sandbox import SandboxResource + + return SandboxResource(self) + @cached_property def async_(self) -> AsyncResource: from .resources.async_ import AsyncResource @@ -347,6 +361,18 @@ def contextualized_embeddings(self) -> AsyncContextualizedEmbeddingsResource: return AsyncContextualizedEmbeddingsResource(self) + @cached_property + def browser(self) -> AsyncBrowserResource: + from .resources.browser import AsyncBrowserResource + + return AsyncBrowserResource(self) + + @cached_property + def sandbox(self) -> AsyncSandboxResource: + from .resources.sandbox import AsyncSandboxResource + + return AsyncSandboxResource(self) + @cached_property def async_(self) -> AsyncAsyncResource: from .resources.async_ import AsyncAsyncResource @@ -502,6 +528,18 @@ def contextualized_embeddings(self) -> contextualized_embeddings.ContextualizedE return ContextualizedEmbeddingsResourceWithRawResponse(self._client.contextualized_embeddings) + @cached_property + def browser(self) -> browser.BrowserResourceWithRawResponse: + from .resources.browser import BrowserResourceWithRawResponse + + return BrowserResourceWithRawResponse(self._client.browser) + + @cached_property + def sandbox(self) -> sandbox.SandboxResourceWithRawResponse: + from .resources.sandbox import SandboxResourceWithRawResponse + + return SandboxResourceWithRawResponse(self._client.sandbox) + @cached_property def async_(self) -> async_.AsyncResourceWithRawResponse: from .resources.async_ import AsyncResourceWithRawResponse @@ -547,6 +585,18 @@ def contextualized_embeddings( return AsyncContextualizedEmbeddingsResourceWithRawResponse(self._client.contextualized_embeddings) + @cached_property + def browser(self) -> browser.AsyncBrowserResourceWithRawResponse: + from .resources.browser import AsyncBrowserResourceWithRawResponse + + return AsyncBrowserResourceWithRawResponse(self._client.browser) + + @cached_property + def sandbox(self) -> sandbox.AsyncSandboxResourceWithRawResponse: + from .resources.sandbox import AsyncSandboxResourceWithRawResponse + + return AsyncSandboxResourceWithRawResponse(self._client.sandbox) + @cached_property def async_(self) -> async_.AsyncAsyncResourceWithRawResponse: from .resources.async_ import AsyncAsyncResourceWithRawResponse @@ -592,6 +642,18 @@ def contextualized_embeddings( return ContextualizedEmbeddingsResourceWithStreamingResponse(self._client.contextualized_embeddings) + @cached_property + def browser(self) -> browser.BrowserResourceWithStreamingResponse: + from .resources.browser import BrowserResourceWithStreamingResponse + + return BrowserResourceWithStreamingResponse(self._client.browser) + + @cached_property + def sandbox(self) -> sandbox.SandboxResourceWithStreamingResponse: + from .resources.sandbox import SandboxResourceWithStreamingResponse + + return SandboxResourceWithStreamingResponse(self._client.sandbox) + @cached_property def async_(self) -> async_.AsyncResourceWithStreamingResponse: from .resources.async_ import AsyncResourceWithStreamingResponse @@ -637,6 +699,18 @@ def contextualized_embeddings( return AsyncContextualizedEmbeddingsResourceWithStreamingResponse(self._client.contextualized_embeddings) + @cached_property + def browser(self) -> browser.AsyncBrowserResourceWithStreamingResponse: + from .resources.browser import AsyncBrowserResourceWithStreamingResponse + + return AsyncBrowserResourceWithStreamingResponse(self._client.browser) + + @cached_property + def sandbox(self) -> sandbox.AsyncSandboxResourceWithStreamingResponse: + from .resources.sandbox import AsyncSandboxResourceWithStreamingResponse + + return AsyncSandboxResourceWithStreamingResponse(self._client.sandbox) + @cached_property def async_(self) -> async_.AsyncAsyncResourceWithStreamingResponse: from .resources.async_ import AsyncAsyncResourceWithStreamingResponse diff --git a/src/perplexity/resources/__init__.py b/src/perplexity/resources/__init__.py index 30b55b6..7096423 100644 --- a/src/perplexity/resources/__init__.py +++ b/src/perplexity/resources/__init__.py @@ -24,6 +24,22 @@ SearchResourceWithStreamingResponse, AsyncSearchResourceWithStreamingResponse, ) +from .browser import ( + BrowserResource, + AsyncBrowserResource, + BrowserResourceWithRawResponse, + AsyncBrowserResourceWithRawResponse, + BrowserResourceWithStreamingResponse, + AsyncBrowserResourceWithStreamingResponse, +) +from .sandbox import ( + SandboxResource, + AsyncSandboxResource, + SandboxResourceWithRawResponse, + AsyncSandboxResourceWithRawResponse, + SandboxResourceWithStreamingResponse, + AsyncSandboxResourceWithStreamingResponse, +) from .responses import ( ResponsesResource, AsyncResponsesResource, @@ -80,6 +96,18 @@ "AsyncContextualizedEmbeddingsResourceWithRawResponse", "ContextualizedEmbeddingsResourceWithStreamingResponse", "AsyncContextualizedEmbeddingsResourceWithStreamingResponse", + "BrowserResource", + "AsyncBrowserResource", + "BrowserResourceWithRawResponse", + "AsyncBrowserResourceWithRawResponse", + "BrowserResourceWithStreamingResponse", + "AsyncBrowserResourceWithStreamingResponse", + "SandboxResource", + "AsyncSandboxResource", + "SandboxResourceWithRawResponse", + "AsyncSandboxResourceWithRawResponse", + "SandboxResourceWithStreamingResponse", + "AsyncSandboxResourceWithStreamingResponse", "AsyncResource", "AsyncAsyncResource", "AsyncResourceWithRawResponse", diff --git a/src/perplexity/resources/browser/__init__.py b/src/perplexity/resources/browser/__init__.py new file mode 100644 index 0000000..e401ff7 --- /dev/null +++ b/src/perplexity/resources/browser/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .browser import ( + BrowserResource, + AsyncBrowserResource, + BrowserResourceWithRawResponse, + AsyncBrowserResourceWithRawResponse, + BrowserResourceWithStreamingResponse, + AsyncBrowserResourceWithStreamingResponse, +) +from .sessions import ( + SessionsResource, + AsyncSessionsResource, + SessionsResourceWithRawResponse, + AsyncSessionsResourceWithRawResponse, + SessionsResourceWithStreamingResponse, + AsyncSessionsResourceWithStreamingResponse, +) + +__all__ = [ + "SessionsResource", + "AsyncSessionsResource", + "SessionsResourceWithRawResponse", + "AsyncSessionsResourceWithRawResponse", + "SessionsResourceWithStreamingResponse", + "AsyncSessionsResourceWithStreamingResponse", + "BrowserResource", + "AsyncBrowserResource", + "BrowserResourceWithRawResponse", + "AsyncBrowserResourceWithRawResponse", + "BrowserResourceWithStreamingResponse", + "AsyncBrowserResourceWithStreamingResponse", +] diff --git a/src/perplexity/resources/browser/browser.py b/src/perplexity/resources/browser/browser.py new file mode 100644 index 0000000..378e5a5 --- /dev/null +++ b/src/perplexity/resources/browser/browser.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .sessions import ( + SessionsResource, + AsyncSessionsResource, + SessionsResourceWithRawResponse, + AsyncSessionsResourceWithRawResponse, + SessionsResourceWithStreamingResponse, + AsyncSessionsResourceWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["BrowserResource", "AsyncBrowserResource"] + + +class BrowserResource(SyncAPIResource): + @cached_property + def sessions(self) -> SessionsResource: + return SessionsResource(self._client) + + @cached_property + def with_raw_response(self) -> BrowserResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return BrowserResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrowserResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return BrowserResourceWithStreamingResponse(self) + + +class AsyncBrowserResource(AsyncAPIResource): + @cached_property + def sessions(self) -> AsyncSessionsResource: + return AsyncSessionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBrowserResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncBrowserResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrowserResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncBrowserResourceWithStreamingResponse(self) + + +class BrowserResourceWithRawResponse: + def __init__(self, browser: BrowserResource) -> None: + self._browser = browser + + @cached_property + def sessions(self) -> SessionsResourceWithRawResponse: + return SessionsResourceWithRawResponse(self._browser.sessions) + + +class AsyncBrowserResourceWithRawResponse: + def __init__(self, browser: AsyncBrowserResource) -> None: + self._browser = browser + + @cached_property + def sessions(self) -> AsyncSessionsResourceWithRawResponse: + return AsyncSessionsResourceWithRawResponse(self._browser.sessions) + + +class BrowserResourceWithStreamingResponse: + def __init__(self, browser: BrowserResource) -> None: + self._browser = browser + + @cached_property + def sessions(self) -> SessionsResourceWithStreamingResponse: + return SessionsResourceWithStreamingResponse(self._browser.sessions) + + +class AsyncBrowserResourceWithStreamingResponse: + def __init__(self, browser: AsyncBrowserResource) -> None: + self._browser = browser + + @cached_property + def sessions(self) -> AsyncSessionsResourceWithStreamingResponse: + return AsyncSessionsResourceWithStreamingResponse(self._browser.sessions) diff --git a/src/perplexity/resources/browser/sessions.py b/src/perplexity/resources/browser/sessions.py new file mode 100644 index 0000000..6655ba5 --- /dev/null +++ b/src/perplexity/resources/browser/sessions.py @@ -0,0 +1,217 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Query, Headers, NoneType, NotGiven, not_given +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.shared.browser_session_response import BrowserSessionResponse + +__all__ = ["SessionsResource", "AsyncSessionsResource"] + + +class SessionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SessionsResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return SessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return SessionsResourceWithStreamingResponse(self) + + def create( + self, + *, + # 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, + ) -> BrowserSessionResponse: + """Create a new remote browser session for CDP-based automation.""" + return self._post( + "/v1/browser/sessions", + body={}, + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BrowserSessionResponse, + ) + + def delete( + self, + session_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, + ) -> None: + """ + Stop and clean up a remote browser session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/v1/browser/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncSessionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSessionsResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncSessionsResourceWithStreamingResponse(self) + + async def create( + self, + *, + # 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, + ) -> BrowserSessionResponse: + """Create a new remote browser session for CDP-based automation.""" + return await self._post( + "/v1/browser/sessions", + body={}, + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BrowserSessionResponse, + ) + + async def delete( + self, + session_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, + ) -> None: + """ + Stop and clean up a remote browser session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/v1/browser/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class SessionsResourceWithRawResponse: + def __init__(self, sessions: SessionsResource) -> None: + self._sessions = sessions + + self.create = to_raw_response_wrapper( + sessions.create, + ) + self.delete = to_raw_response_wrapper( + sessions.delete, + ) + + +class AsyncSessionsResourceWithRawResponse: + def __init__(self, sessions: AsyncSessionsResource) -> None: + self._sessions = sessions + + self.create = async_to_raw_response_wrapper( + sessions.create, + ) + self.delete = async_to_raw_response_wrapper( + sessions.delete, + ) + + +class SessionsResourceWithStreamingResponse: + def __init__(self, sessions: SessionsResource) -> None: + self._sessions = sessions + + self.create = to_streamed_response_wrapper( + sessions.create, + ) + self.delete = to_streamed_response_wrapper( + sessions.delete, + ) + + +class AsyncSessionsResourceWithStreamingResponse: + def __init__(self, sessions: AsyncSessionsResource) -> None: + self._sessions = sessions + + self.create = async_to_streamed_response_wrapper( + sessions.create, + ) + self.delete = async_to_streamed_response_wrapper( + sessions.delete, + ) diff --git a/src/perplexity/resources/sandbox/__init__.py b/src/perplexity/resources/sandbox/__init__.py new file mode 100644 index 0000000..1e564fa --- /dev/null +++ b/src/perplexity/resources/sandbox/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .sandbox import ( + SandboxResource, + AsyncSandboxResource, + SandboxResourceWithRawResponse, + AsyncSandboxResourceWithRawResponse, + SandboxResourceWithStreamingResponse, + AsyncSandboxResourceWithStreamingResponse, +) +from .sessions import ( + SessionsResource, + AsyncSessionsResource, + SessionsResourceWithRawResponse, + AsyncSessionsResourceWithRawResponse, + SessionsResourceWithStreamingResponse, + AsyncSessionsResourceWithStreamingResponse, +) + +__all__ = [ + "SessionsResource", + "AsyncSessionsResource", + "SessionsResourceWithRawResponse", + "AsyncSessionsResourceWithRawResponse", + "SessionsResourceWithStreamingResponse", + "AsyncSessionsResourceWithStreamingResponse", + "SandboxResource", + "AsyncSandboxResource", + "SandboxResourceWithRawResponse", + "AsyncSandboxResourceWithRawResponse", + "SandboxResourceWithStreamingResponse", + "AsyncSandboxResourceWithStreamingResponse", +] diff --git a/src/perplexity/resources/sandbox/sandbox.py b/src/perplexity/resources/sandbox/sandbox.py new file mode 100644 index 0000000..8dd6825 --- /dev/null +++ b/src/perplexity/resources/sandbox/sandbox.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .sessions.sessions import ( + SessionsResource, + AsyncSessionsResource, + SessionsResourceWithRawResponse, + AsyncSessionsResourceWithRawResponse, + SessionsResourceWithStreamingResponse, + AsyncSessionsResourceWithStreamingResponse, +) + +__all__ = ["SandboxResource", "AsyncSandboxResource"] + + +class SandboxResource(SyncAPIResource): + @cached_property + def sessions(self) -> SessionsResource: + return SessionsResource(self._client) + + @cached_property + def with_raw_response(self) -> SandboxResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return SandboxResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SandboxResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return SandboxResourceWithStreamingResponse(self) + + +class AsyncSandboxResource(AsyncAPIResource): + @cached_property + def sessions(self) -> AsyncSessionsResource: + return AsyncSessionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSandboxResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncSandboxResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSandboxResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncSandboxResourceWithStreamingResponse(self) + + +class SandboxResourceWithRawResponse: + def __init__(self, sandbox: SandboxResource) -> None: + self._sandbox = sandbox + + @cached_property + def sessions(self) -> SessionsResourceWithRawResponse: + return SessionsResourceWithRawResponse(self._sandbox.sessions) + + +class AsyncSandboxResourceWithRawResponse: + def __init__(self, sandbox: AsyncSandboxResource) -> None: + self._sandbox = sandbox + + @cached_property + def sessions(self) -> AsyncSessionsResourceWithRawResponse: + return AsyncSessionsResourceWithRawResponse(self._sandbox.sessions) + + +class SandboxResourceWithStreamingResponse: + def __init__(self, sandbox: SandboxResource) -> None: + self._sandbox = sandbox + + @cached_property + def sessions(self) -> SessionsResourceWithStreamingResponse: + return SessionsResourceWithStreamingResponse(self._sandbox.sessions) + + +class AsyncSandboxResourceWithStreamingResponse: + def __init__(self, sandbox: AsyncSandboxResource) -> None: + self._sandbox = sandbox + + @cached_property + def sessions(self) -> AsyncSessionsResourceWithStreamingResponse: + return AsyncSessionsResourceWithStreamingResponse(self._sandbox.sessions) diff --git a/src/perplexity/resources/sandbox/sessions/__init__.py b/src/perplexity/resources/sandbox/sessions/__init__.py new file mode 100644 index 0000000..75f227b --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/__init__.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .files import ( + FilesResource, + AsyncFilesResource, + FilesResourceWithRawResponse, + AsyncFilesResourceWithRawResponse, + FilesResourceWithStreamingResponse, + AsyncFilesResourceWithStreamingResponse, +) +from .pause import ( + PauseResource, + AsyncPauseResource, + PauseResourceWithRawResponse, + AsyncPauseResourceWithRawResponse, + PauseResourceWithStreamingResponse, + AsyncPauseResourceWithStreamingResponse, +) +from .resume import ( + ResumeResource, + AsyncResumeResource, + ResumeResourceWithRawResponse, + AsyncResumeResourceWithRawResponse, + ResumeResourceWithStreamingResponse, + AsyncResumeResourceWithStreamingResponse, +) +from .execute import ( + ExecuteResource, + AsyncExecuteResource, + ExecuteResourceWithRawResponse, + AsyncExecuteResourceWithRawResponse, + ExecuteResourceWithStreamingResponse, + AsyncExecuteResourceWithStreamingResponse, +) +from .sessions import ( + SessionsResource, + AsyncSessionsResource, + SessionsResourceWithRawResponse, + AsyncSessionsResourceWithRawResponse, + SessionsResourceWithStreamingResponse, + AsyncSessionsResourceWithStreamingResponse, +) +from .processes import ( + ProcessesResource, + AsyncProcessesResource, + ProcessesResourceWithRawResponse, + AsyncProcessesResourceWithRawResponse, + ProcessesResourceWithStreamingResponse, + AsyncProcessesResourceWithStreamingResponse, +) + +__all__ = [ + "ExecuteResource", + "AsyncExecuteResource", + "ExecuteResourceWithRawResponse", + "AsyncExecuteResourceWithRawResponse", + "ExecuteResourceWithStreamingResponse", + "AsyncExecuteResourceWithStreamingResponse", + "PauseResource", + "AsyncPauseResource", + "PauseResourceWithRawResponse", + "AsyncPauseResourceWithRawResponse", + "PauseResourceWithStreamingResponse", + "AsyncPauseResourceWithStreamingResponse", + "ResumeResource", + "AsyncResumeResource", + "ResumeResourceWithRawResponse", + "AsyncResumeResourceWithRawResponse", + "ResumeResourceWithStreamingResponse", + "AsyncResumeResourceWithStreamingResponse", + "FilesResource", + "AsyncFilesResource", + "FilesResourceWithRawResponse", + "AsyncFilesResourceWithRawResponse", + "FilesResourceWithStreamingResponse", + "AsyncFilesResourceWithStreamingResponse", + "ProcessesResource", + "AsyncProcessesResource", + "ProcessesResourceWithRawResponse", + "AsyncProcessesResourceWithRawResponse", + "ProcessesResourceWithStreamingResponse", + "AsyncProcessesResourceWithStreamingResponse", + "SessionsResource", + "AsyncSessionsResource", + "SessionsResourceWithRawResponse", + "AsyncSessionsResourceWithRawResponse", + "SessionsResourceWithStreamingResponse", + "AsyncSessionsResourceWithStreamingResponse", +] diff --git a/src/perplexity/resources/sandbox/sessions/execute.py b/src/perplexity/resources/sandbox/sessions/execute.py new file mode 100644 index 0000000..6b63045 --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/execute.py @@ -0,0 +1,209 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, 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.sandbox.sessions import execute_create_params +from ....types.shared.execute_code_response import ExecuteCodeResponse + +__all__ = ["ExecuteResource", "AsyncExecuteResource"] + + +class ExecuteResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ExecuteResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return ExecuteResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ExecuteResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return ExecuteResourceWithStreamingResponse(self) + + def create( + self, + session_id: str, + *, + code: str, + language: Literal["python", "bash"], + background: bool | Omit = omit, + execution_timeout: int | Omit = omit, + # 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, + ) -> ExecuteCodeResponse: + """ + Execute Python or Bash code in the sandbox environment. + + Args: + code: Base64 encoded code to execute + + language: Programming language of the code + + background: Run in background (bash only) + + execution_timeout: Execution timeout in seconds (max 120) + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._post( + f"/v1/sandbox/sessions/{session_id}/execute", + body=maybe_transform( + { + "code": code, + "language": language, + "background": background, + "execution_timeout": execution_timeout, + }, + execute_create_params.ExecuteCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExecuteCodeResponse, + ) + + +class AsyncExecuteResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncExecuteResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncExecuteResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncExecuteResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncExecuteResourceWithStreamingResponse(self) + + async def create( + self, + session_id: str, + *, + code: str, + language: Literal["python", "bash"], + background: bool | Omit = omit, + execution_timeout: int | Omit = omit, + # 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, + ) -> ExecuteCodeResponse: + """ + Execute Python or Bash code in the sandbox environment. + + Args: + code: Base64 encoded code to execute + + language: Programming language of the code + + background: Run in background (bash only) + + execution_timeout: Execution timeout in seconds (max 120) + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._post( + f"/v1/sandbox/sessions/{session_id}/execute", + body=await async_maybe_transform( + { + "code": code, + "language": language, + "background": background, + "execution_timeout": execution_timeout, + }, + execute_create_params.ExecuteCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExecuteCodeResponse, + ) + + +class ExecuteResourceWithRawResponse: + def __init__(self, execute: ExecuteResource) -> None: + self._execute = execute + + self.create = to_raw_response_wrapper( + execute.create, + ) + + +class AsyncExecuteResourceWithRawResponse: + def __init__(self, execute: AsyncExecuteResource) -> None: + self._execute = execute + + self.create = async_to_raw_response_wrapper( + execute.create, + ) + + +class ExecuteResourceWithStreamingResponse: + def __init__(self, execute: ExecuteResource) -> None: + self._execute = execute + + self.create = to_streamed_response_wrapper( + execute.create, + ) + + +class AsyncExecuteResourceWithStreamingResponse: + def __init__(self, execute: AsyncExecuteResource) -> None: + self._execute = execute + + self.create = async_to_streamed_response_wrapper( + execute.create, + ) diff --git a/src/perplexity/resources/sandbox/sessions/files.py b/src/perplexity/resources/sandbox/sessions/files.py new file mode 100644 index 0000000..7773fb7 --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/files.py @@ -0,0 +1,478 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, 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.sandbox.sessions import file_list_params, file_read_params, file_write_params +from ....types.shared.read_file_response import ReadFileResponse +from ....types.shared.list_files_response import ListFilesResponse +from ....types.shared.write_file_response import WriteFileResponse +from ....types.shared.modified_files_response import ModifiedFilesResponse + +__all__ = ["FilesResource", "AsyncFilesResource"] + + +class FilesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FilesResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return FilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return FilesResourceWithStreamingResponse(self) + + def list( + self, + session_id: str, + *, + depth: int | Omit = omit, + path: str | Omit = omit, + # 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, + ) -> ListFilesResponse: + """ + List files and directories in the sandbox filesystem. + + Args: + depth: Directory traversal depth + + path: Directory path to list + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}/files/list", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "depth": depth, + "path": path, + }, + file_list_params.FileListParams, + ), + ), + cast_to=ListFilesResponse, + ) + + def modified( + self, + session_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, + ) -> ModifiedFilesResponse: + """ + Get a list of files that have been modified since the session started. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}/files/modified", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ModifiedFilesResponse, + ) + + def read( + self, + session_id: str, + *, + path: 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, + ) -> ReadFileResponse: + """Read a file from the sandbox filesystem. + + Content is returned base64 encoded. + + Args: + path: Absolute path to the file to read + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}/files", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"path": path}, file_read_params.FileReadParams), + ), + cast_to=ReadFileResponse, + ) + + def write( + self, + session_id: str, + *, + content: str, + path: 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, + ) -> WriteFileResponse: + """Write a file to the sandbox filesystem. + + Content must be base64 encoded. + + Args: + content: Base64 encoded file content + + path: Absolute path where the file should be written + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._post( + f"/v1/sandbox/sessions/{session_id}/files", + body=maybe_transform( + { + "content": content, + "path": path, + }, + file_write_params.FileWriteParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WriteFileResponse, + ) + + +class AsyncFilesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFilesResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncFilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncFilesResourceWithStreamingResponse(self) + + async def list( + self, + session_id: str, + *, + depth: int | Omit = omit, + path: str | Omit = omit, + # 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, + ) -> ListFilesResponse: + """ + List files and directories in the sandbox filesystem. + + Args: + depth: Directory traversal depth + + path: Directory path to list + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}/files/list", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "depth": depth, + "path": path, + }, + file_list_params.FileListParams, + ), + ), + cast_to=ListFilesResponse, + ) + + async def modified( + self, + session_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, + ) -> ModifiedFilesResponse: + """ + Get a list of files that have been modified since the session started. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}/files/modified", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ModifiedFilesResponse, + ) + + async def read( + self, + session_id: str, + *, + path: 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, + ) -> ReadFileResponse: + """Read a file from the sandbox filesystem. + + Content is returned base64 encoded. + + Args: + path: Absolute path to the file to read + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}/files", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"path": path}, file_read_params.FileReadParams), + ), + cast_to=ReadFileResponse, + ) + + async def write( + self, + session_id: str, + *, + content: str, + path: 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, + ) -> WriteFileResponse: + """Write a file to the sandbox filesystem. + + Content must be base64 encoded. + + Args: + content: Base64 encoded file content + + path: Absolute path where the file should be written + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._post( + f"/v1/sandbox/sessions/{session_id}/files", + body=await async_maybe_transform( + { + "content": content, + "path": path, + }, + file_write_params.FileWriteParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WriteFileResponse, + ) + + +class FilesResourceWithRawResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.list = to_raw_response_wrapper( + files.list, + ) + self.modified = to_raw_response_wrapper( + files.modified, + ) + self.read = to_raw_response_wrapper( + files.read, + ) + self.write = to_raw_response_wrapper( + files.write, + ) + + +class AsyncFilesResourceWithRawResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.list = async_to_raw_response_wrapper( + files.list, + ) + self.modified = async_to_raw_response_wrapper( + files.modified, + ) + self.read = async_to_raw_response_wrapper( + files.read, + ) + self.write = async_to_raw_response_wrapper( + files.write, + ) + + +class FilesResourceWithStreamingResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.list = to_streamed_response_wrapper( + files.list, + ) + self.modified = to_streamed_response_wrapper( + files.modified, + ) + self.read = to_streamed_response_wrapper( + files.read, + ) + self.write = to_streamed_response_wrapper( + files.write, + ) + + +class AsyncFilesResourceWithStreamingResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.list = async_to_streamed_response_wrapper( + files.list, + ) + self.modified = async_to_streamed_response_wrapper( + files.modified, + ) + self.read = async_to_streamed_response_wrapper( + files.read, + ) + self.write = async_to_streamed_response_wrapper( + files.write, + ) diff --git a/src/perplexity/resources/sandbox/sessions/pause.py b/src/perplexity/resources/sandbox/sessions/pause.py new file mode 100644 index 0000000..bf5a486 --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/pause.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +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.shared.pause_sandbox_response import PauseSandboxResponse + +__all__ = ["PauseResource", "AsyncPauseResource"] + + +class PauseResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PauseResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return PauseResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PauseResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return PauseResourceWithStreamingResponse(self) + + def create( + self, + session_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, + ) -> PauseSandboxResponse: + """ + Pause the sandbox and snapshot its state to S3 for later resumption. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._post( + f"/v1/sandbox/sessions/{session_id}/pause", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PauseSandboxResponse, + ) + + +class AsyncPauseResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPauseResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncPauseResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPauseResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncPauseResourceWithStreamingResponse(self) + + async def create( + self, + session_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, + ) -> PauseSandboxResponse: + """ + Pause the sandbox and snapshot its state to S3 for later resumption. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._post( + f"/v1/sandbox/sessions/{session_id}/pause", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PauseSandboxResponse, + ) + + +class PauseResourceWithRawResponse: + def __init__(self, pause: PauseResource) -> None: + self._pause = pause + + self.create = to_raw_response_wrapper( + pause.create, + ) + + +class AsyncPauseResourceWithRawResponse: + def __init__(self, pause: AsyncPauseResource) -> None: + self._pause = pause + + self.create = async_to_raw_response_wrapper( + pause.create, + ) + + +class PauseResourceWithStreamingResponse: + def __init__(self, pause: PauseResource) -> None: + self._pause = pause + + self.create = to_streamed_response_wrapper( + pause.create, + ) + + +class AsyncPauseResourceWithStreamingResponse: + def __init__(self, pause: AsyncPauseResource) -> None: + self._pause = pause + + self.create = async_to_streamed_response_wrapper( + pause.create, + ) diff --git a/src/perplexity/resources/sandbox/sessions/processes.py b/src/perplexity/resources/sandbox/sessions/processes.py new file mode 100644 index 0000000..61f92ac --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/processes.py @@ -0,0 +1,326 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Query, Headers, NoneType, NotGiven, not_given +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.shared.process_info import ProcessInfo +from ....types.shared.list_processes_response import ListProcessesResponse + +__all__ = ["ProcessesResource", "AsyncProcessesResource"] + + +class ProcessesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ProcessesResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return ProcessesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ProcessesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return ProcessesResourceWithStreamingResponse(self) + + def list( + self, + session_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, + ) -> ListProcessesResponse: + """ + List all running processes in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}/processes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ListProcessesResponse, + ) + + def delete( + self, + pid: int, + *, + session_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, + ) -> None: + """ + Kill a running process in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/v1/sandbox/sessions/{session_id}/processes/{pid}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + pid: int, + *, + session_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, + ) -> ProcessInfo: + """ + Get details of a specific process in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}/processes/{pid}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ProcessInfo, + ) + + +class AsyncProcessesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncProcessesResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncProcessesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncProcessesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncProcessesResourceWithStreamingResponse(self) + + async def list( + self, + session_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, + ) -> ListProcessesResponse: + """ + List all running processes in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}/processes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ListProcessesResponse, + ) + + async def delete( + self, + pid: int, + *, + session_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, + ) -> None: + """ + Kill a running process in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/v1/sandbox/sessions/{session_id}/processes/{pid}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + pid: int, + *, + session_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, + ) -> ProcessInfo: + """ + Get details of a specific process in the sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}/processes/{pid}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ProcessInfo, + ) + + +class ProcessesResourceWithRawResponse: + def __init__(self, processes: ProcessesResource) -> None: + self._processes = processes + + self.list = to_raw_response_wrapper( + processes.list, + ) + self.delete = to_raw_response_wrapper( + processes.delete, + ) + self.get = to_raw_response_wrapper( + processes.get, + ) + + +class AsyncProcessesResourceWithRawResponse: + def __init__(self, processes: AsyncProcessesResource) -> None: + self._processes = processes + + self.list = async_to_raw_response_wrapper( + processes.list, + ) + self.delete = async_to_raw_response_wrapper( + processes.delete, + ) + self.get = async_to_raw_response_wrapper( + processes.get, + ) + + +class ProcessesResourceWithStreamingResponse: + def __init__(self, processes: ProcessesResource) -> None: + self._processes = processes + + self.list = to_streamed_response_wrapper( + processes.list, + ) + self.delete = to_streamed_response_wrapper( + processes.delete, + ) + self.get = to_streamed_response_wrapper( + processes.get, + ) + + +class AsyncProcessesResourceWithStreamingResponse: + def __init__(self, processes: AsyncProcessesResource) -> None: + self._processes = processes + + self.list = async_to_streamed_response_wrapper( + processes.list, + ) + self.delete = async_to_streamed_response_wrapper( + processes.delete, + ) + self.get = async_to_streamed_response_wrapper( + processes.get, + ) diff --git a/src/perplexity/resources/sandbox/sessions/resume.py b/src/perplexity/resources/sandbox/sessions/resume.py new file mode 100644 index 0000000..4ff6184 --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/resume.py @@ -0,0 +1,175 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, 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.sandbox.sessions import resume_create_params +from ....types.shared.sandbox_session_response import SandboxSessionResponse + +__all__ = ["ResumeResource", "AsyncResumeResource"] + + +class ResumeResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ResumeResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return ResumeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResumeResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return ResumeResourceWithStreamingResponse(self) + + def create( + self, + session_id: str, + *, + network_enabled: bool | Omit = omit, + # 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, + ) -> SandboxSessionResponse: + """ + Resume a paused sandbox session from its S3 snapshot. + + Args: + network_enabled: Override network setting when resuming + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._post( + f"/v1/sandbox/sessions/{session_id}/resume", + body=maybe_transform({"network_enabled": network_enabled}, resume_create_params.ResumeCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + +class AsyncResumeResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncResumeResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncResumeResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResumeResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncResumeResourceWithStreamingResponse(self) + + async def create( + self, + session_id: str, + *, + network_enabled: bool | Omit = omit, + # 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, + ) -> SandboxSessionResponse: + """ + Resume a paused sandbox session from its S3 snapshot. + + Args: + network_enabled: Override network setting when resuming + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._post( + f"/v1/sandbox/sessions/{session_id}/resume", + body=await async_maybe_transform( + {"network_enabled": network_enabled}, resume_create_params.ResumeCreateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + +class ResumeResourceWithRawResponse: + def __init__(self, resume: ResumeResource) -> None: + self._resume = resume + + self.create = to_raw_response_wrapper( + resume.create, + ) + + +class AsyncResumeResourceWithRawResponse: + def __init__(self, resume: AsyncResumeResource) -> None: + self._resume = resume + + self.create = async_to_raw_response_wrapper( + resume.create, + ) + + +class ResumeResourceWithStreamingResponse: + def __init__(self, resume: ResumeResource) -> None: + self._resume = resume + + self.create = to_streamed_response_wrapper( + resume.create, + ) + + +class AsyncResumeResourceWithStreamingResponse: + def __init__(self, resume: AsyncResumeResource) -> None: + self._resume = resume + + self.create = async_to_streamed_response_wrapper( + resume.create, + ) diff --git a/src/perplexity/resources/sandbox/sessions/sessions.py b/src/perplexity/resources/sandbox/sessions/sessions.py new file mode 100644 index 0000000..2907002 --- /dev/null +++ b/src/perplexity/resources/sandbox/sessions/sessions.py @@ -0,0 +1,487 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .files import ( + FilesResource, + AsyncFilesResource, + FilesResourceWithRawResponse, + AsyncFilesResourceWithRawResponse, + FilesResourceWithStreamingResponse, + AsyncFilesResourceWithStreamingResponse, +) +from .pause import ( + PauseResource, + AsyncPauseResource, + PauseResourceWithRawResponse, + AsyncPauseResourceWithRawResponse, + PauseResourceWithStreamingResponse, + AsyncPauseResourceWithStreamingResponse, +) +from .resume import ( + ResumeResource, + AsyncResumeResource, + ResumeResourceWithRawResponse, + AsyncResumeResourceWithRawResponse, + ResumeResourceWithStreamingResponse, + AsyncResumeResourceWithStreamingResponse, +) +from .execute import ( + ExecuteResource, + AsyncExecuteResource, + ExecuteResourceWithRawResponse, + AsyncExecuteResourceWithRawResponse, + ExecuteResourceWithStreamingResponse, + AsyncExecuteResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from .processes import ( + ProcessesResource, + AsyncProcessesResource, + ProcessesResourceWithRawResponse, + AsyncProcessesResourceWithRawResponse, + ProcessesResourceWithStreamingResponse, + AsyncProcessesResourceWithStreamingResponse, +) +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.sandbox import session_create_params +from ....types.shared.sandbox_session_response import SandboxSessionResponse + +__all__ = ["SessionsResource", "AsyncSessionsResource"] + + +class SessionsResource(SyncAPIResource): + @cached_property + def execute(self) -> ExecuteResource: + return ExecuteResource(self._client) + + @cached_property + def pause(self) -> PauseResource: + return PauseResource(self._client) + + @cached_property + def resume(self) -> ResumeResource: + return ResumeResource(self._client) + + @cached_property + def files(self) -> FilesResource: + return FilesResource(self._client) + + @cached_property + def processes(self) -> ProcessesResource: + return ProcessesResource(self._client) + + @cached_property + def with_raw_response(self) -> SessionsResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return SessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return SessionsResourceWithStreamingResponse(self) + + def create( + self, + *, + network_enabled: bool | Omit = omit, + # 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, + ) -> SandboxSessionResponse: + """ + Create a new isolated sandbox environment for code execution. + + Args: + network_enabled: Enable network access in the sandbox + + 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/sandbox/sessions", + body=maybe_transform({"network_enabled": network_enabled}, session_create_params.SessionCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + def delete( + self, + session_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, + ) -> None: + """ + Terminate and clean up a sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/v1/sandbox/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + session_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, + ) -> SandboxSessionResponse: + """ + Retrieve the current status of a sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._get( + f"/v1/sandbox/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + +class AsyncSessionsResource(AsyncAPIResource): + @cached_property + def execute(self) -> AsyncExecuteResource: + return AsyncExecuteResource(self._client) + + @cached_property + def pause(self) -> AsyncPauseResource: + return AsyncPauseResource(self._client) + + @cached_property + def resume(self) -> AsyncResumeResource: + return AsyncResumeResource(self._client) + + @cached_property + def files(self) -> AsyncFilesResource: + return AsyncFilesResource(self._client) + + @cached_property + def processes(self) -> AsyncProcessesResource: + return AsyncProcessesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSessionsResourceWithRawResponse: + """ + 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/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers + """ + return AsyncSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response + """ + return AsyncSessionsResourceWithStreamingResponse(self) + + async def create( + self, + *, + network_enabled: bool | Omit = omit, + # 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, + ) -> SandboxSessionResponse: + """ + Create a new isolated sandbox environment for code execution. + + Args: + network_enabled: Enable network access in the sandbox + + 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/sandbox/sessions", + body=await async_maybe_transform( + {"network_enabled": network_enabled}, session_create_params.SessionCreateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + async def delete( + self, + session_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, + ) -> None: + """ + Terminate and clean up a sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/v1/sandbox/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + session_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, + ) -> SandboxSessionResponse: + """ + Retrieve the current status of a sandbox session. + + 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 session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._get( + f"/v1/sandbox/sessions/{session_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SandboxSessionResponse, + ) + + +class SessionsResourceWithRawResponse: + def __init__(self, sessions: SessionsResource) -> None: + self._sessions = sessions + + self.create = to_raw_response_wrapper( + sessions.create, + ) + self.delete = to_raw_response_wrapper( + sessions.delete, + ) + self.get = to_raw_response_wrapper( + sessions.get, + ) + + @cached_property + def execute(self) -> ExecuteResourceWithRawResponse: + return ExecuteResourceWithRawResponse(self._sessions.execute) + + @cached_property + def pause(self) -> PauseResourceWithRawResponse: + return PauseResourceWithRawResponse(self._sessions.pause) + + @cached_property + def resume(self) -> ResumeResourceWithRawResponse: + return ResumeResourceWithRawResponse(self._sessions.resume) + + @cached_property + def files(self) -> FilesResourceWithRawResponse: + return FilesResourceWithRawResponse(self._sessions.files) + + @cached_property + def processes(self) -> ProcessesResourceWithRawResponse: + return ProcessesResourceWithRawResponse(self._sessions.processes) + + +class AsyncSessionsResourceWithRawResponse: + def __init__(self, sessions: AsyncSessionsResource) -> None: + self._sessions = sessions + + self.create = async_to_raw_response_wrapper( + sessions.create, + ) + self.delete = async_to_raw_response_wrapper( + sessions.delete, + ) + self.get = async_to_raw_response_wrapper( + sessions.get, + ) + + @cached_property + def execute(self) -> AsyncExecuteResourceWithRawResponse: + return AsyncExecuteResourceWithRawResponse(self._sessions.execute) + + @cached_property + def pause(self) -> AsyncPauseResourceWithRawResponse: + return AsyncPauseResourceWithRawResponse(self._sessions.pause) + + @cached_property + def resume(self) -> AsyncResumeResourceWithRawResponse: + return AsyncResumeResourceWithRawResponse(self._sessions.resume) + + @cached_property + def files(self) -> AsyncFilesResourceWithRawResponse: + return AsyncFilesResourceWithRawResponse(self._sessions.files) + + @cached_property + def processes(self) -> AsyncProcessesResourceWithRawResponse: + return AsyncProcessesResourceWithRawResponse(self._sessions.processes) + + +class SessionsResourceWithStreamingResponse: + def __init__(self, sessions: SessionsResource) -> None: + self._sessions = sessions + + self.create = to_streamed_response_wrapper( + sessions.create, + ) + self.delete = to_streamed_response_wrapper( + sessions.delete, + ) + self.get = to_streamed_response_wrapper( + sessions.get, + ) + + @cached_property + def execute(self) -> ExecuteResourceWithStreamingResponse: + return ExecuteResourceWithStreamingResponse(self._sessions.execute) + + @cached_property + def pause(self) -> PauseResourceWithStreamingResponse: + return PauseResourceWithStreamingResponse(self._sessions.pause) + + @cached_property + def resume(self) -> ResumeResourceWithStreamingResponse: + return ResumeResourceWithStreamingResponse(self._sessions.resume) + + @cached_property + def files(self) -> FilesResourceWithStreamingResponse: + return FilesResourceWithStreamingResponse(self._sessions.files) + + @cached_property + def processes(self) -> ProcessesResourceWithStreamingResponse: + return ProcessesResourceWithStreamingResponse(self._sessions.processes) + + +class AsyncSessionsResourceWithStreamingResponse: + def __init__(self, sessions: AsyncSessionsResource) -> None: + self._sessions = sessions + + self.create = async_to_streamed_response_wrapper( + sessions.create, + ) + self.delete = async_to_streamed_response_wrapper( + sessions.delete, + ) + self.get = async_to_streamed_response_wrapper( + sessions.get, + ) + + @cached_property + def execute(self) -> AsyncExecuteResourceWithStreamingResponse: + return AsyncExecuteResourceWithStreamingResponse(self._sessions.execute) + + @cached_property + def pause(self) -> AsyncPauseResourceWithStreamingResponse: + return AsyncPauseResourceWithStreamingResponse(self._sessions.pause) + + @cached_property + def resume(self) -> AsyncResumeResourceWithStreamingResponse: + return AsyncResumeResourceWithStreamingResponse(self._sessions.resume) + + @cached_property + def files(self) -> AsyncFilesResourceWithStreamingResponse: + return AsyncFilesResourceWithStreamingResponse(self._sessions.files) + + @cached_property + def processes(self) -> AsyncProcessesResourceWithStreamingResponse: + return AsyncProcessesResourceWithStreamingResponse(self._sessions.processes) diff --git a/src/perplexity/types/__init__.py b/src/perplexity/types/__init__.py index a9b252f..9ce67d1 100644 --- a/src/perplexity/types/__init__.py +++ b/src/perplexity/types/__init__.py @@ -4,7 +4,9 @@ from .shared import ( Choice as Choice, + FileEntry as FileEntry, UsageInfo as UsageInfo, + ProcessInfo as ProcessInfo, SearchResult as SearchResult, UserLocation as UserLocation, ResponseFormat as ResponseFormat, @@ -12,9 +14,18 @@ EmbeddingsUsage as EmbeddingsUsage, ChatMessageInput as ChatMessageInput, JsonSchemaFormat as JsonSchemaFormat, + ReadFileResponse as ReadFileResponse, WebSearchOptions as WebSearchOptions, ChatMessageOutput as ChatMessageOutput, + ListFilesResponse as ListFilesResponse, + WriteFileResponse as WriteFileResponse, + ExecuteCodeResponse as ExecuteCodeResponse, + PauseSandboxResponse as PauseSandboxResponse, APIPublicSearchResult as APIPublicSearchResult, + ListProcessesResponse as ListProcessesResponse, + ModifiedFilesResponse as ModifiedFilesResponse, + BrowserSessionResponse as BrowserSessionResponse, + SandboxSessionResponse as SandboxSessionResponse, ContextualizedEmbeddingObject as ContextualizedEmbeddingObject, ) from .annotation import Annotation as Annotation diff --git a/src/perplexity/types/browser/__init__.py b/src/perplexity/types/browser/__init__.py new file mode 100644 index 0000000..f8ee8b1 --- /dev/null +++ b/src/perplexity/types/browser/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/perplexity/types/sandbox/__init__.py b/src/perplexity/types/sandbox/__init__.py new file mode 100644 index 0000000..36091f2 --- /dev/null +++ b/src/perplexity/types/sandbox/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .session_create_params import SessionCreateParams as SessionCreateParams diff --git a/src/perplexity/types/sandbox/session_create_params.py b/src/perplexity/types/sandbox/session_create_params.py new file mode 100644 index 0000000..0fe8b06 --- /dev/null +++ b/src/perplexity/types/sandbox/session_create_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["SessionCreateParams"] + + +class SessionCreateParams(TypedDict, total=False): + network_enabled: bool + """Enable network access in the sandbox""" diff --git a/src/perplexity/types/sandbox/sessions/__init__.py b/src/perplexity/types/sandbox/sessions/__init__.py new file mode 100644 index 0000000..b0d18ce --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/__init__.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .file_list_params import FileListParams as FileListParams +from .file_read_params import FileReadParams as FileReadParams +from .file_write_params import FileWriteParams as FileWriteParams +from .resume_create_params import ResumeCreateParams as ResumeCreateParams +from .execute_create_params import ExecuteCreateParams as ExecuteCreateParams diff --git a/src/perplexity/types/sandbox/sessions/execute_create_params.py b/src/perplexity/types/sandbox/sessions/execute_create_params.py new file mode 100644 index 0000000..fdcc41d --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/execute_create_params.py @@ -0,0 +1,21 @@ +# 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__ = ["ExecuteCreateParams"] + + +class ExecuteCreateParams(TypedDict, total=False): + code: Required[str] + """Base64 encoded code to execute""" + + language: Required[Literal["python", "bash"]] + """Programming language of the code""" + + background: bool + """Run in background (bash only)""" + + execution_timeout: int + """Execution timeout in seconds (max 120)""" diff --git a/src/perplexity/types/sandbox/sessions/file_list_params.py b/src/perplexity/types/sandbox/sessions/file_list_params.py new file mode 100644 index 0000000..2eb257e --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/file_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["FileListParams"] + + +class FileListParams(TypedDict, total=False): + depth: int + """Directory traversal depth""" + + path: str + """Directory path to list""" diff --git a/src/perplexity/types/sandbox/sessions/file_read_params.py b/src/perplexity/types/sandbox/sessions/file_read_params.py new file mode 100644 index 0000000..aec9e35 --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/file_read_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["FileReadParams"] + + +class FileReadParams(TypedDict, total=False): + path: Required[str] + """Absolute path to the file to read""" diff --git a/src/perplexity/types/sandbox/sessions/file_write_params.py b/src/perplexity/types/sandbox/sessions/file_write_params.py new file mode 100644 index 0000000..b801d3f --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/file_write_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["FileWriteParams"] + + +class FileWriteParams(TypedDict, total=False): + content: Required[str] + """Base64 encoded file content""" + + path: Required[str] + """Absolute path where the file should be written""" diff --git a/src/perplexity/types/sandbox/sessions/resume_create_params.py b/src/perplexity/types/sandbox/sessions/resume_create_params.py new file mode 100644 index 0000000..b098455 --- /dev/null +++ b/src/perplexity/types/sandbox/sessions/resume_create_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["ResumeCreateParams"] + + +class ResumeCreateParams(TypedDict, total=False): + network_enabled: bool + """Override network setting when resuming""" diff --git a/src/perplexity/types/shared/__init__.py b/src/perplexity/types/shared/__init__.py index 4a3fa01..e7245f3 100644 --- a/src/perplexity/types/shared/__init__.py +++ b/src/perplexity/types/shared/__init__.py @@ -1,7 +1,9 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .choice import Choice as Choice +from .file_entry import FileEntry as FileEntry from .usage_info import UsageInfo as UsageInfo +from .process_info import ProcessInfo as ProcessInfo from .search_result import SearchResult as SearchResult from .user_location import UserLocation as UserLocation from .response_format import ResponseFormat as ResponseFormat @@ -9,7 +11,16 @@ from .embeddings_usage import EmbeddingsUsage as EmbeddingsUsage from .chat_message_input import ChatMessageInput as ChatMessageInput from .json_schema_format import JsonSchemaFormat as JsonSchemaFormat +from .read_file_response import ReadFileResponse as ReadFileResponse from .web_search_options import WebSearchOptions as WebSearchOptions from .chat_message_output import ChatMessageOutput as ChatMessageOutput +from .list_files_response import ListFilesResponse as ListFilesResponse +from .write_file_response import WriteFileResponse as WriteFileResponse +from .execute_code_response import ExecuteCodeResponse as ExecuteCodeResponse +from .pause_sandbox_response import PauseSandboxResponse as PauseSandboxResponse +from .list_processes_response import ListProcessesResponse as ListProcessesResponse +from .modified_files_response import ModifiedFilesResponse as ModifiedFilesResponse from .api_public_search_result import APIPublicSearchResult as APIPublicSearchResult +from .browser_session_response import BrowserSessionResponse as BrowserSessionResponse +from .sandbox_session_response import SandboxSessionResponse as SandboxSessionResponse from .contextualized_embedding_object import ContextualizedEmbeddingObject as ContextualizedEmbeddingObject diff --git a/src/perplexity/types/shared/browser_session_response.py b/src/perplexity/types/shared/browser_session_response.py new file mode 100644 index 0000000..c5ed327 --- /dev/null +++ b/src/perplexity/types/shared/browser_session_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["BrowserSessionResponse"] + + +class BrowserSessionResponse(BaseModel): + """Response containing browser session details""" + + session_id: Optional[str] = None + """Unique identifier for the browser session""" + + status: Optional[Literal["running", "stopped"]] = None + """Current status of the session""" diff --git a/src/perplexity/types/shared/execute_code_response.py b/src/perplexity/types/shared/execute_code_response.py new file mode 100644 index 0000000..38f4c2a --- /dev/null +++ b/src/perplexity/types/shared/execute_code_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["ExecuteCodeResponse", "Output"] + + +class Output(BaseModel): + content: Optional[str] = None + """Output content""" + + type: Optional[str] = None + """Output type (stdout, stderr)""" + + +class ExecuteCodeResponse(BaseModel): + """Response from code execution""" + + error: Optional[str] = None + """Error message if execution failed""" + + execution_time_ms: Optional[float] = None + """Time taken to execute the code in milliseconds""" + + exit_code: Optional[int] = None + """Process exit code (0 for success)""" + + is_background: Optional[bool] = None + """Whether this was a background execution""" + + output: Optional[List[Output]] = None + """Structured output from the execution""" + + process_id: Optional[int] = None + """PID of the background process (only for background execution)""" + + stderr: Optional[str] = None + """Standard error from the execution""" + + stdout: Optional[str] = None + """Standard output from the execution""" + + success: Optional[bool] = None + """Whether the execution completed successfully""" diff --git a/src/perplexity/types/shared/file_entry.py b/src/perplexity/types/shared/file_entry.py new file mode 100644 index 0000000..c73c93d --- /dev/null +++ b/src/perplexity/types/shared/file_entry.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["FileEntry"] + + +class FileEntry(BaseModel): + """A file or directory entry""" + + path: Optional[str] = None + """Absolute path of the entry""" + + size: Optional[int] = None + """Size in bytes (0 for directories)""" + + type: Optional[Literal["file", "directory"]] = None + """Entry type""" diff --git a/src/perplexity/types/shared/list_files_response.py b/src/perplexity/types/shared/list_files_response.py new file mode 100644 index 0000000..894a09d --- /dev/null +++ b/src/perplexity/types/shared/list_files_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel +from .file_entry import FileEntry + +__all__ = ["ListFilesResponse"] + + +class ListFilesResponse(BaseModel): + """Response containing directory listing""" + + entries: Optional[List[FileEntry]] = None + """List of file and directory entries""" diff --git a/src/perplexity/types/shared/list_processes_response.py b/src/perplexity/types/shared/list_processes_response.py new file mode 100644 index 0000000..80369f2 --- /dev/null +++ b/src/perplexity/types/shared/list_processes_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel +from .process_info import ProcessInfo + +__all__ = ["ListProcessesResponse"] + + +class ListProcessesResponse(BaseModel): + """Response containing list of running processes""" + + processes: Optional[List[ProcessInfo]] = None + """List of running processes""" diff --git a/src/perplexity/types/shared/modified_files_response.py b/src/perplexity/types/shared/modified_files_response.py new file mode 100644 index 0000000..78f8084 --- /dev/null +++ b/src/perplexity/types/shared/modified_files_response.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["ModifiedFilesResponse"] + + +class ModifiedFilesResponse(BaseModel): + """Response containing list of modified files since session start""" + + files: Optional[List[str]] = None + """List of modified file paths""" diff --git a/src/perplexity/types/shared/pause_sandbox_response.py b/src/perplexity/types/shared/pause_sandbox_response.py new file mode 100644 index 0000000..f205c9d --- /dev/null +++ b/src/perplexity/types/shared/pause_sandbox_response.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["PauseSandboxResponse"] + + +class PauseSandboxResponse(BaseModel): + """Response from pausing a sandbox session""" + + file_count: Optional[int] = None + """Number of files in the snapshot""" + + file_list: Optional[List[str]] = None + """List of files included in the snapshot""" + + s3_bucket: Optional[str] = None + """S3 bucket containing the snapshot""" + + s3_key: Optional[str] = None + """S3 object key for the snapshot""" + + s3_uploaded: Optional[bool] = None + """Whether the snapshot was uploaded to S3""" + + success: Optional[bool] = None + """Whether the pause was successful""" + + tarball_size: Optional[int] = None + """Size of the snapshot in bytes""" diff --git a/src/perplexity/types/shared/process_info.py b/src/perplexity/types/shared/process_info.py new file mode 100644 index 0000000..f38e2d8 --- /dev/null +++ b/src/perplexity/types/shared/process_info.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ProcessInfo"] + + +class ProcessInfo(BaseModel): + """Information about a running process""" + + command: Optional[str] = None + """Command that started the process""" + + pid: Optional[int] = None + """Process ID""" + + status: Optional[str] = None + """Current status of the process""" diff --git a/src/perplexity/types/shared/read_file_response.py b/src/perplexity/types/shared/read_file_response.py new file mode 100644 index 0000000..c74a452 --- /dev/null +++ b/src/perplexity/types/shared/read_file_response.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ReadFileResponse"] + + +class ReadFileResponse(BaseModel): + """Response containing file content""" + + content: Optional[str] = None + """Base64 encoded file content""" + + path: Optional[str] = None + """Path of the file""" + + size: Optional[int] = None + """File size in bytes""" diff --git a/src/perplexity/types/shared/sandbox_session_response.py b/src/perplexity/types/shared/sandbox_session_response.py new file mode 100644 index 0000000..46ccc2d --- /dev/null +++ b/src/perplexity/types/shared/sandbox_session_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["SandboxSessionResponse"] + + +class SandboxSessionResponse(BaseModel): + """Response containing sandbox session details""" + + execute_url: Optional[str] = None + """URL endpoint for executing code in this session""" + + network_enabled: Optional[bool] = None + """Whether network access is enabled""" + + session_id: Optional[str] = None + """Unique identifier for the sandbox session""" + + status: Optional[Literal["running", "pending", "failed", "succeeded", "unknown", "paused"]] = None + """Current status of the session""" diff --git a/src/perplexity/types/shared/write_file_response.py b/src/perplexity/types/shared/write_file_response.py new file mode 100644 index 0000000..cef4dc0 --- /dev/null +++ b/src/perplexity/types/shared/write_file_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["WriteFileResponse"] + + +class WriteFileResponse(BaseModel): + """Response from writing a file""" + + path: Optional[str] = None + """Path where the file was written""" + + success: Optional[bool] = None + """Whether the file was written successfully""" diff --git a/tests/api_resources/browser/__init__.py b/tests/api_resources/browser/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/browser/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/browser/test_sessions.py b/tests/api_resources/browser/test_sessions.py new file mode 100644 index 0000000..cb41645 --- /dev/null +++ b/tests/api_resources/browser/test_sessions.py @@ -0,0 +1,164 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import BrowserSessionResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Perplexity) -> None: + session = client.browser.sessions.create() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Perplexity) -> None: + response = client.browser.sessions.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Perplexity) -> None: + with client.browser.sessions.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Perplexity) -> None: + session = client.browser.sessions.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Perplexity) -> None: + response = client.browser.sessions.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Perplexity) -> None: + with client.browser.sessions.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert session is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.browser.sessions.with_raw_response.delete( + "", + ) + + +class TestAsyncSessions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPerplexity) -> None: + session = await async_client.browser.sessions.create() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPerplexity) -> None: + response = await async_client.browser.sessions.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = await response.parse() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPerplexity) -> None: + async with async_client.browser.sessions.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(BrowserSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPerplexity) -> None: + session = await async_client.browser.sessions.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPerplexity) -> None: + response = await async_client.browser.sessions.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = await response.parse() + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPerplexity) -> None: + async with async_client.browser.sessions.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert session is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.browser.sessions.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/sandbox/__init__.py b/tests/api_resources/sandbox/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/sandbox/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/sandbox/sessions/__init__.py b/tests/api_resources/sandbox/sessions/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/sandbox/sessions/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/sandbox/sessions/test_execute.py b/tests/api_resources/sandbox/sessions/test_execute.py new file mode 100644 index 0000000..8e9dcce --- /dev/null +++ b/tests/api_resources/sandbox/sessions/test_execute.py @@ -0,0 +1,148 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import ExecuteCodeResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestExecute: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Perplexity) -> None: + execute = client.sandbox.sessions.execute.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Perplexity) -> None: + execute = client.sandbox.sessions.execute.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + background=True, + execution_timeout=1, + ) + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Perplexity) -> None: + response = client.sandbox.sessions.execute.with_raw_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + execute = response.parse() + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Perplexity) -> None: + with client.sandbox.sessions.execute.with_streaming_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + execute = response.parse() + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_create(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.execute.with_raw_response.create( + session_id="", + code="code", + language="python", + ) + + +class TestAsyncExecute: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPerplexity) -> None: + execute = await async_client.sandbox.sessions.execute.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPerplexity) -> None: + execute = await async_client.sandbox.sessions.execute.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + background=True, + execution_timeout=1, + ) + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.execute.with_raw_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + execute = await response.parse() + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.execute.with_streaming_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + code="code", + language="python", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + execute = await response.parse() + assert_matches_type(ExecuteCodeResponse, execute, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.execute.with_raw_response.create( + session_id="", + code="code", + language="python", + ) diff --git a/tests/api_resources/sandbox/sessions/test_files.py b/tests/api_resources/sandbox/sessions/test_files.py new file mode 100644 index 0000000..f552be2 --- /dev/null +++ b/tests/api_resources/sandbox/sessions/test_files.py @@ -0,0 +1,404 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import ReadFileResponse, ListFilesResponse, WriteFileResponse, ModifiedFilesResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFiles: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Perplexity) -> None: + file = client.sandbox.sessions.files.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Perplexity) -> None: + file = client.sandbox.sessions.files.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + depth=1, + path="path", + ) + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Perplexity) -> None: + response = client.sandbox.sessions.files.with_raw_response.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Perplexity) -> None: + with client.sandbox.sessions.files.with_streaming_response.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(ListFilesResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_list(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.files.with_raw_response.list( + session_id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_modified(self, client: Perplexity) -> None: + file = client.sandbox.sessions.files.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_modified(self, client: Perplexity) -> None: + response = client.sandbox.sessions.files.with_raw_response.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_modified(self, client: Perplexity) -> None: + with client.sandbox.sessions.files.with_streaming_response.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_modified(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.files.with_raw_response.modified( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_read(self, client: Perplexity) -> None: + file = client.sandbox.sessions.files.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) + assert_matches_type(ReadFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_read(self, client: Perplexity) -> None: + response = client.sandbox.sessions.files.with_raw_response.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(ReadFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_read(self, client: Perplexity) -> None: + with client.sandbox.sessions.files.with_streaming_response.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(ReadFileResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_read(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.files.with_raw_response.read( + session_id="", + path="path", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_write(self, client: Perplexity) -> None: + file = client.sandbox.sessions.files.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) + assert_matches_type(WriteFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_write(self, client: Perplexity) -> None: + response = client.sandbox.sessions.files.with_raw_response.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(WriteFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_write(self, client: Perplexity) -> None: + with client.sandbox.sessions.files.with_streaming_response.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(WriteFileResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_write(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.files.with_raw_response.write( + session_id="", + content="content", + path="path", + ) + + +class TestAsyncFiles: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPerplexity) -> None: + file = await async_client.sandbox.sessions.files.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPerplexity) -> None: + file = await async_client.sandbox.sessions.files.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + depth=1, + path="path", + ) + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.files.with_raw_response.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(ListFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.files.with_streaming_response.list( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(ListFilesResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_list(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.files.with_raw_response.list( + session_id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_modified(self, async_client: AsyncPerplexity) -> None: + file = await async_client.sandbox.sessions.files.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_modified(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.files.with_raw_response.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_modified(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.files.with_streaming_response.modified( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(ModifiedFilesResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_modified(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.files.with_raw_response.modified( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_read(self, async_client: AsyncPerplexity) -> None: + file = await async_client.sandbox.sessions.files.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) + assert_matches_type(ReadFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_read(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.files.with_raw_response.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(ReadFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_read(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.files.with_streaming_response.read( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(ReadFileResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_read(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.files.with_raw_response.read( + session_id="", + path="path", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_write(self, async_client: AsyncPerplexity) -> None: + file = await async_client.sandbox.sessions.files.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) + assert_matches_type(WriteFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_write(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.files.with_raw_response.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(WriteFileResponse, file, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_write(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.files.with_streaming_response.write( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + content="content", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(WriteFileResponse, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_write(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.files.with_raw_response.write( + session_id="", + content="content", + path="path", + ) diff --git a/tests/api_resources/sandbox/sessions/test_pause.py b/tests/api_resources/sandbox/sessions/test_pause.py new file mode 100644 index 0000000..4bd4bc0 --- /dev/null +++ b/tests/api_resources/sandbox/sessions/test_pause.py @@ -0,0 +1,108 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import PauseSandboxResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPause: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Perplexity) -> None: + pause = client.sandbox.sessions.pause.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Perplexity) -> None: + response = client.sandbox.sessions.pause.with_raw_response.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + pause = response.parse() + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Perplexity) -> None: + with client.sandbox.sessions.pause.with_streaming_response.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + pause = response.parse() + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_create(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.pause.with_raw_response.create( + "", + ) + + +class TestAsyncPause: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPerplexity) -> None: + pause = await async_client.sandbox.sessions.pause.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.pause.with_raw_response.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + pause = await response.parse() + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.pause.with_streaming_response.create( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + pause = await response.parse() + assert_matches_type(PauseSandboxResponse, pause, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.pause.with_raw_response.create( + "", + ) diff --git a/tests/api_resources/sandbox/sessions/test_processes.py b/tests/api_resources/sandbox/sessions/test_processes.py new file mode 100644 index 0000000..56bf5d8 --- /dev/null +++ b/tests/api_resources/sandbox/sessions/test_processes.py @@ -0,0 +1,292 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import ProcessInfo, ListProcessesResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestProcesses: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_list(self, client: Perplexity) -> None: + process = client.sandbox.sessions.processes.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_list(self, client: Perplexity) -> None: + response = client.sandbox.sessions.processes.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = response.parse() + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Perplexity) -> None: + with client.sandbox.sessions.processes.with_streaming_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = response.parse() + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_list(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.processes.with_raw_response.list( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Perplexity) -> None: + process = client.sandbox.sessions.processes.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert process is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Perplexity) -> None: + response = client.sandbox.sessions.processes.with_raw_response.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = response.parse() + assert process is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Perplexity) -> None: + with client.sandbox.sessions.processes.with_streaming_response.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = response.parse() + assert process is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.processes.with_raw_response.delete( + pid=0, + session_id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_get(self, client: Perplexity) -> None: + process = client.sandbox.sessions.processes.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ProcessInfo, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_get(self, client: Perplexity) -> None: + response = client.sandbox.sessions.processes.with_raw_response.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = response.parse() + assert_matches_type(ProcessInfo, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Perplexity) -> None: + with client.sandbox.sessions.processes.with_streaming_response.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = response.parse() + assert_matches_type(ProcessInfo, process, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_get(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.processes.with_raw_response.get( + pid=0, + session_id="", + ) + + +class TestAsyncProcesses: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPerplexity) -> None: + process = await async_client.sandbox.sessions.processes.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.processes.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = await response.parse() + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.processes.with_streaming_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = await response.parse() + assert_matches_type(ListProcessesResponse, process, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_list(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.processes.with_raw_response.list( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPerplexity) -> None: + process = await async_client.sandbox.sessions.processes.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert process is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.processes.with_raw_response.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = await response.parse() + assert process is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.processes.with_streaming_response.delete( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = await response.parse() + assert process is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.processes.with_raw_response.delete( + pid=0, + session_id="", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncPerplexity) -> None: + process = await async_client.sandbox.sessions.processes.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(ProcessInfo, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.processes.with_raw_response.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + process = await response.parse() + assert_matches_type(ProcessInfo, process, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.processes.with_streaming_response.get( + pid=0, + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + process = await response.parse() + assert_matches_type(ProcessInfo, process, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.processes.with_raw_response.get( + pid=0, + session_id="", + ) diff --git a/tests/api_resources/sandbox/sessions/test_resume.py b/tests/api_resources/sandbox/sessions/test_resume.py new file mode 100644 index 0000000..91b81c6 --- /dev/null +++ b/tests/api_resources/sandbox/sessions/test_resume.py @@ -0,0 +1,126 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import SandboxSessionResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestResume: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Perplexity) -> None: + resume = client.sandbox.sessions.resume.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Perplexity) -> None: + resume = client.sandbox.sessions.resume.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + network_enabled=True, + ) + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Perplexity) -> None: + response = client.sandbox.sessions.resume.with_raw_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resume = response.parse() + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Perplexity) -> None: + with client.sandbox.sessions.resume.with_streaming_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resume = response.parse() + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_create(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.resume.with_raw_response.create( + session_id="", + ) + + +class TestAsyncResume: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPerplexity) -> None: + resume = await async_client.sandbox.sessions.resume.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPerplexity) -> None: + resume = await async_client.sandbox.sessions.resume.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + network_enabled=True, + ) + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.resume.with_raw_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resume = await response.parse() + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.resume.with_streaming_response.create( + session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resume = await response.parse() + assert_matches_type(SandboxSessionResponse, resume, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.resume.with_raw_response.create( + session_id="", + ) diff --git a/tests/api_resources/sandbox/test_sessions.py b/tests/api_resources/sandbox/test_sessions.py new file mode 100644 index 0000000..982ef32 --- /dev/null +++ b/tests/api_resources/sandbox/test_sessions.py @@ -0,0 +1,264 @@ +# 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 perplexity import Perplexity, AsyncPerplexity +from tests.utils import assert_matches_type +from perplexity.types.shared import SandboxSessionResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create(self, client: Perplexity) -> None: + session = client.sandbox.sessions.create() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Perplexity) -> None: + session = client.sandbox.sessions.create( + network_enabled=True, + ) + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_create(self, client: Perplexity) -> None: + response = client.sandbox.sessions.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Perplexity) -> None: + with client.sandbox.sessions.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_delete(self, client: Perplexity) -> None: + session = client.sandbox.sessions.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Perplexity) -> None: + response = client.sandbox.sessions.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Perplexity) -> None: + with client.sandbox.sessions.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert session is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_delete(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_method_get(self, client: Perplexity) -> None: + session = client.sandbox.sessions.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_raw_response_get(self, client: Perplexity) -> None: + response = client.sandbox.sessions.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Perplexity) -> None: + with client.sandbox.sessions.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + def test_path_params_get(self, client: Perplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.sandbox.sessions.with_raw_response.get( + "", + ) + + +class TestAsyncSessions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPerplexity) -> None: + session = await async_client.sandbox.sessions.create() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPerplexity) -> None: + session = await async_client.sandbox.sessions.create( + network_enabled=True, + ) + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = await response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPerplexity) -> None: + session = await async_client.sandbox.sessions.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = await response.parse() + assert session is None + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert session is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncPerplexity) -> None: + session = await async_client.sandbox.sessions.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncPerplexity) -> None: + response = await async_client.sandbox.sessions.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = await response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncPerplexity) -> None: + async with async_client.sandbox.sessions.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(SandboxSessionResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Prism tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncPerplexity) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.sandbox.sessions.with_raw_response.get( + "", + ) From 907fba5c0f01b4784ccc0f047a094895337e612f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:59:34 +0000 Subject: [PATCH 4/4] release: 0.30.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 7ed8b9a..554e34b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.29.1" + ".": "0.30.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ac971..4b93459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.30.0 (2026-02-12) + +Full Changelog: [v0.29.1...v0.30.0](https://github.com/perplexityai/perplexity-py/compare/v0.29.1...v0.30.0) + +### Features + +* **api:** Add browser and sandbox API endpoints ([f5c3e58](https://github.com/perplexityai/perplexity-py/commit/f5c3e58836feb37a6b9ba366a55811513a8cd28c)) + ## 0.29.1 (2026-02-12) Full Changelog: [v0.29.0...v0.29.1](https://github.com/perplexityai/perplexity-py/compare/v0.29.0...v0.29.1) diff --git a/pyproject.toml b/pyproject.toml index 0105782..6cd026c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "perplexityai" -version = "0.29.1" +version = "0.30.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 a0c5adf..aca4a94 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.29.1" # x-release-please-version +__version__ = "0.30.0" # x-release-please-version