perplexityai 0.22.3__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.
Files changed (64) hide show
  1. perplexity/__init__.py +102 -0
  2. perplexity/_base_client.py +2001 -0
  3. perplexity/_client.py +529 -0
  4. perplexity/_compat.py +219 -0
  5. perplexity/_constants.py +14 -0
  6. perplexity/_exceptions.py +108 -0
  7. perplexity/_files.py +123 -0
  8. perplexity/_models.py +857 -0
  9. perplexity/_qs.py +150 -0
  10. perplexity/_resource.py +43 -0
  11. perplexity/_response.py +832 -0
  12. perplexity/_streaming.py +371 -0
  13. perplexity/_types.py +261 -0
  14. perplexity/_utils/__init__.py +64 -0
  15. perplexity/_utils/_compat.py +45 -0
  16. perplexity/_utils/_datetime_parse.py +136 -0
  17. perplexity/_utils/_logs.py +25 -0
  18. perplexity/_utils/_proxy.py +65 -0
  19. perplexity/_utils/_reflection.py +42 -0
  20. perplexity/_utils/_resources_proxy.py +24 -0
  21. perplexity/_utils/_streams.py +12 -0
  22. perplexity/_utils/_sync.py +58 -0
  23. perplexity/_utils/_transform.py +457 -0
  24. perplexity/_utils/_typing.py +156 -0
  25. perplexity/_utils/_utils.py +421 -0
  26. perplexity/_version.py +4 -0
  27. perplexity/lib/.keep +4 -0
  28. perplexity/py.typed +0 -0
  29. perplexity/resources/__init__.py +47 -0
  30. perplexity/resources/async_/__init__.py +33 -0
  31. perplexity/resources/async_/async_.py +102 -0
  32. perplexity/resources/async_/chat/__init__.py +33 -0
  33. perplexity/resources/async_/chat/chat.py +102 -0
  34. perplexity/resources/async_/chat/completions.py +359 -0
  35. perplexity/resources/chat/__init__.py +33 -0
  36. perplexity/resources/chat/chat.py +102 -0
  37. perplexity/resources/chat/completions.py +900 -0
  38. perplexity/resources/search.py +228 -0
  39. perplexity/types/__init__.py +14 -0
  40. perplexity/types/async_/__init__.py +3 -0
  41. perplexity/types/async_/chat/__init__.py +9 -0
  42. perplexity/types/async_/chat/completion_create_params.py +242 -0
  43. perplexity/types/async_/chat/completion_create_response.py +30 -0
  44. perplexity/types/async_/chat/completion_get_params.py +25 -0
  45. perplexity/types/async_/chat/completion_get_response.py +30 -0
  46. perplexity/types/async_/chat/completion_list_response.py +31 -0
  47. perplexity/types/chat/__init__.py +5 -0
  48. perplexity/types/chat/completion_create_params.py +244 -0
  49. perplexity/types/search_create_params.py +40 -0
  50. perplexity/types/search_create_response.py +27 -0
  51. perplexity/types/shared/__init__.py +7 -0
  52. perplexity/types/shared/api_public_search_result.py +22 -0
  53. perplexity/types/shared/chat_message_input.py +176 -0
  54. perplexity/types/shared/chat_message_output.py +176 -0
  55. perplexity/types/shared/choice.py +19 -0
  56. perplexity/types/shared/usage_info.py +41 -0
  57. perplexity/types/shared_params/__init__.py +4 -0
  58. perplexity/types/shared_params/api_public_search_result.py +22 -0
  59. perplexity/types/shared_params/chat_message_input.py +178 -0
  60. perplexity/types/stream_chunk.py +33 -0
  61. perplexityai-0.22.3.dist-info/METADATA +548 -0
  62. perplexityai-0.22.3.dist-info/RECORD +64 -0
  63. perplexityai-0.22.3.dist-info/WHEEL +4 -0
  64. perplexityai-0.22.3.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,19 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ..._models import BaseModel
7
+ from .chat_message_output import ChatMessageOutput
8
+
9
+ __all__ = ["Choice"]
10
+
11
+
12
+ class Choice(BaseModel):
13
+ delta: ChatMessageOutput
14
+
15
+ index: int
16
+
17
+ message: ChatMessageOutput
18
+
19
+ finish_reason: Optional[Literal["stop", "length"]] = None
@@ -0,0 +1,41 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+
5
+ from ..._models import BaseModel
6
+
7
+ __all__ = ["UsageInfo", "Cost"]
8
+
9
+
10
+ class Cost(BaseModel):
11
+ input_tokens_cost: float
12
+
13
+ output_tokens_cost: float
14
+
15
+ total_cost: float
16
+
17
+ citation_tokens_cost: Optional[float] = None
18
+
19
+ reasoning_tokens_cost: Optional[float] = None
20
+
21
+ request_cost: Optional[float] = None
22
+
23
+ search_queries_cost: Optional[float] = None
24
+
25
+
26
+ class UsageInfo(BaseModel):
27
+ completion_tokens: int
28
+
29
+ cost: Cost
30
+
31
+ prompt_tokens: int
32
+
33
+ total_tokens: int
34
+
35
+ citation_tokens: Optional[int] = None
36
+
37
+ num_search_queries: Optional[int] = None
38
+
39
+ reasoning_tokens: Optional[int] = None
40
+
41
+ search_context_size: Optional[str] = None
@@ -0,0 +1,4 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .chat_message_input import ChatMessageInput as ChatMessageInput
4
+ from .api_public_search_result import APIPublicSearchResult as APIPublicSearchResult
@@ -0,0 +1,22 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+ from typing_extensions import Literal, Required, TypedDict
7
+
8
+ __all__ = ["APIPublicSearchResult"]
9
+
10
+
11
+ class APIPublicSearchResult(TypedDict, total=False):
12
+ title: Required[str]
13
+
14
+ url: Required[str]
15
+
16
+ date: Optional[str]
17
+
18
+ last_updated: Optional[str]
19
+
20
+ snippet: str
21
+
22
+ source: Literal["web", "attachment"]
@@ -0,0 +1,178 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Union, Iterable, Optional
6
+ from typing_extensions import Literal, Required, TypeAlias, TypedDict
7
+
8
+ from ..._types import SequenceNotStr
9
+ from .api_public_search_result import APIPublicSearchResult
10
+
11
+ __all__ = [
12
+ "ChatMessageInput",
13
+ "ContentStructuredContent",
14
+ "ContentStructuredContentChatMessageContentTextChunk",
15
+ "ContentStructuredContentChatMessageContentImageChunk",
16
+ "ContentStructuredContentChatMessageContentImageChunkImageURL",
17
+ "ContentStructuredContentChatMessageContentImageChunkImageURLURL",
18
+ "ContentStructuredContentChatMessageContentFileChunk",
19
+ "ContentStructuredContentChatMessageContentFileChunkFileURL",
20
+ "ContentStructuredContentChatMessageContentFileChunkFileURLURL",
21
+ "ContentStructuredContentChatMessageContentPdfChunk",
22
+ "ContentStructuredContentChatMessageContentPdfChunkPdfURL",
23
+ "ContentStructuredContentChatMessageContentPdfChunkPdfURLURL",
24
+ "ContentStructuredContentChatMessageContentVideoChunk",
25
+ "ContentStructuredContentChatMessageContentVideoChunkVideoURL",
26
+ "ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL",
27
+ "ReasoningStep",
28
+ "ReasoningStepExecutePython",
29
+ "ReasoningStepFetchURLContent",
30
+ "ReasoningStepWebSearch",
31
+ "ToolCall",
32
+ "ToolCallFunction",
33
+ ]
34
+
35
+
36
+ class ContentStructuredContentChatMessageContentTextChunk(TypedDict, total=False):
37
+ text: Required[str]
38
+
39
+ type: Required[Literal["text"]]
40
+
41
+
42
+ class ContentStructuredContentChatMessageContentImageChunkImageURLURL(TypedDict, total=False):
43
+ url: Required[str]
44
+
45
+
46
+ ContentStructuredContentChatMessageContentImageChunkImageURL: TypeAlias = Union[
47
+ ContentStructuredContentChatMessageContentImageChunkImageURLURL, str
48
+ ]
49
+
50
+
51
+ class ContentStructuredContentChatMessageContentImageChunk(TypedDict, total=False):
52
+ image_url: Required[ContentStructuredContentChatMessageContentImageChunkImageURL]
53
+
54
+ type: Required[Literal["image_url"]]
55
+
56
+
57
+ class ContentStructuredContentChatMessageContentFileChunkFileURLURL(TypedDict, total=False):
58
+ url: Required[str]
59
+
60
+
61
+ ContentStructuredContentChatMessageContentFileChunkFileURL: TypeAlias = Union[
62
+ ContentStructuredContentChatMessageContentFileChunkFileURLURL, str
63
+ ]
64
+
65
+
66
+ class ContentStructuredContentChatMessageContentFileChunk(TypedDict, total=False):
67
+ file_url: Required[ContentStructuredContentChatMessageContentFileChunkFileURL]
68
+
69
+ type: Required[Literal["file_url"]]
70
+
71
+ file_name: Optional[str]
72
+
73
+
74
+ class ContentStructuredContentChatMessageContentPdfChunkPdfURLURL(TypedDict, total=False):
75
+ url: Required[str]
76
+
77
+
78
+ ContentStructuredContentChatMessageContentPdfChunkPdfURL: TypeAlias = Union[
79
+ ContentStructuredContentChatMessageContentPdfChunkPdfURLURL, str
80
+ ]
81
+
82
+
83
+ class ContentStructuredContentChatMessageContentPdfChunk(TypedDict, total=False):
84
+ pdf_url: Required[ContentStructuredContentChatMessageContentPdfChunkPdfURL]
85
+
86
+ type: Required[Literal["pdf_url"]]
87
+
88
+
89
+ class ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL(TypedDict, total=False):
90
+ url: Required[str]
91
+
92
+ frame_interval: Union[str, int]
93
+
94
+
95
+ ContentStructuredContentChatMessageContentVideoChunkVideoURL: TypeAlias = Union[
96
+ ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL, str
97
+ ]
98
+
99
+
100
+ class ContentStructuredContentChatMessageContentVideoChunk(TypedDict, total=False):
101
+ type: Required[Literal["video_url"]]
102
+
103
+ video_url: Required[ContentStructuredContentChatMessageContentVideoChunkVideoURL]
104
+
105
+
106
+ ContentStructuredContent: TypeAlias = Union[
107
+ ContentStructuredContentChatMessageContentTextChunk,
108
+ ContentStructuredContentChatMessageContentImageChunk,
109
+ ContentStructuredContentChatMessageContentFileChunk,
110
+ ContentStructuredContentChatMessageContentPdfChunk,
111
+ ContentStructuredContentChatMessageContentVideoChunk,
112
+ ]
113
+
114
+
115
+ class ReasoningStepExecutePython(TypedDict, total=False):
116
+ """Code generation step details wrapper class"""
117
+
118
+ code: Required[str]
119
+
120
+ result: Required[str]
121
+
122
+
123
+ class ReasoningStepFetchURLContent(TypedDict, total=False):
124
+ """Fetch url content step details wrapper class"""
125
+
126
+ contents: Required[Iterable[APIPublicSearchResult]]
127
+
128
+
129
+ class ReasoningStepWebSearch(TypedDict, total=False):
130
+ """Web search step details wrapper class"""
131
+
132
+ search_keywords: Required[SequenceNotStr[str]]
133
+
134
+ search_results: Required[Iterable[APIPublicSearchResult]]
135
+
136
+
137
+ class ReasoningStep(TypedDict, total=False):
138
+ """Reasoning step wrapper class"""
139
+
140
+ thought: Required[str]
141
+
142
+ execute_python: Optional[ReasoningStepExecutePython]
143
+ """Code generation step details wrapper class"""
144
+
145
+ fetch_url_content: Optional[ReasoningStepFetchURLContent]
146
+ """Fetch url content step details wrapper class"""
147
+
148
+ type: Optional[str]
149
+
150
+ web_search: Optional[ReasoningStepWebSearch]
151
+ """Web search step details wrapper class"""
152
+
153
+
154
+ class ToolCallFunction(TypedDict, total=False):
155
+ arguments: Optional[str]
156
+
157
+ name: Optional[str]
158
+
159
+
160
+ class ToolCall(TypedDict, total=False):
161
+ id: Optional[str]
162
+
163
+ function: Optional[ToolCallFunction]
164
+
165
+ type: Optional[Literal["function"]]
166
+
167
+
168
+ class ChatMessageInput(TypedDict, total=False):
169
+ content: Required[Union[str, Iterable[ContentStructuredContent], None]]
170
+
171
+ role: Required[Literal["system", "user", "assistant", "tool"]]
172
+ """Chat roles enum"""
173
+
174
+ reasoning_steps: Optional[Iterable[ReasoningStep]]
175
+
176
+ tool_call_id: Optional[str]
177
+
178
+ tool_calls: Optional[Iterable[ToolCall]]
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import List, Optional
4
+ from typing_extensions import Literal
5
+
6
+ from .._models import BaseModel
7
+ from .shared.choice import Choice
8
+ from .shared.usage_info import UsageInfo
9
+ from .shared.api_public_search_result import APIPublicSearchResult
10
+
11
+ __all__ = ["StreamChunk"]
12
+
13
+
14
+ class StreamChunk(BaseModel):
15
+ id: str
16
+
17
+ choices: List[Choice]
18
+
19
+ created: int
20
+
21
+ model: str
22
+
23
+ citations: Optional[List[str]] = None
24
+
25
+ object: Optional[str] = None
26
+
27
+ search_results: Optional[List[APIPublicSearchResult]] = None
28
+
29
+ status: Optional[Literal["PENDING", "COMPLETED"]] = None
30
+
31
+ type: Optional[Literal["message", "info", "end_of_stream"]] = None
32
+
33
+ usage: Optional[UsageInfo] = None