perplexityai 0.4.0__tar.gz → 0.6.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 (75) hide show
  1. perplexityai-0.6.0/.release-please-manifest.json +3 -0
  2. {perplexityai-0.4.0 → perplexityai-0.6.0}/CHANGELOG.md +17 -0
  3. {perplexityai-0.4.0 → perplexityai-0.6.0}/PKG-INFO +7 -7
  4. {perplexityai-0.4.0 → perplexityai-0.6.0}/README.md +6 -6
  5. perplexityai-0.6.0/api.md +23 -0
  6. {perplexityai-0.4.0 → perplexityai-0.6.0}/pyproject.toml +1 -1
  7. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_client.py +33 -25
  8. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_version.py +1 -1
  9. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/resources/__init__.py +14 -0
  10. perplexityai-0.6.0/src/perplexity/resources/content.py +163 -0
  11. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/resources/search.py +4 -0
  12. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/types/__init__.py +2 -0
  13. perplexityai-0.6.0/src/perplexity/types/content_create_params.py +13 -0
  14. perplexityai-0.6.0/src/perplexity/types/content_create_response.py +23 -0
  15. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/types/search_create_params.py +2 -0
  16. perplexityai-0.6.0/tests/api_resources/test_content.py +92 -0
  17. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/api_resources/test_search.py +2 -0
  18. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/conftest.py +3 -3
  19. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_client.py +63 -101
  20. perplexityai-0.4.0/.release-please-manifest.json +0 -3
  21. perplexityai-0.4.0/api.md +0 -11
  22. {perplexityai-0.4.0 → perplexityai-0.6.0}/.gitignore +0 -0
  23. {perplexityai-0.4.0 → perplexityai-0.6.0}/CONTRIBUTING.md +0 -0
  24. {perplexityai-0.4.0 → perplexityai-0.6.0}/LICENSE +0 -0
  25. {perplexityai-0.4.0 → perplexityai-0.6.0}/SECURITY.md +0 -0
  26. {perplexityai-0.4.0 → perplexityai-0.6.0}/bin/check-release-environment +0 -0
  27. {perplexityai-0.4.0 → perplexityai-0.6.0}/bin/publish-pypi +0 -0
  28. {perplexityai-0.4.0 → perplexityai-0.6.0}/examples/.keep +0 -0
  29. {perplexityai-0.4.0 → perplexityai-0.6.0}/noxfile.py +0 -0
  30. {perplexityai-0.4.0 → perplexityai-0.6.0}/release-please-config.json +0 -0
  31. {perplexityai-0.4.0 → perplexityai-0.6.0}/requirements-dev.lock +0 -0
  32. {perplexityai-0.4.0 → perplexityai-0.6.0}/requirements.lock +0 -0
  33. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/__init__.py +0 -0
  34. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_base_client.py +0 -0
  35. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_compat.py +0 -0
  36. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_constants.py +0 -0
  37. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_exceptions.py +0 -0
  38. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_files.py +0 -0
  39. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_models.py +0 -0
  40. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_qs.py +0 -0
  41. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_resource.py +0 -0
  42. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_response.py +0 -0
  43. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_streaming.py +0 -0
  44. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_types.py +0 -0
  45. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/__init__.py +0 -0
  46. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_compat.py +0 -0
  47. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_datetime_parse.py +0 -0
  48. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_logs.py +0 -0
  49. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_proxy.py +0 -0
  50. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_reflection.py +0 -0
  51. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_resources_proxy.py +0 -0
  52. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_streams.py +0 -0
  53. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_sync.py +0 -0
  54. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_transform.py +0 -0
  55. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_typing.py +0 -0
  56. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/_utils/_utils.py +0 -0
  57. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/lib/.keep +0 -0
  58. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/py.typed +0 -0
  59. {perplexityai-0.4.0 → perplexityai-0.6.0}/src/perplexity/types/search_create_response.py +0 -0
  60. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/__init__.py +0 -0
  61. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/api_resources/__init__.py +0 -0
  62. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/sample_file.txt +0 -0
  63. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_deepcopy.py +0 -0
  64. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_extract_files.py +0 -0
  65. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_files.py +0 -0
  66. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_models.py +0 -0
  67. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_qs.py +0 -0
  68. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_required_args.py +0 -0
  69. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_response.py +0 -0
  70. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_streaming.py +0 -0
  71. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_transform.py +0 -0
  72. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_utils/test_datetime_parse.py +0 -0
  73. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_utils/test_proxy.py +0 -0
  74. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/test_utils/test_typing.py +0 -0
  75. {perplexityai-0.4.0 → perplexityai-0.6.0}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.6.0"
3
+ }
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 (2025-09-08)
4
+
5
+ Full Changelog: [v0.5.0...v0.6.0](https://github.com/ppl-ai/perplexity-py/compare/v0.5.0...v0.6.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** add /content endpoint ([a83e23b](https://github.com/ppl-ai/perplexity-py/commit/a83e23bbcacc8b80748ccf512f3a287ed6011a37))
10
+ * **api:** include /content endpoint ([d30ca3e](https://github.com/ppl-ai/perplexity-py/commit/d30ca3e3697f8fd5e17f00762ab2a89ea4d5814f))
11
+
12
+ ## 0.5.0 (2025-09-08)
13
+
14
+ Full Changelog: [v0.4.0...v0.5.0](https://github.com/ppl-ai/perplexity-py/compare/v0.4.0...v0.5.0)
15
+
16
+ ### Features
17
+
18
+ * **api:** change bearer_token to api_key ([875bba1](https://github.com/ppl-ai/perplexity-py/commit/875bba126072093d572f00818746b0637a1a56a6))
19
+
3
20
  ## 0.4.0 (2025-09-07)
4
21
 
5
22
  Full Changelog: [v0.3.0...v0.4.0](https://github.com/ppl-ai/perplexity-py/compare/v0.3.0...v0.4.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: perplexityai
3
- Version: 0.4.0
3
+ Version: 0.6.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
@@ -64,7 +64,7 @@ import os
64
64
  from perplexity import Perplexity
65
65
 
66
66
  client = Perplexity(
67
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
67
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
68
68
  )
69
69
 
70
70
  search = client.search.create(
@@ -73,10 +73,10 @@ search = client.search.create(
73
73
  print(search.id)
74
74
  ```
75
75
 
76
- While you can provide a `bearer_token` keyword argument,
76
+ While you can provide an `api_key` keyword argument,
77
77
  we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
78
- to add `PERPLEXITY_API_KEY="My Bearer Token"` to your `.env` file
79
- so that your Bearer Token is not stored in source control.
78
+ to add `PERPLEXITY_API_KEY="My API Key"` to your `.env` file
79
+ so that your API Key is not stored in source control.
80
80
 
81
81
  ## Async usage
82
82
 
@@ -88,7 +88,7 @@ import asyncio
88
88
  from perplexity import AsyncPerplexity
89
89
 
90
90
  client = AsyncPerplexity(
91
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
91
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
92
92
  )
93
93
 
94
94
 
@@ -125,7 +125,7 @@ from perplexity import AsyncPerplexity
125
125
 
126
126
  async def main() -> None:
127
127
  async with AsyncPerplexity(
128
- bearer_token="My Bearer Token",
128
+ api_key="My API Key",
129
129
  http_client=DefaultAioHttpClient(),
130
130
  ) as client:
131
131
  search = await client.search.create(
@@ -29,7 +29,7 @@ import os
29
29
  from perplexity import Perplexity
30
30
 
31
31
  client = Perplexity(
32
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
32
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
33
33
  )
34
34
 
35
35
  search = client.search.create(
@@ -38,10 +38,10 @@ search = client.search.create(
38
38
  print(search.id)
39
39
  ```
40
40
 
41
- While you can provide a `bearer_token` keyword argument,
41
+ While you can provide an `api_key` keyword argument,
42
42
  we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
43
- to add `PERPLEXITY_API_KEY="My Bearer Token"` to your `.env` file
44
- so that your Bearer Token is not stored in source control.
43
+ to add `PERPLEXITY_API_KEY="My API Key"` to your `.env` file
44
+ so that your API Key is not stored in source control.
45
45
 
46
46
  ## Async usage
47
47
 
@@ -53,7 +53,7 @@ import asyncio
53
53
  from perplexity import AsyncPerplexity
54
54
 
55
55
  client = AsyncPerplexity(
56
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
56
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
57
57
  )
58
58
 
59
59
 
@@ -90,7 +90,7 @@ from perplexity import AsyncPerplexity
90
90
 
91
91
  async def main() -> None:
92
92
  async with AsyncPerplexity(
93
- bearer_token="My Bearer Token",
93
+ api_key="My API Key",
94
94
  http_client=DefaultAioHttpClient(),
95
95
  ) as client:
96
96
  search = await client.search.create(
@@ -0,0 +1,23 @@
1
+ # Search
2
+
3
+ Types:
4
+
5
+ ```python
6
+ from perplexity.types import SearchCreateResponse
7
+ ```
8
+
9
+ Methods:
10
+
11
+ - <code title="post /search">client.search.<a href="./src/perplexity/resources/search.py">create</a>(\*\*<a href="src/perplexity/types/search_create_params.py">params</a>) -> <a href="./src/perplexity/types/search_create_response.py">SearchCreateResponse</a></code>
12
+
13
+ # Content
14
+
15
+ Types:
16
+
17
+ ```python
18
+ from perplexity.types import ContentCreateResponse
19
+ ```
20
+
21
+ Methods:
22
+
23
+ - <code title="post /content">client.content.<a href="./src/perplexity/resources/content.py">create</a>(\*\*<a href="src/perplexity/types/content_create_params.py">params</a>) -> <a href="./src/perplexity/types/content_create_response.py">ContentCreateResponse</a></code>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "perplexityai"
3
- version = "0.4.0"
3
+ version = "0.6.0"
4
4
  description = "The official Python library for the perplexity API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -21,7 +21,7 @@ from ._types import (
21
21
  )
22
22
  from ._utils import is_given, get_async_library
23
23
  from ._version import __version__
24
- from .resources import search
24
+ from .resources import search, content
25
25
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
26
26
  from ._exceptions import APIStatusError, PerplexityError
27
27
  from ._base_client import (
@@ -44,16 +44,17 @@ __all__ = [
44
44
 
45
45
  class Perplexity(SyncAPIClient):
46
46
  search: search.SearchResource
47
+ content: content.ContentResource
47
48
  with_raw_response: PerplexityWithRawResponse
48
49
  with_streaming_response: PerplexityWithStreamedResponse
49
50
 
50
51
  # client options
51
- bearer_token: str
52
+ api_key: str
52
53
 
53
54
  def __init__(
54
55
  self,
55
56
  *,
56
- bearer_token: str | None = None,
57
+ api_key: str | None = None,
57
58
  base_url: str | httpx.URL | None = None,
58
59
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
59
60
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -75,15 +76,15 @@ class Perplexity(SyncAPIClient):
75
76
  ) -> None:
76
77
  """Construct a new synchronous Perplexity client instance.
77
78
 
78
- This automatically infers the `bearer_token` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
79
+ This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
79
80
  """
80
- if bearer_token is None:
81
- bearer_token = os.environ.get("PERPLEXITY_API_KEY")
82
- if bearer_token is None:
81
+ if api_key is None:
82
+ api_key = os.environ.get("PERPLEXITY_API_KEY")
83
+ if api_key is None:
83
84
  raise PerplexityError(
84
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the PERPLEXITY_API_KEY environment variable"
85
+ "The api_key client option must be set either by passing api_key to the client or by setting the PERPLEXITY_API_KEY environment variable"
85
86
  )
86
- self.bearer_token = bearer_token
87
+ self.api_key = api_key
87
88
 
88
89
  if base_url is None:
89
90
  base_url = os.environ.get("PERPLEXITY_BASE_URL")
@@ -102,6 +103,7 @@ class Perplexity(SyncAPIClient):
102
103
  )
103
104
 
104
105
  self.search = search.SearchResource(self)
106
+ self.content = content.ContentResource(self)
105
107
  self.with_raw_response = PerplexityWithRawResponse(self)
106
108
  self.with_streaming_response = PerplexityWithStreamedResponse(self)
107
109
 
@@ -113,8 +115,8 @@ class Perplexity(SyncAPIClient):
113
115
  @property
114
116
  @override
115
117
  def auth_headers(self) -> dict[str, str]:
116
- bearer_token = self.bearer_token
117
- return {"Authorization": f"Bearer {bearer_token}"}
118
+ api_key = self.api_key
119
+ return {"Authorization": f"Bearer {api_key}"}
118
120
 
119
121
  @property
120
122
  @override
@@ -128,7 +130,7 @@ class Perplexity(SyncAPIClient):
128
130
  def copy(
129
131
  self,
130
132
  *,
131
- bearer_token: str | None = None,
133
+ api_key: str | None = None,
132
134
  base_url: str | httpx.URL | None = None,
133
135
  timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
134
136
  http_client: httpx.Client | None = None,
@@ -162,7 +164,7 @@ class Perplexity(SyncAPIClient):
162
164
 
163
165
  http_client = http_client or self._client
164
166
  return self.__class__(
165
- bearer_token=bearer_token or self.bearer_token,
167
+ api_key=api_key or self.api_key,
166
168
  base_url=base_url or self.base_url,
167
169
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
168
170
  http_client=http_client,
@@ -212,16 +214,17 @@ class Perplexity(SyncAPIClient):
212
214
 
213
215
  class AsyncPerplexity(AsyncAPIClient):
214
216
  search: search.AsyncSearchResource
217
+ content: content.AsyncContentResource
215
218
  with_raw_response: AsyncPerplexityWithRawResponse
216
219
  with_streaming_response: AsyncPerplexityWithStreamedResponse
217
220
 
218
221
  # client options
219
- bearer_token: str
222
+ api_key: str
220
223
 
221
224
  def __init__(
222
225
  self,
223
226
  *,
224
- bearer_token: str | None = None,
227
+ api_key: str | None = None,
225
228
  base_url: str | httpx.URL | None = None,
226
229
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
227
230
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -243,15 +246,15 @@ class AsyncPerplexity(AsyncAPIClient):
243
246
  ) -> None:
244
247
  """Construct a new async AsyncPerplexity client instance.
245
248
 
246
- This automatically infers the `bearer_token` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
249
+ This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
247
250
  """
248
- if bearer_token is None:
249
- bearer_token = os.environ.get("PERPLEXITY_API_KEY")
250
- if bearer_token is None:
251
+ if api_key is None:
252
+ api_key = os.environ.get("PERPLEXITY_API_KEY")
253
+ if api_key is None:
251
254
  raise PerplexityError(
252
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the PERPLEXITY_API_KEY environment variable"
255
+ "The api_key client option must be set either by passing api_key to the client or by setting the PERPLEXITY_API_KEY environment variable"
253
256
  )
254
- self.bearer_token = bearer_token
257
+ self.api_key = api_key
255
258
 
256
259
  if base_url is None:
257
260
  base_url = os.environ.get("PERPLEXITY_BASE_URL")
@@ -270,6 +273,7 @@ class AsyncPerplexity(AsyncAPIClient):
270
273
  )
271
274
 
272
275
  self.search = search.AsyncSearchResource(self)
276
+ self.content = content.AsyncContentResource(self)
273
277
  self.with_raw_response = AsyncPerplexityWithRawResponse(self)
274
278
  self.with_streaming_response = AsyncPerplexityWithStreamedResponse(self)
275
279
 
@@ -281,8 +285,8 @@ class AsyncPerplexity(AsyncAPIClient):
281
285
  @property
282
286
  @override
283
287
  def auth_headers(self) -> dict[str, str]:
284
- bearer_token = self.bearer_token
285
- return {"Authorization": f"Bearer {bearer_token}"}
288
+ api_key = self.api_key
289
+ return {"Authorization": f"Bearer {api_key}"}
286
290
 
287
291
  @property
288
292
  @override
@@ -296,7 +300,7 @@ class AsyncPerplexity(AsyncAPIClient):
296
300
  def copy(
297
301
  self,
298
302
  *,
299
- bearer_token: str | None = None,
303
+ api_key: str | None = None,
300
304
  base_url: str | httpx.URL | None = None,
301
305
  timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
302
306
  http_client: httpx.AsyncClient | None = None,
@@ -330,7 +334,7 @@ class AsyncPerplexity(AsyncAPIClient):
330
334
 
331
335
  http_client = http_client or self._client
332
336
  return self.__class__(
333
- bearer_token=bearer_token or self.bearer_token,
337
+ api_key=api_key or self.api_key,
334
338
  base_url=base_url or self.base_url,
335
339
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
336
340
  http_client=http_client,
@@ -381,21 +385,25 @@ class AsyncPerplexity(AsyncAPIClient):
381
385
  class PerplexityWithRawResponse:
382
386
  def __init__(self, client: Perplexity) -> None:
383
387
  self.search = search.SearchResourceWithRawResponse(client.search)
388
+ self.content = content.ContentResourceWithRawResponse(client.content)
384
389
 
385
390
 
386
391
  class AsyncPerplexityWithRawResponse:
387
392
  def __init__(self, client: AsyncPerplexity) -> None:
388
393
  self.search = search.AsyncSearchResourceWithRawResponse(client.search)
394
+ self.content = content.AsyncContentResourceWithRawResponse(client.content)
389
395
 
390
396
 
391
397
  class PerplexityWithStreamedResponse:
392
398
  def __init__(self, client: Perplexity) -> None:
393
399
  self.search = search.SearchResourceWithStreamingResponse(client.search)
400
+ self.content = content.ContentResourceWithStreamingResponse(client.content)
394
401
 
395
402
 
396
403
  class AsyncPerplexityWithStreamedResponse:
397
404
  def __init__(self, client: AsyncPerplexity) -> None:
398
405
  self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
406
+ self.content = content.AsyncContentResourceWithStreamingResponse(client.content)
399
407
 
400
408
 
401
409
  Client = Perplexity
@@ -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.4.0" # x-release-please-version
4
+ __version__ = "0.6.0" # x-release-please-version
@@ -8,6 +8,14 @@ from .search import (
8
8
  SearchResourceWithStreamingResponse,
9
9
  AsyncSearchResourceWithStreamingResponse,
10
10
  )
11
+ from .content import (
12
+ ContentResource,
13
+ AsyncContentResource,
14
+ ContentResourceWithRawResponse,
15
+ AsyncContentResourceWithRawResponse,
16
+ ContentResourceWithStreamingResponse,
17
+ AsyncContentResourceWithStreamingResponse,
18
+ )
11
19
 
12
20
  __all__ = [
13
21
  "SearchResource",
@@ -16,4 +24,10 @@ __all__ = [
16
24
  "AsyncSearchResourceWithRawResponse",
17
25
  "SearchResourceWithStreamingResponse",
18
26
  "AsyncSearchResourceWithStreamingResponse",
27
+ "ContentResource",
28
+ "AsyncContentResource",
29
+ "ContentResourceWithRawResponse",
30
+ "AsyncContentResourceWithRawResponse",
31
+ "ContentResourceWithStreamingResponse",
32
+ "AsyncContentResourceWithStreamingResponse",
19
33
  ]
@@ -0,0 +1,163 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from ..types import content_create_params
8
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
9
+ from .._utils import maybe_transform, async_maybe_transform
10
+ from .._compat import cached_property
11
+ from .._resource import SyncAPIResource, AsyncAPIResource
12
+ from .._response import (
13
+ to_raw_response_wrapper,
14
+ to_streamed_response_wrapper,
15
+ async_to_raw_response_wrapper,
16
+ async_to_streamed_response_wrapper,
17
+ )
18
+ from .._base_client import make_request_options
19
+ from ..types.content_create_response import ContentCreateResponse
20
+
21
+ __all__ = ["ContentResource", "AsyncContentResource"]
22
+
23
+
24
+ class ContentResource(SyncAPIResource):
25
+ @cached_property
26
+ def with_raw_response(self) -> ContentResourceWithRawResponse:
27
+ """
28
+ This property can be used as a prefix for any HTTP method call to return
29
+ the raw response object instead of the parsed content.
30
+
31
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
32
+ """
33
+ return ContentResourceWithRawResponse(self)
34
+
35
+ @cached_property
36
+ def with_streaming_response(self) -> ContentResourceWithStreamingResponse:
37
+ """
38
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
39
+
40
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
41
+ """
42
+ return ContentResourceWithStreamingResponse(self)
43
+
44
+ def create(
45
+ self,
46
+ *,
47
+ urls: SequenceNotStr[str],
48
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
49
+ # The extra values given here take precedence over values defined on the client or passed to this method.
50
+ extra_headers: Headers | None = None,
51
+ extra_query: Query | None = None,
52
+ extra_body: Body | None = None,
53
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
54
+ ) -> ContentCreateResponse:
55
+ """
56
+ Get Urls Content
57
+
58
+ Args:
59
+ extra_headers: Send extra headers
60
+
61
+ extra_query: Add additional query parameters to the request
62
+
63
+ extra_body: Add additional JSON properties to the request
64
+
65
+ timeout: Override the client-level default timeout for this request, in seconds
66
+ """
67
+ return self._post(
68
+ "/content",
69
+ body=maybe_transform({"urls": urls}, content_create_params.ContentCreateParams),
70
+ options=make_request_options(
71
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
72
+ ),
73
+ cast_to=ContentCreateResponse,
74
+ )
75
+
76
+
77
+ class AsyncContentResource(AsyncAPIResource):
78
+ @cached_property
79
+ def with_raw_response(self) -> AsyncContentResourceWithRawResponse:
80
+ """
81
+ This property can be used as a prefix for any HTTP method call to return
82
+ the raw response object instead of the parsed content.
83
+
84
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
85
+ """
86
+ return AsyncContentResourceWithRawResponse(self)
87
+
88
+ @cached_property
89
+ def with_streaming_response(self) -> AsyncContentResourceWithStreamingResponse:
90
+ """
91
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
92
+
93
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
94
+ """
95
+ return AsyncContentResourceWithStreamingResponse(self)
96
+
97
+ async def create(
98
+ self,
99
+ *,
100
+ urls: SequenceNotStr[str],
101
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
102
+ # The extra values given here take precedence over values defined on the client or passed to this method.
103
+ extra_headers: Headers | None = None,
104
+ extra_query: Query | None = None,
105
+ extra_body: Body | None = None,
106
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
107
+ ) -> ContentCreateResponse:
108
+ """
109
+ Get Urls Content
110
+
111
+ Args:
112
+ extra_headers: Send extra headers
113
+
114
+ extra_query: Add additional query parameters to the request
115
+
116
+ extra_body: Add additional JSON properties to the request
117
+
118
+ timeout: Override the client-level default timeout for this request, in seconds
119
+ """
120
+ return await self._post(
121
+ "/content",
122
+ body=await async_maybe_transform({"urls": urls}, content_create_params.ContentCreateParams),
123
+ options=make_request_options(
124
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
125
+ ),
126
+ cast_to=ContentCreateResponse,
127
+ )
128
+
129
+
130
+ class ContentResourceWithRawResponse:
131
+ def __init__(self, content: ContentResource) -> None:
132
+ self._content = content
133
+
134
+ self.create = to_raw_response_wrapper(
135
+ content.create,
136
+ )
137
+
138
+
139
+ class AsyncContentResourceWithRawResponse:
140
+ def __init__(self, content: AsyncContentResource) -> None:
141
+ self._content = content
142
+
143
+ self.create = async_to_raw_response_wrapper(
144
+ content.create,
145
+ )
146
+
147
+
148
+ class ContentResourceWithStreamingResponse:
149
+ def __init__(self, content: ContentResource) -> None:
150
+ self._content = content
151
+
152
+ self.create = to_streamed_response_wrapper(
153
+ content.create,
154
+ )
155
+
156
+
157
+ class AsyncContentResourceWithStreamingResponse:
158
+ def __init__(self, content: AsyncContentResource) -> None:
159
+ self._content = content
160
+
161
+ self.create = async_to_streamed_response_wrapper(
162
+ content.create,
163
+ )
@@ -53,6 +53,7 @@ class SearchResource(SyncAPIResource):
53
53
  last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
54
54
  max_results: int | NotGiven = NOT_GIVEN,
55
55
  max_tokens: int | NotGiven = NOT_GIVEN,
56
+ max_tokens_per_page: int | NotGiven = NOT_GIVEN,
56
57
  safe_search: Optional[bool] | NotGiven = NOT_GIVEN,
57
58
  search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
58
59
  search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
@@ -88,6 +89,7 @@ class SearchResource(SyncAPIResource):
88
89
  "last_updated_before_filter": last_updated_before_filter,
89
90
  "max_results": max_results,
90
91
  "max_tokens": max_tokens,
92
+ "max_tokens_per_page": max_tokens_per_page,
91
93
  "safe_search": safe_search,
92
94
  "search_after_date_filter": search_after_date_filter,
93
95
  "search_before_date_filter": search_before_date_filter,
@@ -133,6 +135,7 @@ class AsyncSearchResource(AsyncAPIResource):
133
135
  last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
134
136
  max_results: int | NotGiven = NOT_GIVEN,
135
137
  max_tokens: int | NotGiven = NOT_GIVEN,
138
+ max_tokens_per_page: int | NotGiven = NOT_GIVEN,
136
139
  safe_search: Optional[bool] | NotGiven = NOT_GIVEN,
137
140
  search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
138
141
  search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
@@ -168,6 +171,7 @@ class AsyncSearchResource(AsyncAPIResource):
168
171
  "last_updated_before_filter": last_updated_before_filter,
169
172
  "max_results": max_results,
170
173
  "max_tokens": max_tokens,
174
+ "max_tokens_per_page": max_tokens_per_page,
171
175
  "safe_search": safe_search,
172
176
  "search_after_date_filter": search_after_date_filter,
173
177
  "search_before_date_filter": search_before_date_filter,
@@ -3,4 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from .search_create_params import SearchCreateParams as SearchCreateParams
6
+ from .content_create_params import ContentCreateParams as ContentCreateParams
6
7
  from .search_create_response import SearchCreateResponse as SearchCreateResponse
8
+ from .content_create_response import ContentCreateResponse as ContentCreateResponse
@@ -0,0 +1,13 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Required, TypedDict
6
+
7
+ from .._types import SequenceNotStr
8
+
9
+ __all__ = ["ContentCreateParams"]
10
+
11
+
12
+ class ContentCreateParams(TypedDict, total=False):
13
+ urls: Required[SequenceNotStr[str]]
@@ -0,0 +1,23 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import List, Optional
4
+
5
+ from .._models import BaseModel
6
+
7
+ __all__ = ["ContentCreateResponse", "Result"]
8
+
9
+
10
+ class Result(BaseModel):
11
+ content: str
12
+
13
+ title: str
14
+
15
+ url: str
16
+
17
+ date: Optional[str] = None
18
+
19
+
20
+ class ContentCreateResponse(BaseModel):
21
+ id: str
22
+
23
+ results: List[Result]
@@ -23,6 +23,8 @@ class SearchCreateParams(TypedDict, total=False):
23
23
 
24
24
  max_tokens: int
25
25
 
26
+ max_tokens_per_page: int
27
+
26
28
  safe_search: Optional[bool]
27
29
 
28
30
  search_after_date_filter: Optional[str]