perplexityai 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- perplexity/_version.py +1 -1
- perplexity/resources/search.py +18 -18
- perplexity/types/__init__.py +2 -2
- perplexity/types/{search_perform_params.py → search_create_params.py} +2 -2
- perplexity/types/{search_perform_response.py → search_create_response.py} +2 -2
- {perplexityai-0.3.0.dist-info → perplexityai-0.4.0.dist-info}/METADATA +13 -13
- {perplexityai-0.3.0.dist-info → perplexityai-0.4.0.dist-info}/RECORD +9 -9
- {perplexityai-0.3.0.dist-info → perplexityai-0.4.0.dist-info}/WHEEL +0 -0
- {perplexityai-0.3.0.dist-info → perplexityai-0.4.0.dist-info}/licenses/LICENSE +0 -0
perplexity/_version.py
CHANGED
perplexity/resources/search.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing_extensions import Literal
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
|
-
from ..types import
|
|
10
|
+
from ..types import search_create_params
|
|
11
11
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
|
|
12
12
|
from .._utils import maybe_transform, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
@@ -19,7 +19,7 @@ from .._response import (
|
|
|
19
19
|
async_to_streamed_response_wrapper,
|
|
20
20
|
)
|
|
21
21
|
from .._base_client import make_request_options
|
|
22
|
-
from ..types.
|
|
22
|
+
from ..types.search_create_response import SearchCreateResponse
|
|
23
23
|
|
|
24
24
|
__all__ = ["SearchResource", "AsyncSearchResource"]
|
|
25
25
|
|
|
@@ -44,7 +44,7 @@ class SearchResource(SyncAPIResource):
|
|
|
44
44
|
"""
|
|
45
45
|
return SearchResourceWithStreamingResponse(self)
|
|
46
46
|
|
|
47
|
-
def
|
|
47
|
+
def create(
|
|
48
48
|
self,
|
|
49
49
|
*,
|
|
50
50
|
query: Union[str, SequenceNotStr[str]],
|
|
@@ -65,7 +65,7 @@ class SearchResource(SyncAPIResource):
|
|
|
65
65
|
extra_query: Query | None = None,
|
|
66
66
|
extra_body: Body | None = None,
|
|
67
67
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
68
|
-
) ->
|
|
68
|
+
) -> SearchCreateResponse:
|
|
69
69
|
"""
|
|
70
70
|
Search
|
|
71
71
|
|
|
@@ -95,12 +95,12 @@ class SearchResource(SyncAPIResource):
|
|
|
95
95
|
"search_mode": search_mode,
|
|
96
96
|
"search_recency_filter": search_recency_filter,
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
search_create_params.SearchCreateParams,
|
|
99
99
|
),
|
|
100
100
|
options=make_request_options(
|
|
101
101
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
102
102
|
),
|
|
103
|
-
cast_to=
|
|
103
|
+
cast_to=SearchCreateResponse,
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
|
|
@@ -124,7 +124,7 @@ class AsyncSearchResource(AsyncAPIResource):
|
|
|
124
124
|
"""
|
|
125
125
|
return AsyncSearchResourceWithStreamingResponse(self)
|
|
126
126
|
|
|
127
|
-
async def
|
|
127
|
+
async def create(
|
|
128
128
|
self,
|
|
129
129
|
*,
|
|
130
130
|
query: Union[str, SequenceNotStr[str]],
|
|
@@ -145,7 +145,7 @@ class AsyncSearchResource(AsyncAPIResource):
|
|
|
145
145
|
extra_query: Query | None = None,
|
|
146
146
|
extra_body: Body | None = None,
|
|
147
147
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
148
|
-
) ->
|
|
148
|
+
) -> SearchCreateResponse:
|
|
149
149
|
"""
|
|
150
150
|
Search
|
|
151
151
|
|
|
@@ -175,12 +175,12 @@ class AsyncSearchResource(AsyncAPIResource):
|
|
|
175
175
|
"search_mode": search_mode,
|
|
176
176
|
"search_recency_filter": search_recency_filter,
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
search_create_params.SearchCreateParams,
|
|
179
179
|
),
|
|
180
180
|
options=make_request_options(
|
|
181
181
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
182
182
|
),
|
|
183
|
-
cast_to=
|
|
183
|
+
cast_to=SearchCreateResponse,
|
|
184
184
|
)
|
|
185
185
|
|
|
186
186
|
|
|
@@ -188,8 +188,8 @@ class SearchResourceWithRawResponse:
|
|
|
188
188
|
def __init__(self, search: SearchResource) -> None:
|
|
189
189
|
self._search = search
|
|
190
190
|
|
|
191
|
-
self.
|
|
192
|
-
search.
|
|
191
|
+
self.create = to_raw_response_wrapper(
|
|
192
|
+
search.create,
|
|
193
193
|
)
|
|
194
194
|
|
|
195
195
|
|
|
@@ -197,8 +197,8 @@ class AsyncSearchResourceWithRawResponse:
|
|
|
197
197
|
def __init__(self, search: AsyncSearchResource) -> None:
|
|
198
198
|
self._search = search
|
|
199
199
|
|
|
200
|
-
self.
|
|
201
|
-
search.
|
|
200
|
+
self.create = async_to_raw_response_wrapper(
|
|
201
|
+
search.create,
|
|
202
202
|
)
|
|
203
203
|
|
|
204
204
|
|
|
@@ -206,8 +206,8 @@ class SearchResourceWithStreamingResponse:
|
|
|
206
206
|
def __init__(self, search: SearchResource) -> None:
|
|
207
207
|
self._search = search
|
|
208
208
|
|
|
209
|
-
self.
|
|
210
|
-
search.
|
|
209
|
+
self.create = to_streamed_response_wrapper(
|
|
210
|
+
search.create,
|
|
211
211
|
)
|
|
212
212
|
|
|
213
213
|
|
|
@@ -215,6 +215,6 @@ class AsyncSearchResourceWithStreamingResponse:
|
|
|
215
215
|
def __init__(self, search: AsyncSearchResource) -> None:
|
|
216
216
|
self._search = search
|
|
217
217
|
|
|
218
|
-
self.
|
|
219
|
-
search.
|
|
218
|
+
self.create = async_to_streamed_response_wrapper(
|
|
219
|
+
search.create,
|
|
220
220
|
)
|
perplexity/types/__init__.py
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from .
|
|
6
|
-
from .
|
|
5
|
+
from .search_create_params import SearchCreateParams as SearchCreateParams
|
|
6
|
+
from .search_create_response import SearchCreateResponse as SearchCreateResponse
|
|
@@ -7,10 +7,10 @@ from typing_extensions import Literal, Required, TypedDict
|
|
|
7
7
|
|
|
8
8
|
from .._types import SequenceNotStr
|
|
9
9
|
|
|
10
|
-
__all__ = ["
|
|
10
|
+
__all__ = ["SearchCreateParams"]
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class SearchCreateParams(TypedDict, total=False):
|
|
14
14
|
query: Required[Union[str, SequenceNotStr[str]]]
|
|
15
15
|
|
|
16
16
|
country: Optional[str]
|
|
@@ -4,7 +4,7 @@ from typing import List, Optional
|
|
|
4
4
|
|
|
5
5
|
from .._models import BaseModel
|
|
6
6
|
|
|
7
|
-
__all__ = ["
|
|
7
|
+
__all__ = ["SearchCreateResponse", "Result"]
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Result(BaseModel):
|
|
@@ -19,7 +19,7 @@ class Result(BaseModel):
|
|
|
19
19
|
last_updated: Optional[str] = None
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class SearchCreateResponse(BaseModel):
|
|
23
23
|
id: str
|
|
24
24
|
|
|
25
25
|
results: List[Result]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: perplexityai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.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
|
|
@@ -67,10 +67,10 @@ client = Perplexity(
|
|
|
67
67
|
bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
search = client.search.create(
|
|
71
71
|
query="string",
|
|
72
72
|
)
|
|
73
|
-
print(
|
|
73
|
+
print(search.id)
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
While you can provide a `bearer_token` keyword argument,
|
|
@@ -93,10 +93,10 @@ client = AsyncPerplexity(
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
async def main() -> None:
|
|
96
|
-
|
|
96
|
+
search = await client.search.create(
|
|
97
97
|
query="string",
|
|
98
98
|
)
|
|
99
|
-
print(
|
|
99
|
+
print(search.id)
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
asyncio.run(main())
|
|
@@ -128,10 +128,10 @@ async def main() -> None:
|
|
|
128
128
|
bearer_token="My Bearer Token",
|
|
129
129
|
http_client=DefaultAioHttpClient(),
|
|
130
130
|
) as client:
|
|
131
|
-
|
|
131
|
+
search = await client.search.create(
|
|
132
132
|
query="string",
|
|
133
133
|
)
|
|
134
|
-
print(
|
|
134
|
+
print(search.id)
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
asyncio.run(main())
|
|
@@ -162,7 +162,7 @@ from perplexity import Perplexity
|
|
|
162
162
|
client = Perplexity()
|
|
163
163
|
|
|
164
164
|
try:
|
|
165
|
-
client.search.
|
|
165
|
+
client.search.create(
|
|
166
166
|
query="string",
|
|
167
167
|
)
|
|
168
168
|
except perplexity.APIConnectionError as e:
|
|
@@ -207,7 +207,7 @@ client = Perplexity(
|
|
|
207
207
|
)
|
|
208
208
|
|
|
209
209
|
# Or, configure per-request:
|
|
210
|
-
client.with_options(max_retries=5).search.
|
|
210
|
+
client.with_options(max_retries=5).search.create(
|
|
211
211
|
query="string",
|
|
212
212
|
)
|
|
213
213
|
```
|
|
@@ -232,7 +232,7 @@ client = Perplexity(
|
|
|
232
232
|
)
|
|
233
233
|
|
|
234
234
|
# Override per-request:
|
|
235
|
-
client.with_options(timeout=5.0).search.
|
|
235
|
+
client.with_options(timeout=5.0).search.create(
|
|
236
236
|
query="string",
|
|
237
237
|
)
|
|
238
238
|
```
|
|
@@ -275,12 +275,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
275
275
|
from perplexity import Perplexity
|
|
276
276
|
|
|
277
277
|
client = Perplexity()
|
|
278
|
-
response = client.search.with_raw_response.
|
|
278
|
+
response = client.search.with_raw_response.create(
|
|
279
279
|
query="string",
|
|
280
280
|
)
|
|
281
281
|
print(response.headers.get('X-My-Header'))
|
|
282
282
|
|
|
283
|
-
search = response.parse() # get the object that `search.
|
|
283
|
+
search = response.parse() # get the object that `search.create()` would have returned
|
|
284
284
|
print(search.id)
|
|
285
285
|
```
|
|
286
286
|
|
|
@@ -295,7 +295,7 @@ The above interface eagerly reads the full response body when you make the reque
|
|
|
295
295
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
|
296
296
|
|
|
297
297
|
```python
|
|
298
|
-
with client.search.with_streaming_response.
|
|
298
|
+
with client.search.with_streaming_response.create(
|
|
299
299
|
query="string",
|
|
300
300
|
) as response:
|
|
301
301
|
print(response.headers.get("X-My-Header"))
|
|
@@ -11,7 +11,7 @@ perplexity/_resource.py,sha256=Pgc8KNBsIc1ltJn94uhDcDl0-3n5RLbe3iC2AiiNRnE,1124
|
|
|
11
11
|
perplexity/_response.py,sha256=bpqzmVGq6jnivoMkUgt3OI0Rh6xHd6BMcp5PHgSFPb0,28842
|
|
12
12
|
perplexity/_streaming.py,sha256=SQ61v42gFmNiO57uMFUZMAuDlGE0n_EulkZcPgJXt4U,10116
|
|
13
13
|
perplexity/_types.py,sha256=XZYv2_G7oQGhQkjI28-TFIMP_yZZV590TRuKAoLJ3wM,7300
|
|
14
|
-
perplexity/_version.py,sha256=
|
|
14
|
+
perplexity/_version.py,sha256=QazGxOaPhzOlDQUA-C5O4AvYyIhQ_UnLWKUqg_rFehU,162
|
|
15
15
|
perplexity/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
perplexity/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
|
|
17
17
|
perplexity/_utils/_compat.py,sha256=D8gtAvjJQrDWt9upS0XaG9Rr5l1QhiAx_I_1utT_tt0,1195
|
|
@@ -27,11 +27,11 @@ perplexity/_utils/_typing.py,sha256=N_5PPuFNsaygbtA_npZd98SVN1LQQvFTKL6bkWPBZGU,
|
|
|
27
27
|
perplexity/_utils/_utils.py,sha256=D2QE7mVPNEJzaB50u8rvDQAUDS5jx7JoeFD7zdj-TeI,12231
|
|
28
28
|
perplexity/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
29
29
|
perplexity/resources/__init__.py,sha256=e0o4Fhm2rFANVaRFoUJUmfCjJunhyhiJHWWRRnwv_yg,552
|
|
30
|
-
perplexity/resources/search.py,sha256=
|
|
31
|
-
perplexity/types/__init__.py,sha256=
|
|
32
|
-
perplexity/types/
|
|
33
|
-
perplexity/types/
|
|
34
|
-
perplexityai-0.
|
|
35
|
-
perplexityai-0.
|
|
36
|
-
perplexityai-0.
|
|
37
|
-
perplexityai-0.
|
|
30
|
+
perplexity/resources/search.py,sha256=8wlC-XJbprA1q6Ba_MZQ4aABUKvPnpBuFoY__YWaZOY,9028
|
|
31
|
+
perplexity/types/__init__.py,sha256=yc0WYtyPE_vei_eT8gwY9-g7otC7EJjQpKSdeBcte4Y,279
|
|
32
|
+
perplexity/types/search_create_params.py,sha256=RR5716GptBeuX99P0VHICzd5fEYsiwKdz1bW8nAlujI,886
|
|
33
|
+
perplexity/types/search_create_response.py,sha256=lOteaJs4qpULkx5GLtEs6HhetqIBhM0I1AC1moWTeI8,426
|
|
34
|
+
perplexityai-0.4.0.dist-info/METADATA,sha256=Md245aFBmveFwVDcB6gAqZ3gEfC8Ze5YMxGPHuvZeEc,13655
|
|
35
|
+
perplexityai-0.4.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
36
|
+
perplexityai-0.4.0.dist-info/licenses/LICENSE,sha256=hkCriG3MT4vBhhc0roAOsrCE7IEDr1ywVEMonVHGmAQ,11340
|
|
37
|
+
perplexityai-0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|