perplexityai 0.4.0__py3-none-any.whl → 0.6.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/_client.py +33 -25
- perplexity/_version.py +1 -1
- perplexity/resources/__init__.py +14 -0
- perplexity/resources/content.py +163 -0
- perplexity/resources/search.py +4 -0
- perplexity/types/__init__.py +2 -0
- perplexity/types/content_create_params.py +13 -0
- perplexity/types/content_create_response.py +23 -0
- perplexity/types/search_create_params.py +2 -0
- {perplexityai-0.4.0.dist-info → perplexityai-0.6.0.dist-info}/METADATA +7 -7
- {perplexityai-0.4.0.dist-info → perplexityai-0.6.0.dist-info}/RECORD +13 -10
- {perplexityai-0.4.0.dist-info → perplexityai-0.6.0.dist-info}/WHEEL +0 -0
- {perplexityai-0.4.0.dist-info → perplexityai-0.6.0.dist-info}/licenses/LICENSE +0 -0
perplexity/_client.py
CHANGED
|
@@ -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
|
-
|
|
52
|
+
api_key: str
|
|
52
53
|
|
|
53
54
|
def __init__(
|
|
54
55
|
self,
|
|
55
56
|
*,
|
|
56
|
-
|
|
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 `
|
|
79
|
+
This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
|
|
79
80
|
"""
|
|
80
|
-
if
|
|
81
|
-
|
|
82
|
-
if
|
|
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
|
|
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.
|
|
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
|
-
|
|
117
|
-
return {"Authorization": f"Bearer {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
222
|
+
api_key: str
|
|
220
223
|
|
|
221
224
|
def __init__(
|
|
222
225
|
self,
|
|
223
226
|
*,
|
|
224
|
-
|
|
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 `
|
|
249
|
+
This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
|
|
247
250
|
"""
|
|
248
|
-
if
|
|
249
|
-
|
|
250
|
-
if
|
|
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
|
|
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.
|
|
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
|
-
|
|
285
|
-
return {"Authorization": f"Bearer {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
perplexity/_version.py
CHANGED
perplexity/resources/__init__.py
CHANGED
|
@@ -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
|
+
)
|
perplexity/resources/search.py
CHANGED
|
@@ -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,
|
perplexity/types/__init__.py
CHANGED
|
@@ -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]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: perplexityai
|
|
3
|
-
Version: 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
|
-
|
|
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
|
|
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
|
|
79
|
-
so that your
|
|
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
|
-
|
|
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
|
-
|
|
128
|
+
api_key="My API Key",
|
|
129
129
|
http_client=DefaultAioHttpClient(),
|
|
130
130
|
) as client:
|
|
131
131
|
search = await client.search.create(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
perplexity/__init__.py,sha256=5epbvK3UiJEgvsBW9Ds6RFB6zObkUxYkA9fIQlgUaXA,2655
|
|
2
2
|
perplexity/_base_client.py,sha256=DSeMteXutziRGJA9HqJaoLpG7ktzpU2GPcaIgQT1oZQ,67051
|
|
3
|
-
perplexity/_client.py,sha256=
|
|
3
|
+
perplexity/_client.py,sha256=dMkVFaHlpMtICqxeJOxwhIj1PKBgn7DPdoMmOKfvQ0s,15613
|
|
4
4
|
perplexity/_compat.py,sha256=DQBVORjFb33zch24jzkhM14msvnzY7mmSmgDLaVFUM8,6562
|
|
5
5
|
perplexity/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
|
6
6
|
perplexity/_exceptions.py,sha256=v-hOXWSDTEtXcn_By7pPml3HjEmG5HXpbE-RK_A6_0Q,3228
|
|
@@ -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=jJUPrkIRgFBl89WVXU3mGpPT6gT2nbhE_hrTKXiRDtk,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
|
|
@@ -26,12 +26,15 @@ perplexity/_utils/_transform.py,sha256=i_U4R82RtQJtKKCriwFqmfcWjtwmmsiiF1AEXKQ_O
|
|
|
26
26
|
perplexity/_utils/_typing.py,sha256=N_5PPuFNsaygbtA_npZd98SVN1LQQvFTKL6bkWPBZGU,4786
|
|
27
27
|
perplexity/_utils/_utils.py,sha256=D2QE7mVPNEJzaB50u8rvDQAUDS5jx7JoeFD7zdj-TeI,12231
|
|
28
28
|
perplexity/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
29
|
-
perplexity/resources/__init__.py,sha256=
|
|
30
|
-
perplexity/resources/
|
|
31
|
-
perplexity/
|
|
32
|
-
perplexity/types/
|
|
29
|
+
perplexity/resources/__init__.py,sha256=4gcgh_cZ4sqi0z898C_SeFbHx_RpXtkd3coApMVPiPs,1015
|
|
30
|
+
perplexity/resources/content.py,sha256=4BbRmRPY3qeYtP-b8toraEbRnBMAPYRZkyuri17SH-0,5905
|
|
31
|
+
perplexity/resources/search.py,sha256=3EqjYtS5EK457YAO0QXY5QutoqscbSqKKxkwM65sRqU,9270
|
|
32
|
+
perplexity/types/__init__.py,sha256=gD41Ien1RrCYCdig8ygalnShM5uT8k_l0-dx1u38I8I,441
|
|
33
|
+
perplexity/types/content_create_params.py,sha256=NHj29NXYWhvY9CpcE2RuqHQ-H2_dP7yRRa3fFUbB2AM,338
|
|
34
|
+
perplexity/types/content_create_response.py,sha256=Wr2TbU5lbEb5tHhw68erei5AGtX6hfQHmc-y8DcatLc,388
|
|
35
|
+
perplexity/types/search_create_params.py,sha256=RHKT4toTErSF4T5g0DYD9DTDFDOvjKF0BIa0t5Pv7bk,916
|
|
33
36
|
perplexity/types/search_create_response.py,sha256=lOteaJs4qpULkx5GLtEs6HhetqIBhM0I1AC1moWTeI8,426
|
|
34
|
-
perplexityai-0.
|
|
35
|
-
perplexityai-0.
|
|
36
|
-
perplexityai-0.
|
|
37
|
-
perplexityai-0.
|
|
37
|
+
perplexityai-0.6.0.dist-info/METADATA,sha256=_RTfMkrLjrfNgCxgD2YASfbevut51kA7ePgRI9E_17Q,13621
|
|
38
|
+
perplexityai-0.6.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
39
|
+
perplexityai-0.6.0.dist-info/licenses/LICENSE,sha256=hkCriG3MT4vBhhc0roAOsrCE7IEDr1ywVEMonVHGmAQ,11340
|
|
40
|
+
perplexityai-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|