perplexityai 0.9.0__tar.gz → 0.11.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of perplexityai might be problematic. Click here for more details.

Files changed (102) hide show
  1. perplexityai-0.11.0/.release-please-manifest.json +3 -0
  2. {perplexityai-0.9.0 → perplexityai-0.11.0}/CHANGELOG.md +22 -0
  3. {perplexityai-0.9.0 → perplexityai-0.11.0}/PKG-INFO +1 -1
  4. {perplexityai-0.9.0 → perplexityai-0.11.0}/pyproject.toml +1 -1
  5. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/__init__.py +3 -1
  6. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_base_client.py +9 -9
  7. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_client.py +8 -8
  8. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_qs.py +7 -7
  9. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_types.py +18 -11
  10. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_transform.py +2 -2
  11. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_utils.py +4 -4
  12. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_version.py +1 -1
  13. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/async_/chat/completions.py +21 -21
  14. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/chat/completions.py +107 -107
  15. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/search.py +13 -41
  16. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/search_create_params.py +0 -14
  17. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/test_search.py +0 -14
  18. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_transform.py +9 -2
  19. perplexityai-0.9.0/.release-please-manifest.json +0 -3
  20. {perplexityai-0.9.0 → perplexityai-0.11.0}/.gitignore +0 -0
  21. {perplexityai-0.9.0 → perplexityai-0.11.0}/CONTRIBUTING.md +0 -0
  22. {perplexityai-0.9.0 → perplexityai-0.11.0}/LICENSE +0 -0
  23. {perplexityai-0.9.0 → perplexityai-0.11.0}/README.md +0 -0
  24. {perplexityai-0.9.0 → perplexityai-0.11.0}/SECURITY.md +0 -0
  25. {perplexityai-0.9.0 → perplexityai-0.11.0}/api.md +0 -0
  26. {perplexityai-0.9.0 → perplexityai-0.11.0}/bin/check-release-environment +0 -0
  27. {perplexityai-0.9.0 → perplexityai-0.11.0}/bin/publish-pypi +0 -0
  28. {perplexityai-0.9.0 → perplexityai-0.11.0}/examples/.keep +0 -0
  29. {perplexityai-0.9.0 → perplexityai-0.11.0}/noxfile.py +0 -0
  30. {perplexityai-0.9.0 → perplexityai-0.11.0}/release-please-config.json +0 -0
  31. {perplexityai-0.9.0 → perplexityai-0.11.0}/requirements-dev.lock +0 -0
  32. {perplexityai-0.9.0 → perplexityai-0.11.0}/requirements.lock +0 -0
  33. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_compat.py +0 -0
  34. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_constants.py +0 -0
  35. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_exceptions.py +0 -0
  36. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_files.py +0 -0
  37. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_models.py +0 -0
  38. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_resource.py +0 -0
  39. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_response.py +0 -0
  40. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_streaming.py +0 -0
  41. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/__init__.py +0 -0
  42. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_compat.py +0 -0
  43. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_datetime_parse.py +0 -0
  44. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_logs.py +0 -0
  45. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_proxy.py +0 -0
  46. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_reflection.py +0 -0
  47. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_resources_proxy.py +0 -0
  48. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_streams.py +0 -0
  49. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_sync.py +0 -0
  50. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/_utils/_typing.py +0 -0
  51. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/lib/.keep +0 -0
  52. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/py.typed +0 -0
  53. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/__init__.py +0 -0
  54. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/async_/__init__.py +0 -0
  55. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/async_/async_.py +0 -0
  56. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/async_/chat/__init__.py +0 -0
  57. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/async_/chat/chat.py +0 -0
  58. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/chat/__init__.py +0 -0
  59. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/resources/chat/chat.py +0 -0
  60. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/__init__.py +0 -0
  61. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/__init__.py +0 -0
  62. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/__init__.py +0 -0
  63. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/completion_create_params.py +0 -0
  64. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/completion_create_response.py +0 -0
  65. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/completion_get_params.py +0 -0
  66. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/completion_get_response.py +0 -0
  67. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/async_/chat/completion_list_response.py +0 -0
  68. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/chat/__init__.py +0 -0
  69. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/chat/completion_create_params.py +0 -0
  70. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/chat/completion_create_response.py +0 -0
  71. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/search_create_response.py +0 -0
  72. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/__init__.py +0 -0
  73. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/api_public_search_result.py +0 -0
  74. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/chat_message_input.py +0 -0
  75. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/chat_message_output.py +0 -0
  76. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/choice.py +0 -0
  77. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared/usage_info.py +0 -0
  78. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared_params/__init__.py +0 -0
  79. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared_params/api_public_search_result.py +0 -0
  80. {perplexityai-0.9.0 → perplexityai-0.11.0}/src/perplexity/types/shared_params/chat_message_input.py +0 -0
  81. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/__init__.py +0 -0
  82. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/__init__.py +0 -0
  83. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/async_/__init__.py +0 -0
  84. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/async_/chat/__init__.py +0 -0
  85. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/async_/chat/test_completions.py +0 -0
  86. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/chat/__init__.py +0 -0
  87. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/api_resources/chat/test_completions.py +0 -0
  88. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/conftest.py +0 -0
  89. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/sample_file.txt +0 -0
  90. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_client.py +0 -0
  91. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_deepcopy.py +0 -0
  92. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_extract_files.py +0 -0
  93. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_files.py +0 -0
  94. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_models.py +0 -0
  95. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_qs.py +0 -0
  96. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_required_args.py +0 -0
  97. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_response.py +0 -0
  98. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_streaming.py +0 -0
  99. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_utils/test_datetime_parse.py +0 -0
  100. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_utils/test_proxy.py +0 -0
  101. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/test_utils/test_typing.py +0 -0
  102. {perplexityai-0.9.0 → perplexityai-0.11.0}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.11.0"
3
+ }
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 (2025-09-24)
4
+
5
+ Full Changelog: [v0.10.0...v0.11.0](https://github.com/ppl-ai/perplexity-py/compare/v0.10.0...v0.11.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** manual updates ([d0b1071](https://github.com/ppl-ai/perplexity-py/commit/d0b1071f0a16cf589c8c7d58dd545f8455eb6878))
10
+
11
+
12
+ ### Chores
13
+
14
+ * do not install brew dependencies in ./scripts/bootstrap by default ([6642343](https://github.com/ppl-ai/perplexity-py/commit/66423439ddc11f2db05dc47f71b362c37681a557))
15
+ * **types:** change optional parameter type from NotGiven to Omit ([3b0edc9](https://github.com/ppl-ai/perplexity-py/commit/3b0edc968f37f3a4233d0a66333e526a23f5073e))
16
+
17
+ ## 0.10.0 (2025-09-19)
18
+
19
+ Full Changelog: [v0.9.0...v0.10.0](https://github.com/ppl-ai/perplexity-py/compare/v0.9.0...v0.10.0)
20
+
21
+ ### Features
22
+
23
+ * **api:** manual updates ([7f38b2f](https://github.com/ppl-ai/perplexity-py/commit/7f38b2f1eb750a6d5e435a5bfd376b62fa5a9594))
24
+
3
25
  ## 0.9.0 (2025-09-17)
4
26
 
5
27
  Full Changelog: [v0.8.0...v0.9.0](https://github.com/ppl-ai/perplexity-py/compare/v0.8.0...v0.9.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: perplexityai
3
- Version: 0.9.0
3
+ Version: 0.11.0
4
4
  Summary: The official Python library for the perplexity API
5
5
  Project-URL: Homepage, https://github.com/ppl-ai/perplexity-py
6
6
  Project-URL: Repository, https://github.com/ppl-ai/perplexity-py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "perplexityai"
3
- version = "0.9.0"
3
+ version = "0.11.0"
4
4
  description = "The official Python library for the perplexity API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -3,7 +3,7 @@
3
3
  import typing as _t
4
4
 
5
5
  from . import types
6
- from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
6
+ from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
7
  from ._utils import file_from_path
8
8
  from ._client import (
9
9
  Client,
@@ -48,7 +48,9 @@ __all__ = [
48
48
  "ProxiesTypes",
49
49
  "NotGiven",
50
50
  "NOT_GIVEN",
51
+ "not_given",
51
52
  "Omit",
53
+ "omit",
52
54
  "PerplexityError",
53
55
  "APIError",
54
56
  "APIStatusError",
@@ -42,7 +42,6 @@ from . import _exceptions
42
42
  from ._qs import Querystring
43
43
  from ._files import to_httpx_files, async_to_httpx_files
44
44
  from ._types import (
45
- NOT_GIVEN,
46
45
  Body,
47
46
  Omit,
48
47
  Query,
@@ -57,6 +56,7 @@ from ._types import (
57
56
  RequestOptions,
58
57
  HttpxRequestFiles,
59
58
  ModelBuilderProtocol,
59
+ not_given,
60
60
  )
61
61
  from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
62
62
  from ._compat import PYDANTIC_V1, model_copy, model_dump
@@ -145,9 +145,9 @@ class PageInfo:
145
145
  def __init__(
146
146
  self,
147
147
  *,
148
- url: URL | NotGiven = NOT_GIVEN,
149
- json: Body | NotGiven = NOT_GIVEN,
150
- params: Query | NotGiven = NOT_GIVEN,
148
+ url: URL | NotGiven = not_given,
149
+ json: Body | NotGiven = not_given,
150
+ params: Query | NotGiven = not_given,
151
151
  ) -> None:
152
152
  self.url = url
153
153
  self.json = json
@@ -595,7 +595,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
595
595
  # we internally support defining a temporary header to override the
596
596
  # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
597
597
  # see _response.py for implementation details
598
- override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
598
+ override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
599
599
  if is_given(override_cast_to):
600
600
  options.headers = headers
601
601
  return cast(Type[ResponseT], override_cast_to)
@@ -825,7 +825,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
825
825
  version: str,
826
826
  base_url: str | URL,
827
827
  max_retries: int = DEFAULT_MAX_RETRIES,
828
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
828
+ timeout: float | Timeout | None | NotGiven = not_given,
829
829
  http_client: httpx.Client | None = None,
830
830
  custom_headers: Mapping[str, str] | None = None,
831
831
  custom_query: Mapping[str, object] | None = None,
@@ -1356,7 +1356,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1356
1356
  base_url: str | URL,
1357
1357
  _strict_response_validation: bool,
1358
1358
  max_retries: int = DEFAULT_MAX_RETRIES,
1359
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1359
+ timeout: float | Timeout | None | NotGiven = not_given,
1360
1360
  http_client: httpx.AsyncClient | None = None,
1361
1361
  custom_headers: Mapping[str, str] | None = None,
1362
1362
  custom_query: Mapping[str, object] | None = None,
@@ -1818,8 +1818,8 @@ def make_request_options(
1818
1818
  extra_query: Query | None = None,
1819
1819
  extra_body: Body | None = None,
1820
1820
  idempotency_key: str | None = None,
1821
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1822
- post_parser: PostParser | NotGiven = NOT_GIVEN,
1821
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1822
+ post_parser: PostParser | NotGiven = not_given,
1823
1823
  ) -> RequestOptions:
1824
1824
  """Create a dict of type RequestOptions without keys of NotGiven values."""
1825
1825
  options: RequestOptions = {}
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Union, Mapping
6
+ from typing import Any, Mapping
7
7
  from typing_extensions import Self, override
8
8
 
9
9
  import httpx
@@ -11,13 +11,13 @@ import httpx
11
11
  from . import _exceptions
12
12
  from ._qs import Querystring
13
13
  from ._types import (
14
- NOT_GIVEN,
15
14
  Omit,
16
15
  Timeout,
17
16
  NotGiven,
18
17
  Transport,
19
18
  ProxiesTypes,
20
19
  RequestOptions,
20
+ not_given,
21
21
  )
22
22
  from ._utils import is_given, get_async_library
23
23
  from ._version import __version__
@@ -59,7 +59,7 @@ class Perplexity(SyncAPIClient):
59
59
  *,
60
60
  api_key: str | None = None,
61
61
  base_url: str | httpx.URL | None = None,
62
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
62
+ timeout: float | Timeout | None | NotGiven = not_given,
63
63
  max_retries: int = DEFAULT_MAX_RETRIES,
64
64
  default_headers: Mapping[str, str] | None = None,
65
65
  default_query: Mapping[str, object] | None = None,
@@ -136,9 +136,9 @@ class Perplexity(SyncAPIClient):
136
136
  *,
137
137
  api_key: str | None = None,
138
138
  base_url: str | httpx.URL | None = None,
139
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
139
+ timeout: float | Timeout | None | NotGiven = not_given,
140
140
  http_client: httpx.Client | None = None,
141
- max_retries: int | NotGiven = NOT_GIVEN,
141
+ max_retries: int | NotGiven = not_given,
142
142
  default_headers: Mapping[str, str] | None = None,
143
143
  set_default_headers: Mapping[str, str] | None = None,
144
144
  default_query: Mapping[str, object] | None = None,
@@ -231,7 +231,7 @@ class AsyncPerplexity(AsyncAPIClient):
231
231
  *,
232
232
  api_key: str | None = None,
233
233
  base_url: str | httpx.URL | None = None,
234
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
234
+ timeout: float | Timeout | None | NotGiven = not_given,
235
235
  max_retries: int = DEFAULT_MAX_RETRIES,
236
236
  default_headers: Mapping[str, str] | None = None,
237
237
  default_query: Mapping[str, object] | None = None,
@@ -308,9 +308,9 @@ class AsyncPerplexity(AsyncAPIClient):
308
308
  *,
309
309
  api_key: str | None = None,
310
310
  base_url: str | httpx.URL | None = None,
311
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
311
+ timeout: float | Timeout | None | NotGiven = not_given,
312
312
  http_client: httpx.AsyncClient | None = None,
313
- max_retries: int | NotGiven = NOT_GIVEN,
313
+ max_retries: int | NotGiven = not_given,
314
314
  default_headers: Mapping[str, str] | None = None,
315
315
  set_default_headers: Mapping[str, str] | None = None,
316
316
  default_query: Mapping[str, object] | None = None,
@@ -4,7 +4,7 @@ from typing import Any, List, Tuple, Union, Mapping, TypeVar
4
4
  from urllib.parse import parse_qs, urlencode
5
5
  from typing_extensions import Literal, get_args
6
6
 
7
- from ._types import NOT_GIVEN, NotGiven, NotGivenOr
7
+ from ._types import NotGiven, not_given
8
8
  from ._utils import flatten
9
9
 
10
10
  _T = TypeVar("_T")
@@ -41,8 +41,8 @@ class Querystring:
41
41
  self,
42
42
  params: Params,
43
43
  *,
44
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
45
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
44
+ array_format: ArrayFormat | NotGiven = not_given,
45
+ nested_format: NestedFormat | NotGiven = not_given,
46
46
  ) -> str:
47
47
  return urlencode(
48
48
  self.stringify_items(
@@ -56,8 +56,8 @@ class Querystring:
56
56
  self,
57
57
  params: Params,
58
58
  *,
59
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
60
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
59
+ array_format: ArrayFormat | NotGiven = not_given,
60
+ nested_format: NestedFormat | NotGiven = not_given,
61
61
  ) -> list[tuple[str, str]]:
62
62
  opts = Options(
63
63
  qs=self,
@@ -143,8 +143,8 @@ class Options:
143
143
  self,
144
144
  qs: Querystring = _qs,
145
145
  *,
146
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
147
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
146
+ array_format: ArrayFormat | NotGiven = not_given,
147
+ nested_format: NestedFormat | NotGiven = not_given,
148
148
  ) -> None:
149
149
  self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
150
150
  self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
@@ -117,18 +117,21 @@ class RequestOptions(TypedDict, total=False):
117
117
  # Sentinel class used until PEP 0661 is accepted
118
118
  class NotGiven:
119
119
  """
120
- A sentinel singleton class used to distinguish omitted keyword arguments
121
- from those passed in with the value None (which may have different behavior).
120
+ For parameters with a meaningful None value, we need to distinguish between
121
+ the user explicitly passing None, and the user not passing the parameter at
122
+ all.
123
+
124
+ User code shouldn't need to use not_given directly.
122
125
 
123
126
  For example:
124
127
 
125
128
  ```py
126
- def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
129
+ def create(timeout: Timeout | None | NotGiven = not_given): ...
127
130
 
128
131
 
129
- get(timeout=1) # 1s timeout
130
- get(timeout=None) # No timeout
131
- get() # Default timeout behavior, which may not be statically known at the method definition.
132
+ create(timeout=1) # 1s timeout
133
+ create(timeout=None) # No timeout
134
+ create() # Default timeout behavior
132
135
  ```
133
136
  """
134
137
 
@@ -140,13 +143,14 @@ class NotGiven:
140
143
  return "NOT_GIVEN"
141
144
 
142
145
 
143
- NotGivenOr = Union[_T, NotGiven]
146
+ not_given = NotGiven()
147
+ # for backwards compatibility:
144
148
  NOT_GIVEN = NotGiven()
145
149
 
146
150
 
147
151
  class Omit:
148
- """In certain situations you need to be able to represent a case where a default value has
149
- to be explicitly removed and `None` is not an appropriate substitute, for example:
152
+ """
153
+ To explicitly omit something from being sent in a request, use `omit`.
150
154
 
151
155
  ```py
152
156
  # as the default `Content-Type` header is `application/json` that will be sent
@@ -156,8 +160,8 @@ class Omit:
156
160
  # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983'
157
161
  client.post(..., headers={"Content-Type": "multipart/form-data"})
158
162
 
159
- # instead you can remove the default `application/json` header by passing Omit
160
- client.post(..., headers={"Content-Type": Omit()})
163
+ # instead you can remove the default `application/json` header by passing omit
164
+ client.post(..., headers={"Content-Type": omit})
161
165
  ```
162
166
  """
163
167
 
@@ -165,6 +169,9 @@ class Omit:
165
169
  return False
166
170
 
167
171
 
172
+ omit = Omit()
173
+
174
+
168
175
  @runtime_checkable
169
176
  class ModelBuilderProtocol(Protocol):
170
177
  @classmethod
@@ -268,7 +268,7 @@ def _transform_typeddict(
268
268
  annotations = get_type_hints(expected_type, include_extras=True)
269
269
  for key, value in data.items():
270
270
  if not is_given(value):
271
- # we don't need to include `NotGiven` values here as they'll
271
+ # we don't need to include omitted values here as they'll
272
272
  # be stripped out before the request is sent anyway
273
273
  continue
274
274
 
@@ -434,7 +434,7 @@ async def _async_transform_typeddict(
434
434
  annotations = get_type_hints(expected_type, include_extras=True)
435
435
  for key, value in data.items():
436
436
  if not is_given(value):
437
- # we don't need to include `NotGiven` values here as they'll
437
+ # we don't need to include omitted values here as they'll
438
438
  # be stripped out before the request is sent anyway
439
439
  continue
440
440
 
@@ -21,7 +21,7 @@ from typing_extensions import TypeGuard
21
21
 
22
22
  import sniffio
23
23
 
24
- from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike
24
+ from .._types import Omit, NotGiven, FileTypes, HeadersLike
25
25
 
26
26
  _T = TypeVar("_T")
27
27
  _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
@@ -63,7 +63,7 @@ def _extract_items(
63
63
  try:
64
64
  key = path[index]
65
65
  except IndexError:
66
- if isinstance(obj, NotGiven):
66
+ if not is_given(obj):
67
67
  # no value was provided - we can safely ignore
68
68
  return []
69
69
 
@@ -126,8 +126,8 @@ def _extract_items(
126
126
  return []
127
127
 
128
128
 
129
- def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]:
130
- return not isinstance(obj, NotGiven)
129
+ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
130
+ return not isinstance(obj, NotGiven) and not isinstance(obj, Omit)
131
131
 
132
132
 
133
133
  # Type safe methods for narrowing types with TypeVars.
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "perplexity"
4
- __version__ = "0.9.0" # x-release-please-version
4
+ __version__ = "0.11.0" # x-release-please-version
@@ -6,7 +6,7 @@ from typing import Optional
6
6
 
7
7
  import httpx
8
8
 
9
- from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9
+ from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
10
10
  from ...._utils import maybe_transform, strip_not_given, async_maybe_transform
11
11
  from ...._compat import cached_property
12
12
  from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -49,13 +49,13 @@ class CompletionsResource(SyncAPIResource):
49
49
  self,
50
50
  *,
51
51
  request: completion_create_params.Request,
52
- idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
52
+ idempotency_key: Optional[str] | Omit = omit,
53
53
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
54
54
  # The extra values given here take precedence over values defined on the client or passed to this method.
55
55
  extra_headers: Headers | None = None,
56
56
  extra_query: Query | None = None,
57
57
  extra_body: Body | None = None,
58
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
58
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
59
59
  ) -> CompletionCreateResponse:
60
60
  """
61
61
  FastAPI wrapper around async chat completions
@@ -95,7 +95,7 @@ class CompletionsResource(SyncAPIResource):
95
95
  extra_headers: Headers | None = None,
96
96
  extra_query: Query | None = None,
97
97
  extra_body: Body | None = None,
98
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
98
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
99
99
  ) -> CompletionListResponse:
100
100
  """list all async chat completion requests for a given user."""
101
101
  return self._get(
@@ -110,18 +110,18 @@ class CompletionsResource(SyncAPIResource):
110
110
  self,
111
111
  api_request: str,
112
112
  *,
113
- local_mode: bool | NotGiven = NOT_GIVEN,
114
- x_client_env: str | NotGiven = NOT_GIVEN,
115
- x_client_name: str | NotGiven = NOT_GIVEN,
116
- x_request_time: str | NotGiven = NOT_GIVEN,
117
- x_usage_tier: str | NotGiven = NOT_GIVEN,
118
- x_user_id: str | NotGiven = NOT_GIVEN,
113
+ local_mode: bool | Omit = omit,
114
+ x_client_env: str | Omit = omit,
115
+ x_client_name: str | Omit = omit,
116
+ x_request_time: str | Omit = omit,
117
+ x_usage_tier: str | Omit = omit,
118
+ x_user_id: str | Omit = omit,
119
119
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
120
120
  # The extra values given here take precedence over values defined on the client or passed to this method.
121
121
  extra_headers: Headers | None = None,
122
122
  extra_query: Query | None = None,
123
123
  extra_body: Body | None = None,
124
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
124
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
125
125
  ) -> CompletionGetResponse:
126
126
  """
127
127
  get the response for a given async chat completion request.
@@ -186,13 +186,13 @@ class AsyncCompletionsResource(AsyncAPIResource):
186
186
  self,
187
187
  *,
188
188
  request: completion_create_params.Request,
189
- idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
189
+ idempotency_key: Optional[str] | Omit = omit,
190
190
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191
191
  # The extra values given here take precedence over values defined on the client or passed to this method.
192
192
  extra_headers: Headers | None = None,
193
193
  extra_query: Query | None = None,
194
194
  extra_body: Body | None = None,
195
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
195
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
196
196
  ) -> CompletionCreateResponse:
197
197
  """
198
198
  FastAPI wrapper around async chat completions
@@ -232,7 +232,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
232
232
  extra_headers: Headers | None = None,
233
233
  extra_query: Query | None = None,
234
234
  extra_body: Body | None = None,
235
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
235
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
236
236
  ) -> CompletionListResponse:
237
237
  """list all async chat completion requests for a given user."""
238
238
  return await self._get(
@@ -247,18 +247,18 @@ class AsyncCompletionsResource(AsyncAPIResource):
247
247
  self,
248
248
  api_request: str,
249
249
  *,
250
- local_mode: bool | NotGiven = NOT_GIVEN,
251
- x_client_env: str | NotGiven = NOT_GIVEN,
252
- x_client_name: str | NotGiven = NOT_GIVEN,
253
- x_request_time: str | NotGiven = NOT_GIVEN,
254
- x_usage_tier: str | NotGiven = NOT_GIVEN,
255
- x_user_id: str | NotGiven = NOT_GIVEN,
250
+ local_mode: bool | Omit = omit,
251
+ x_client_env: str | Omit = omit,
252
+ x_client_name: str | Omit = omit,
253
+ x_request_time: str | Omit = omit,
254
+ x_usage_tier: str | Omit = omit,
255
+ x_user_id: str | Omit = omit,
256
256
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
257
257
  # The extra values given here take precedence over values defined on the client or passed to this method.
258
258
  extra_headers: Headers | None = None,
259
259
  extra_query: Query | None = None,
260
260
  extra_body: Body | None = None,
261
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
261
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
262
262
  ) -> CompletionGetResponse:
263
263
  """
264
264
  get the response for a given async chat completion request.