perplexityai 0.5.0__py3-none-any.whl → 0.7.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.

Files changed (40) hide show
  1. perplexity/_client.py +27 -1
  2. perplexity/_version.py +1 -1
  3. perplexity/resources/__init__.py +42 -0
  4. perplexity/resources/async_/__init__.py +33 -0
  5. perplexity/resources/async_/async_.py +102 -0
  6. perplexity/resources/async_/chat/__init__.py +33 -0
  7. perplexity/resources/async_/chat/chat.py +102 -0
  8. perplexity/resources/async_/chat/completions.py +347 -0
  9. perplexity/resources/chat/__init__.py +33 -0
  10. perplexity/resources/chat/chat.py +102 -0
  11. perplexity/resources/chat/completions.py +295 -0
  12. perplexity/resources/content.py +167 -0
  13. perplexity/resources/search.py +64 -2
  14. perplexity/types/__init__.py +8 -0
  15. perplexity/types/async_/__init__.py +3 -0
  16. perplexity/types/async_/chat/__init__.py +9 -0
  17. perplexity/types/async_/chat/completion_create_params.py +94 -0
  18. perplexity/types/async_/chat/completion_create_response.py +54 -0
  19. perplexity/types/async_/chat/completion_get_response.py +54 -0
  20. perplexity/types/async_/chat/completion_list_params.py +15 -0
  21. perplexity/types/async_/chat/completion_list_response.py +31 -0
  22. perplexity/types/chat/__init__.py +6 -0
  23. perplexity/types/chat/completion_create_params.py +90 -0
  24. perplexity/types/chat/completion_create_response.py +30 -0
  25. perplexity/types/content_create_params.py +14 -0
  26. perplexity/types/content_create_response.py +29 -0
  27. perplexity/types/search_create_params.py +26 -0
  28. perplexity/types/search_create_response.py +7 -0
  29. perplexity/types/shared/__init__.py +6 -0
  30. perplexity/types/shared/chat_choice.py +17 -0
  31. perplexity/types/shared/chat_message.py +31 -0
  32. perplexity/types/shared/search_result.py +15 -0
  33. perplexity/types/shared/usage_info.py +23 -0
  34. perplexity/types/shared_params/__init__.py +3 -0
  35. perplexity/types/shared_params/chat_message.py +31 -0
  36. {perplexityai-0.5.0.dist-info → perplexityai-0.7.0.dist-info}/METADATA +90 -22
  37. perplexityai-0.7.0.dist-info/RECORD +65 -0
  38. perplexityai-0.5.0.dist-info/RECORD +0 -37
  39. {perplexityai-0.5.0.dist-info → perplexityai-0.7.0.dist-info}/WHEEL +0 -0
  40. {perplexityai-0.5.0.dist-info → perplexityai-0.7.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 (
@@ -29,6 +29,8 @@ from ._base_client import (
29
29
  SyncAPIClient,
30
30
  AsyncAPIClient,
31
31
  )
32
+ from .resources.chat import chat
33
+ from .resources.async_ import async_
32
34
 
33
35
  __all__ = [
34
36
  "Timeout",
@@ -43,7 +45,10 @@ __all__ = [
43
45
 
44
46
 
45
47
  class Perplexity(SyncAPIClient):
48
+ chat: chat.ChatResource
49
+ async_: async_.AsyncResource
46
50
  search: search.SearchResource
51
+ content: content.ContentResource
47
52
  with_raw_response: PerplexityWithRawResponse
48
53
  with_streaming_response: PerplexityWithStreamedResponse
49
54
 
@@ -101,7 +106,10 @@ class Perplexity(SyncAPIClient):
101
106
  _strict_response_validation=_strict_response_validation,
102
107
  )
103
108
 
109
+ self.chat = chat.ChatResource(self)
110
+ self.async_ = async_.AsyncResource(self)
104
111
  self.search = search.SearchResource(self)
112
+ self.content = content.ContentResource(self)
105
113
  self.with_raw_response = PerplexityWithRawResponse(self)
106
114
  self.with_streaming_response = PerplexityWithStreamedResponse(self)
107
115
 
@@ -211,7 +219,10 @@ class Perplexity(SyncAPIClient):
211
219
 
212
220
 
213
221
  class AsyncPerplexity(AsyncAPIClient):
222
+ chat: chat.AsyncChatResource
223
+ async_: async_.AsyncAsyncResource
214
224
  search: search.AsyncSearchResource
225
+ content: content.AsyncContentResource
215
226
  with_raw_response: AsyncPerplexityWithRawResponse
216
227
  with_streaming_response: AsyncPerplexityWithStreamedResponse
217
228
 
@@ -269,7 +280,10 @@ class AsyncPerplexity(AsyncAPIClient):
269
280
  _strict_response_validation=_strict_response_validation,
270
281
  )
271
282
 
283
+ self.chat = chat.AsyncChatResource(self)
284
+ self.async_ = async_.AsyncAsyncResource(self)
272
285
  self.search = search.AsyncSearchResource(self)
286
+ self.content = content.AsyncContentResource(self)
273
287
  self.with_raw_response = AsyncPerplexityWithRawResponse(self)
274
288
  self.with_streaming_response = AsyncPerplexityWithStreamedResponse(self)
275
289
 
@@ -380,22 +394,34 @@ class AsyncPerplexity(AsyncAPIClient):
380
394
 
381
395
  class PerplexityWithRawResponse:
382
396
  def __init__(self, client: Perplexity) -> None:
397
+ self.chat = chat.ChatResourceWithRawResponse(client.chat)
398
+ self.async_ = async_.AsyncResourceWithRawResponse(client.async_)
383
399
  self.search = search.SearchResourceWithRawResponse(client.search)
400
+ self.content = content.ContentResourceWithRawResponse(client.content)
384
401
 
385
402
 
386
403
  class AsyncPerplexityWithRawResponse:
387
404
  def __init__(self, client: AsyncPerplexity) -> None:
405
+ self.chat = chat.AsyncChatResourceWithRawResponse(client.chat)
406
+ self.async_ = async_.AsyncAsyncResourceWithRawResponse(client.async_)
388
407
  self.search = search.AsyncSearchResourceWithRawResponse(client.search)
408
+ self.content = content.AsyncContentResourceWithRawResponse(client.content)
389
409
 
390
410
 
391
411
  class PerplexityWithStreamedResponse:
392
412
  def __init__(self, client: Perplexity) -> None:
413
+ self.chat = chat.ChatResourceWithStreamingResponse(client.chat)
414
+ self.async_ = async_.AsyncResourceWithStreamingResponse(client.async_)
393
415
  self.search = search.SearchResourceWithStreamingResponse(client.search)
416
+ self.content = content.ContentResourceWithStreamingResponse(client.content)
394
417
 
395
418
 
396
419
  class AsyncPerplexityWithStreamedResponse:
397
420
  def __init__(self, client: AsyncPerplexity) -> None:
421
+ self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat)
422
+ self.async_ = async_.AsyncAsyncResourceWithStreamingResponse(client.async_)
398
423
  self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
424
+ self.content = content.AsyncContentResourceWithStreamingResponse(client.content)
399
425
 
400
426
 
401
427
  Client = Perplexity
perplexity/_version.py CHANGED
@@ -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.5.0" # x-release-please-version
4
+ __version__ = "0.7.0" # x-release-please-version
@@ -1,5 +1,21 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ from .chat import (
4
+ ChatResource,
5
+ AsyncChatResource,
6
+ ChatResourceWithRawResponse,
7
+ AsyncChatResourceWithRawResponse,
8
+ ChatResourceWithStreamingResponse,
9
+ AsyncChatResourceWithStreamingResponse,
10
+ )
11
+ from .async_ import (
12
+ AsyncResource,
13
+ AsyncAsyncResource,
14
+ AsyncResourceWithRawResponse,
15
+ AsyncAsyncResourceWithRawResponse,
16
+ AsyncResourceWithStreamingResponse,
17
+ AsyncAsyncResourceWithStreamingResponse,
18
+ )
3
19
  from .search import (
4
20
  SearchResource,
5
21
  AsyncSearchResource,
@@ -8,12 +24,38 @@ from .search import (
8
24
  SearchResourceWithStreamingResponse,
9
25
  AsyncSearchResourceWithStreamingResponse,
10
26
  )
27
+ from .content import (
28
+ ContentResource,
29
+ AsyncContentResource,
30
+ ContentResourceWithRawResponse,
31
+ AsyncContentResourceWithRawResponse,
32
+ ContentResourceWithStreamingResponse,
33
+ AsyncContentResourceWithStreamingResponse,
34
+ )
11
35
 
12
36
  __all__ = [
37
+ "ChatResource",
38
+ "AsyncChatResource",
39
+ "ChatResourceWithRawResponse",
40
+ "AsyncChatResourceWithRawResponse",
41
+ "ChatResourceWithStreamingResponse",
42
+ "AsyncChatResourceWithStreamingResponse",
43
+ "AsyncResource",
44
+ "AsyncAsyncResource",
45
+ "AsyncResourceWithRawResponse",
46
+ "AsyncAsyncResourceWithRawResponse",
47
+ "AsyncResourceWithStreamingResponse",
48
+ "AsyncAsyncResourceWithStreamingResponse",
13
49
  "SearchResource",
14
50
  "AsyncSearchResource",
15
51
  "SearchResourceWithRawResponse",
16
52
  "AsyncSearchResourceWithRawResponse",
17
53
  "SearchResourceWithStreamingResponse",
18
54
  "AsyncSearchResourceWithStreamingResponse",
55
+ "ContentResource",
56
+ "AsyncContentResource",
57
+ "ContentResourceWithRawResponse",
58
+ "AsyncContentResourceWithRawResponse",
59
+ "ContentResourceWithStreamingResponse",
60
+ "AsyncContentResourceWithStreamingResponse",
19
61
  ]
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .chat import (
4
+ ChatResource,
5
+ AsyncChatResource,
6
+ ChatResourceWithRawResponse,
7
+ AsyncChatResourceWithRawResponse,
8
+ ChatResourceWithStreamingResponse,
9
+ AsyncChatResourceWithStreamingResponse,
10
+ )
11
+ from .async_ import (
12
+ AsyncResource,
13
+ AsyncAsyncResource,
14
+ AsyncResourceWithRawResponse,
15
+ AsyncAsyncResourceWithRawResponse,
16
+ AsyncResourceWithStreamingResponse,
17
+ AsyncAsyncResourceWithStreamingResponse,
18
+ )
19
+
20
+ __all__ = [
21
+ "ChatResource",
22
+ "AsyncChatResource",
23
+ "ChatResourceWithRawResponse",
24
+ "AsyncChatResourceWithRawResponse",
25
+ "ChatResourceWithStreamingResponse",
26
+ "AsyncChatResourceWithStreamingResponse",
27
+ "AsyncResource",
28
+ "AsyncAsyncResource",
29
+ "AsyncResourceWithRawResponse",
30
+ "AsyncAsyncResourceWithRawResponse",
31
+ "AsyncResourceWithStreamingResponse",
32
+ "AsyncAsyncResourceWithStreamingResponse",
33
+ ]
@@ -0,0 +1,102 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from ..._compat import cached_property
6
+ from .chat.chat import (
7
+ ChatResource,
8
+ AsyncChatResource,
9
+ ChatResourceWithRawResponse,
10
+ AsyncChatResourceWithRawResponse,
11
+ ChatResourceWithStreamingResponse,
12
+ AsyncChatResourceWithStreamingResponse,
13
+ )
14
+ from ..._resource import SyncAPIResource, AsyncAPIResource
15
+
16
+ __all__ = ["AsyncResource", "AsyncAsyncResource"]
17
+
18
+
19
+ class AsyncResource(SyncAPIResource):
20
+ @cached_property
21
+ def chat(self) -> ChatResource:
22
+ return ChatResource(self._client)
23
+
24
+ @cached_property
25
+ def with_raw_response(self) -> AsyncResourceWithRawResponse:
26
+ """
27
+ This property can be used as a prefix for any HTTP method call to return
28
+ the raw response object instead of the parsed content.
29
+
30
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
31
+ """
32
+ return AsyncResourceWithRawResponse(self)
33
+
34
+ @cached_property
35
+ def with_streaming_response(self) -> AsyncResourceWithStreamingResponse:
36
+ """
37
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38
+
39
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
40
+ """
41
+ return AsyncResourceWithStreamingResponse(self)
42
+
43
+
44
+ class AsyncAsyncResource(AsyncAPIResource):
45
+ @cached_property
46
+ def chat(self) -> AsyncChatResource:
47
+ return AsyncChatResource(self._client)
48
+
49
+ @cached_property
50
+ def with_raw_response(self) -> AsyncAsyncResourceWithRawResponse:
51
+ """
52
+ This property can be used as a prefix for any HTTP method call to return
53
+ the raw response object instead of the parsed content.
54
+
55
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
56
+ """
57
+ return AsyncAsyncResourceWithRawResponse(self)
58
+
59
+ @cached_property
60
+ def with_streaming_response(self) -> AsyncAsyncResourceWithStreamingResponse:
61
+ """
62
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
63
+
64
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
65
+ """
66
+ return AsyncAsyncResourceWithStreamingResponse(self)
67
+
68
+
69
+ class AsyncResourceWithRawResponse:
70
+ def __init__(self, async_: AsyncResource) -> None:
71
+ self._async_ = async_
72
+
73
+ @cached_property
74
+ def chat(self) -> ChatResourceWithRawResponse:
75
+ return ChatResourceWithRawResponse(self._async_.chat)
76
+
77
+
78
+ class AsyncAsyncResourceWithRawResponse:
79
+ def __init__(self, async_: AsyncAsyncResource) -> None:
80
+ self._async_ = async_
81
+
82
+ @cached_property
83
+ def chat(self) -> AsyncChatResourceWithRawResponse:
84
+ return AsyncChatResourceWithRawResponse(self._async_.chat)
85
+
86
+
87
+ class AsyncResourceWithStreamingResponse:
88
+ def __init__(self, async_: AsyncResource) -> None:
89
+ self._async_ = async_
90
+
91
+ @cached_property
92
+ def chat(self) -> ChatResourceWithStreamingResponse:
93
+ return ChatResourceWithStreamingResponse(self._async_.chat)
94
+
95
+
96
+ class AsyncAsyncResourceWithStreamingResponse:
97
+ def __init__(self, async_: AsyncAsyncResource) -> None:
98
+ self._async_ = async_
99
+
100
+ @cached_property
101
+ def chat(self) -> AsyncChatResourceWithStreamingResponse:
102
+ return AsyncChatResourceWithStreamingResponse(self._async_.chat)
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .chat import (
4
+ ChatResource,
5
+ AsyncChatResource,
6
+ ChatResourceWithRawResponse,
7
+ AsyncChatResourceWithRawResponse,
8
+ ChatResourceWithStreamingResponse,
9
+ AsyncChatResourceWithStreamingResponse,
10
+ )
11
+ from .completions import (
12
+ CompletionsResource,
13
+ AsyncCompletionsResource,
14
+ CompletionsResourceWithRawResponse,
15
+ AsyncCompletionsResourceWithRawResponse,
16
+ CompletionsResourceWithStreamingResponse,
17
+ AsyncCompletionsResourceWithStreamingResponse,
18
+ )
19
+
20
+ __all__ = [
21
+ "CompletionsResource",
22
+ "AsyncCompletionsResource",
23
+ "CompletionsResourceWithRawResponse",
24
+ "AsyncCompletionsResourceWithRawResponse",
25
+ "CompletionsResourceWithStreamingResponse",
26
+ "AsyncCompletionsResourceWithStreamingResponse",
27
+ "ChatResource",
28
+ "AsyncChatResource",
29
+ "ChatResourceWithRawResponse",
30
+ "AsyncChatResourceWithRawResponse",
31
+ "ChatResourceWithStreamingResponse",
32
+ "AsyncChatResourceWithStreamingResponse",
33
+ ]
@@ -0,0 +1,102 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from ...._compat import cached_property
6
+ from .completions import (
7
+ CompletionsResource,
8
+ AsyncCompletionsResource,
9
+ CompletionsResourceWithRawResponse,
10
+ AsyncCompletionsResourceWithRawResponse,
11
+ CompletionsResourceWithStreamingResponse,
12
+ AsyncCompletionsResourceWithStreamingResponse,
13
+ )
14
+ from ...._resource import SyncAPIResource, AsyncAPIResource
15
+
16
+ __all__ = ["ChatResource", "AsyncChatResource"]
17
+
18
+
19
+ class ChatResource(SyncAPIResource):
20
+ @cached_property
21
+ def completions(self) -> CompletionsResource:
22
+ return CompletionsResource(self._client)
23
+
24
+ @cached_property
25
+ def with_raw_response(self) -> ChatResourceWithRawResponse:
26
+ """
27
+ This property can be used as a prefix for any HTTP method call to return
28
+ the raw response object instead of the parsed content.
29
+
30
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
31
+ """
32
+ return ChatResourceWithRawResponse(self)
33
+
34
+ @cached_property
35
+ def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
36
+ """
37
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38
+
39
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
40
+ """
41
+ return ChatResourceWithStreamingResponse(self)
42
+
43
+
44
+ class AsyncChatResource(AsyncAPIResource):
45
+ @cached_property
46
+ def completions(self) -> AsyncCompletionsResource:
47
+ return AsyncCompletionsResource(self._client)
48
+
49
+ @cached_property
50
+ def with_raw_response(self) -> AsyncChatResourceWithRawResponse:
51
+ """
52
+ This property can be used as a prefix for any HTTP method call to return
53
+ the raw response object instead of the parsed content.
54
+
55
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
56
+ """
57
+ return AsyncChatResourceWithRawResponse(self)
58
+
59
+ @cached_property
60
+ def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
61
+ """
62
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
63
+
64
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
65
+ """
66
+ return AsyncChatResourceWithStreamingResponse(self)
67
+
68
+
69
+ class ChatResourceWithRawResponse:
70
+ def __init__(self, chat: ChatResource) -> None:
71
+ self._chat = chat
72
+
73
+ @cached_property
74
+ def completions(self) -> CompletionsResourceWithRawResponse:
75
+ return CompletionsResourceWithRawResponse(self._chat.completions)
76
+
77
+
78
+ class AsyncChatResourceWithRawResponse:
79
+ def __init__(self, chat: AsyncChatResource) -> None:
80
+ self._chat = chat
81
+
82
+ @cached_property
83
+ def completions(self) -> AsyncCompletionsResourceWithRawResponse:
84
+ return AsyncCompletionsResourceWithRawResponse(self._chat.completions)
85
+
86
+
87
+ class ChatResourceWithStreamingResponse:
88
+ def __init__(self, chat: ChatResource) -> None:
89
+ self._chat = chat
90
+
91
+ @cached_property
92
+ def completions(self) -> CompletionsResourceWithStreamingResponse:
93
+ return CompletionsResourceWithStreamingResponse(self._chat.completions)
94
+
95
+
96
+ class AsyncChatResourceWithStreamingResponse:
97
+ def __init__(self, chat: AsyncChatResource) -> None:
98
+ self._chat = chat
99
+
100
+ @cached_property
101
+ def completions(self) -> AsyncCompletionsResourceWithStreamingResponse:
102
+ return AsyncCompletionsResourceWithStreamingResponse(self._chat.completions)