perplexityai 0.7.1__py3-none-any.whl → 0.8.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/async_/chat/completions.py +90 -76
- perplexity/resources/chat/completions.py +178 -80
- perplexity/resources/content.py +2 -6
- perplexity/resources/search.py +2 -60
- perplexity/types/__init__.py +4 -3
- perplexity/types/async_/chat/__init__.py +1 -1
- perplexity/types/async_/chat/completion_create_params.py +187 -40
- perplexity/types/async_/chat/completion_create_response.py +13 -13
- perplexity/types/async_/chat/completion_get_params.py +23 -0
- perplexity/types/async_/chat/completion_get_response.py +13 -13
- perplexity/types/async_/chat/completion_list_response.py +1 -1
- perplexity/types/chat/completion_create_params.py +182 -40
- perplexity/types/chat/completion_create_response.py +13 -10
- perplexity/types/content_create_params.py +0 -1
- perplexity/types/content_create_response.py +0 -6
- perplexity/types/search_create_params.py +0 -24
- perplexity/types/search_create_response.py +0 -7
- perplexity/types/shared/__init__.py +4 -3
- perplexity/types/shared/{search_result.py → api_public_search_result.py} +6 -2
- perplexity/types/shared/chat_message_input.py +212 -0
- perplexity/types/shared/chat_message_output.py +212 -0
- perplexity/types/shared/{chat_choice.py → choice.py} +6 -4
- perplexity/types/shared/usage_info.py +19 -1
- perplexity/types/shared_params/__init__.py +2 -1
- perplexity/types/shared_params/api_public_search_result.py +20 -0
- perplexity/types/shared_params/chat_message_input.py +216 -0
- {perplexityai-0.7.1.dist-info → perplexityai-0.8.0.dist-info}/METADATA +44 -5
- {perplexityai-0.7.1.dist-info → perplexityai-0.8.0.dist-info}/RECORD +31 -29
- perplexity/types/async_/chat/completion_list_params.py +0 -15
- perplexity/types/shared/chat_message.py +0 -31
- perplexity/types/shared_params/chat_message.py +0 -31
- {perplexityai-0.7.1.dist-info → perplexityai-0.8.0.dist-info}/WHEEL +0 -0
- {perplexityai-0.7.1.dist-info → perplexityai-0.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Union, Optional
|
|
4
|
+
from typing_extensions import Literal, TypeAlias
|
|
5
|
+
|
|
6
|
+
from ..._models import BaseModel
|
|
7
|
+
from .api_public_search_result import APIPublicSearchResult
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"ChatMessageOutput",
|
|
11
|
+
"ContentStructuredContent",
|
|
12
|
+
"ContentStructuredContentChatMessageContentTextChunk",
|
|
13
|
+
"ContentStructuredContentChatMessageContentImageChunk",
|
|
14
|
+
"ContentStructuredContentChatMessageContentImageChunkImageURL",
|
|
15
|
+
"ContentStructuredContentChatMessageContentImageChunkImageURLURL",
|
|
16
|
+
"ContentStructuredContentChatMessageContentFileChunk",
|
|
17
|
+
"ContentStructuredContentChatMessageContentFileChunkFileURL",
|
|
18
|
+
"ContentStructuredContentChatMessageContentFileChunkFileURLURL",
|
|
19
|
+
"ContentStructuredContentChatMessageContentPdfChunk",
|
|
20
|
+
"ContentStructuredContentChatMessageContentPdfChunkPdfURL",
|
|
21
|
+
"ContentStructuredContentChatMessageContentPdfChunkPdfURLURL",
|
|
22
|
+
"ContentStructuredContentChatMessageContentVideoChunk",
|
|
23
|
+
"ContentStructuredContentChatMessageContentVideoChunkVideoURL",
|
|
24
|
+
"ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL",
|
|
25
|
+
"ReasoningStep",
|
|
26
|
+
"ReasoningStepAgentProgress",
|
|
27
|
+
"ReasoningStepBrowserAgent",
|
|
28
|
+
"ReasoningStepBrowserToolExecution",
|
|
29
|
+
"ReasoningStepExecutePython",
|
|
30
|
+
"ReasoningStepFetchURLContent",
|
|
31
|
+
"ReasoningStepFileAttachmentSearch",
|
|
32
|
+
"ReasoningStepWebSearch",
|
|
33
|
+
"ToolCall",
|
|
34
|
+
"ToolCallFunction",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ContentStructuredContentChatMessageContentTextChunk(BaseModel):
|
|
39
|
+
text: str
|
|
40
|
+
|
|
41
|
+
type: Literal["text"]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ContentStructuredContentChatMessageContentImageChunkImageURLURL(BaseModel):
|
|
45
|
+
url: str
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
ContentStructuredContentChatMessageContentImageChunkImageURL: TypeAlias = Union[
|
|
49
|
+
ContentStructuredContentChatMessageContentImageChunkImageURLURL, str
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ContentStructuredContentChatMessageContentImageChunk(BaseModel):
|
|
54
|
+
image_url: ContentStructuredContentChatMessageContentImageChunkImageURL
|
|
55
|
+
|
|
56
|
+
type: Literal["image_url"]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ContentStructuredContentChatMessageContentFileChunkFileURLURL(BaseModel):
|
|
60
|
+
url: str
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
ContentStructuredContentChatMessageContentFileChunkFileURL: TypeAlias = Union[
|
|
64
|
+
ContentStructuredContentChatMessageContentFileChunkFileURLURL, str
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ContentStructuredContentChatMessageContentFileChunk(BaseModel):
|
|
69
|
+
file_url: ContentStructuredContentChatMessageContentFileChunkFileURL
|
|
70
|
+
|
|
71
|
+
type: Literal["file_url"]
|
|
72
|
+
|
|
73
|
+
file_name: Optional[str] = None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ContentStructuredContentChatMessageContentPdfChunkPdfURLURL(BaseModel):
|
|
77
|
+
url: str
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
ContentStructuredContentChatMessageContentPdfChunkPdfURL: TypeAlias = Union[
|
|
81
|
+
ContentStructuredContentChatMessageContentPdfChunkPdfURLURL, str
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ContentStructuredContentChatMessageContentPdfChunk(BaseModel):
|
|
86
|
+
pdf_url: ContentStructuredContentChatMessageContentPdfChunkPdfURL
|
|
87
|
+
|
|
88
|
+
type: Literal["pdf_url"]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL(BaseModel):
|
|
92
|
+
url: str
|
|
93
|
+
|
|
94
|
+
frame_interval: Union[str, int, None] = None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
ContentStructuredContentChatMessageContentVideoChunkVideoURL: TypeAlias = Union[
|
|
98
|
+
ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL, str
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ContentStructuredContentChatMessageContentVideoChunk(BaseModel):
|
|
103
|
+
type: Literal["video_url"]
|
|
104
|
+
|
|
105
|
+
video_url: ContentStructuredContentChatMessageContentVideoChunkVideoURL
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
ContentStructuredContent: TypeAlias = Union[
|
|
109
|
+
ContentStructuredContentChatMessageContentTextChunk,
|
|
110
|
+
ContentStructuredContentChatMessageContentImageChunk,
|
|
111
|
+
ContentStructuredContentChatMessageContentFileChunk,
|
|
112
|
+
ContentStructuredContentChatMessageContentPdfChunk,
|
|
113
|
+
ContentStructuredContentChatMessageContentVideoChunk,
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class ReasoningStepAgentProgress(BaseModel):
|
|
118
|
+
action: Optional[str] = None
|
|
119
|
+
|
|
120
|
+
screenshot: Optional[str] = None
|
|
121
|
+
|
|
122
|
+
url: Optional[str] = None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class ReasoningStepBrowserAgent(BaseModel):
|
|
126
|
+
result: str
|
|
127
|
+
|
|
128
|
+
url: str
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class ReasoningStepBrowserToolExecution(BaseModel):
|
|
132
|
+
tool: Dict[str, object]
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class ReasoningStepExecutePython(BaseModel):
|
|
136
|
+
code: str
|
|
137
|
+
|
|
138
|
+
result: str
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class ReasoningStepFetchURLContent(BaseModel):
|
|
142
|
+
contents: List[APIPublicSearchResult]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class ReasoningStepFileAttachmentSearch(BaseModel):
|
|
146
|
+
attachment_urls: List[str]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ReasoningStepWebSearch(BaseModel):
|
|
150
|
+
search_keywords: List[str]
|
|
151
|
+
|
|
152
|
+
search_results: List[APIPublicSearchResult]
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class ReasoningStep(BaseModel):
|
|
156
|
+
thought: str
|
|
157
|
+
|
|
158
|
+
type: Literal[
|
|
159
|
+
"web_search",
|
|
160
|
+
"fetch_url_content",
|
|
161
|
+
"execute_python",
|
|
162
|
+
"agent_progress",
|
|
163
|
+
"browser_agent",
|
|
164
|
+
"browser_tool_execution",
|
|
165
|
+
"file_attachment_search",
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
agent_progress: Optional[ReasoningStepAgentProgress] = None
|
|
169
|
+
"""Agent progress class for live-browsing updates"""
|
|
170
|
+
|
|
171
|
+
browser_agent: Optional[ReasoningStepBrowserAgent] = None
|
|
172
|
+
"""Browser agent step summary class"""
|
|
173
|
+
|
|
174
|
+
browser_tool_execution: Optional[ReasoningStepBrowserToolExecution] = None
|
|
175
|
+
"""Tool input for kicking off browser tool automation"""
|
|
176
|
+
|
|
177
|
+
execute_python: Optional[ReasoningStepExecutePython] = None
|
|
178
|
+
"""Code generation step details wrapper class"""
|
|
179
|
+
|
|
180
|
+
fetch_url_content: Optional[ReasoningStepFetchURLContent] = None
|
|
181
|
+
"""Fetch url content step details wrapper class"""
|
|
182
|
+
|
|
183
|
+
file_attachment_search: Optional[ReasoningStepFileAttachmentSearch] = None
|
|
184
|
+
"""File attachment search step details wrapper class"""
|
|
185
|
+
|
|
186
|
+
web_search: Optional[ReasoningStepWebSearch] = None
|
|
187
|
+
"""Web search step details wrapper class"""
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class ToolCallFunction(BaseModel):
|
|
191
|
+
arguments: Optional[str] = None
|
|
192
|
+
|
|
193
|
+
name: Optional[str] = None
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class ToolCall(BaseModel):
|
|
197
|
+
id: Optional[str] = None
|
|
198
|
+
|
|
199
|
+
function: Optional[ToolCallFunction] = None
|
|
200
|
+
|
|
201
|
+
type: Optional[Literal["function"]] = None
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class ChatMessageOutput(BaseModel):
|
|
205
|
+
content: Union[str, List[ContentStructuredContent]]
|
|
206
|
+
|
|
207
|
+
role: Literal["system", "user", "assistant", "tool"]
|
|
208
|
+
"""Chat roles enum"""
|
|
209
|
+
|
|
210
|
+
reasoning_steps: Optional[List[ReasoningStep]] = None
|
|
211
|
+
|
|
212
|
+
tool_calls: Optional[List[ToolCall]] = None
|
|
@@ -4,14 +4,16 @@ from typing import Optional
|
|
|
4
4
|
from typing_extensions import Literal
|
|
5
5
|
|
|
6
6
|
from ..._models import BaseModel
|
|
7
|
-
from .
|
|
7
|
+
from .chat_message_output import ChatMessageOutput
|
|
8
8
|
|
|
9
|
-
__all__ = ["
|
|
9
|
+
__all__ = ["Choice"]
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class Choice(BaseModel):
|
|
13
|
+
delta: ChatMessageOutput
|
|
14
|
+
|
|
13
15
|
index: int
|
|
14
16
|
|
|
15
|
-
message:
|
|
17
|
+
message: ChatMessageOutput
|
|
16
18
|
|
|
17
19
|
finish_reason: Optional[Literal["stop", "length"]] = None
|
|
@@ -4,12 +4,30 @@ from typing import Optional
|
|
|
4
4
|
|
|
5
5
|
from ..._models import BaseModel
|
|
6
6
|
|
|
7
|
-
__all__ = ["UsageInfo"]
|
|
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
|
|
8
24
|
|
|
9
25
|
|
|
10
26
|
class UsageInfo(BaseModel):
|
|
11
27
|
completion_tokens: int
|
|
12
28
|
|
|
29
|
+
cost: Cost
|
|
30
|
+
|
|
13
31
|
prompt_tokens: int
|
|
14
32
|
|
|
15
33
|
total_tokens: int
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
from .
|
|
3
|
+
from .chat_message_input import ChatMessageInput as ChatMessageInput
|
|
4
|
+
from .api_public_search_result import APIPublicSearchResult as APIPublicSearchResult
|
|
@@ -0,0 +1,20 @@
|
|
|
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 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
|
|
@@ -0,0 +1,216 @@
|
|
|
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 Dict, 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
|
+
"ReasoningStepAgentProgress",
|
|
29
|
+
"ReasoningStepBrowserAgent",
|
|
30
|
+
"ReasoningStepBrowserToolExecution",
|
|
31
|
+
"ReasoningStepExecutePython",
|
|
32
|
+
"ReasoningStepFetchURLContent",
|
|
33
|
+
"ReasoningStepFileAttachmentSearch",
|
|
34
|
+
"ReasoningStepWebSearch",
|
|
35
|
+
"ToolCall",
|
|
36
|
+
"ToolCallFunction",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ContentStructuredContentChatMessageContentTextChunk(TypedDict, total=False):
|
|
41
|
+
text: Required[str]
|
|
42
|
+
|
|
43
|
+
type: Required[Literal["text"]]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ContentStructuredContentChatMessageContentImageChunkImageURLURL(TypedDict, total=False):
|
|
47
|
+
url: Required[str]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
ContentStructuredContentChatMessageContentImageChunkImageURL: TypeAlias = Union[
|
|
51
|
+
ContentStructuredContentChatMessageContentImageChunkImageURLURL, str
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ContentStructuredContentChatMessageContentImageChunk(TypedDict, total=False):
|
|
56
|
+
image_url: Required[ContentStructuredContentChatMessageContentImageChunkImageURL]
|
|
57
|
+
|
|
58
|
+
type: Required[Literal["image_url"]]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class ContentStructuredContentChatMessageContentFileChunkFileURLURL(TypedDict, total=False):
|
|
62
|
+
url: Required[str]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
ContentStructuredContentChatMessageContentFileChunkFileURL: TypeAlias = Union[
|
|
66
|
+
ContentStructuredContentChatMessageContentFileChunkFileURLURL, str
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ContentStructuredContentChatMessageContentFileChunk(TypedDict, total=False):
|
|
71
|
+
file_url: Required[ContentStructuredContentChatMessageContentFileChunkFileURL]
|
|
72
|
+
|
|
73
|
+
type: Required[Literal["file_url"]]
|
|
74
|
+
|
|
75
|
+
file_name: Optional[str]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ContentStructuredContentChatMessageContentPdfChunkPdfURLURL(TypedDict, total=False):
|
|
79
|
+
url: Required[str]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
ContentStructuredContentChatMessageContentPdfChunkPdfURL: TypeAlias = Union[
|
|
83
|
+
ContentStructuredContentChatMessageContentPdfChunkPdfURLURL, str
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ContentStructuredContentChatMessageContentPdfChunk(TypedDict, total=False):
|
|
88
|
+
pdf_url: Required[ContentStructuredContentChatMessageContentPdfChunkPdfURL]
|
|
89
|
+
|
|
90
|
+
type: Required[Literal["pdf_url"]]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL(TypedDict, total=False):
|
|
94
|
+
url: Required[str]
|
|
95
|
+
|
|
96
|
+
frame_interval: Union[str, int]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
ContentStructuredContentChatMessageContentVideoChunkVideoURL: TypeAlias = Union[
|
|
100
|
+
ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL, str
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class ContentStructuredContentChatMessageContentVideoChunk(TypedDict, total=False):
|
|
105
|
+
type: Required[Literal["video_url"]]
|
|
106
|
+
|
|
107
|
+
video_url: Required[ContentStructuredContentChatMessageContentVideoChunkVideoURL]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
ContentStructuredContent: TypeAlias = Union[
|
|
111
|
+
ContentStructuredContentChatMessageContentTextChunk,
|
|
112
|
+
ContentStructuredContentChatMessageContentImageChunk,
|
|
113
|
+
ContentStructuredContentChatMessageContentFileChunk,
|
|
114
|
+
ContentStructuredContentChatMessageContentPdfChunk,
|
|
115
|
+
ContentStructuredContentChatMessageContentVideoChunk,
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class ReasoningStepAgentProgress(TypedDict, total=False):
|
|
120
|
+
action: Required[Optional[str]]
|
|
121
|
+
|
|
122
|
+
screenshot: Required[Optional[str]]
|
|
123
|
+
|
|
124
|
+
url: Required[Optional[str]]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class ReasoningStepBrowserAgent(TypedDict, total=False):
|
|
128
|
+
result: Required[str]
|
|
129
|
+
|
|
130
|
+
url: Required[str]
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class ReasoningStepBrowserToolExecution(TypedDict, total=False):
|
|
134
|
+
tool: Required[Dict[str, object]]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class ReasoningStepExecutePython(TypedDict, total=False):
|
|
138
|
+
code: Required[str]
|
|
139
|
+
|
|
140
|
+
result: Required[str]
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class ReasoningStepFetchURLContent(TypedDict, total=False):
|
|
144
|
+
contents: Required[Iterable[APIPublicSearchResult]]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ReasoningStepFileAttachmentSearch(TypedDict, total=False):
|
|
148
|
+
attachment_urls: Required[SequenceNotStr[str]]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class ReasoningStepWebSearch(TypedDict, total=False):
|
|
152
|
+
search_keywords: Required[SequenceNotStr[str]]
|
|
153
|
+
|
|
154
|
+
search_results: Required[Iterable[APIPublicSearchResult]]
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class ReasoningStep(TypedDict, total=False):
|
|
158
|
+
thought: Required[str]
|
|
159
|
+
|
|
160
|
+
type: Required[
|
|
161
|
+
Literal[
|
|
162
|
+
"web_search",
|
|
163
|
+
"fetch_url_content",
|
|
164
|
+
"execute_python",
|
|
165
|
+
"agent_progress",
|
|
166
|
+
"browser_agent",
|
|
167
|
+
"browser_tool_execution",
|
|
168
|
+
"file_attachment_search",
|
|
169
|
+
]
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
agent_progress: Optional[ReasoningStepAgentProgress]
|
|
173
|
+
"""Agent progress class for live-browsing updates"""
|
|
174
|
+
|
|
175
|
+
browser_agent: Optional[ReasoningStepBrowserAgent]
|
|
176
|
+
"""Browser agent step summary class"""
|
|
177
|
+
|
|
178
|
+
browser_tool_execution: Optional[ReasoningStepBrowserToolExecution]
|
|
179
|
+
"""Tool input for kicking off browser tool automation"""
|
|
180
|
+
|
|
181
|
+
execute_python: Optional[ReasoningStepExecutePython]
|
|
182
|
+
"""Code generation step details wrapper class"""
|
|
183
|
+
|
|
184
|
+
fetch_url_content: Optional[ReasoningStepFetchURLContent]
|
|
185
|
+
"""Fetch url content step details wrapper class"""
|
|
186
|
+
|
|
187
|
+
file_attachment_search: Optional[ReasoningStepFileAttachmentSearch]
|
|
188
|
+
"""File attachment search step details wrapper class"""
|
|
189
|
+
|
|
190
|
+
web_search: Optional[ReasoningStepWebSearch]
|
|
191
|
+
"""Web search step details wrapper class"""
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ToolCallFunction(TypedDict, total=False):
|
|
195
|
+
arguments: Optional[str]
|
|
196
|
+
|
|
197
|
+
name: Optional[str]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class ToolCall(TypedDict, total=False):
|
|
201
|
+
id: Optional[str]
|
|
202
|
+
|
|
203
|
+
function: Optional[ToolCallFunction]
|
|
204
|
+
|
|
205
|
+
type: Optional[Literal["function"]]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class ChatMessageInput(TypedDict, total=False):
|
|
209
|
+
content: Required[Union[str, Iterable[ContentStructuredContent]]]
|
|
210
|
+
|
|
211
|
+
role: Required[Literal["system", "user", "assistant", "tool"]]
|
|
212
|
+
"""Chat roles enum"""
|
|
213
|
+
|
|
214
|
+
reasoning_steps: Optional[Iterable[ReasoningStep]]
|
|
215
|
+
|
|
216
|
+
tool_calls: Optional[Iterable[ToolCall]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: perplexityai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.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
|
|
@@ -55,7 +55,46 @@ The full API of this library can be found in [api.md](https://github.com/ppl-ai/
|
|
|
55
55
|
pip install perplexityai
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## Search API
|
|
59
|
+
|
|
60
|
+
Get web search results:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import os
|
|
64
|
+
from perplexity import Perplexity
|
|
65
|
+
|
|
66
|
+
client = Perplexity(
|
|
67
|
+
api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
search = client.search.create(
|
|
71
|
+
query="latest AI developments 2024",
|
|
72
|
+
max_results=5
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
for result in search.results:
|
|
76
|
+
print(f"{result.title}: {result.url}")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Content API
|
|
80
|
+
|
|
81
|
+
Extract and process content from URLs:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from perplexity import Perplexity
|
|
85
|
+
|
|
86
|
+
client = Perplexity()
|
|
87
|
+
|
|
88
|
+
content = client.content.create(
|
|
89
|
+
urls=["https://en.wikipedia.org/wiki/Perplexity_AI"]
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
for result in content.results:
|
|
93
|
+
print(f"Title: {result.title}")
|
|
94
|
+
print(f"Content: {result.content[:200]}...")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Chat Completions
|
|
59
98
|
|
|
60
99
|
The full API of this library can be found in [api.md](https://github.com/ppl-ai/perplexity-py/tree/main/api.md).
|
|
61
100
|
|
|
@@ -180,10 +219,10 @@ completion = client.chat.completions.create(
|
|
|
180
219
|
"role": "system",
|
|
181
220
|
}
|
|
182
221
|
],
|
|
183
|
-
model="
|
|
184
|
-
|
|
222
|
+
model="model",
|
|
223
|
+
debug_params={},
|
|
185
224
|
)
|
|
186
|
-
print(completion.
|
|
225
|
+
print(completion.debug_params)
|
|
187
226
|
```
|
|
188
227
|
|
|
189
228
|
## Handling errors
|
|
@@ -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=WFUYKYNg6jhaTctBBVU130bgSjL7INKzfZ7wwQgnBnA,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,39 +27,41 @@ 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=gQcgmiNY3uzaN5eAh9eclKJZRSaklhYcCF4ZTnFqemc,1877
|
|
30
|
-
perplexity/resources/content.py,sha256=
|
|
31
|
-
perplexity/resources/search.py,sha256=
|
|
30
|
+
perplexity/resources/content.py,sha256=4BbRmRPY3qeYtP-b8toraEbRnBMAPYRZkyuri17SH-0,5905
|
|
31
|
+
perplexity/resources/search.py,sha256=3EqjYtS5EK457YAO0QXY5QutoqscbSqKKxkwM65sRqU,9270
|
|
32
32
|
perplexity/resources/async_/__init__.py,sha256=hvcoEKx4nCYPDoBSO_sk-uNVQ7y-fmNhzvAlvX19TIo,964
|
|
33
33
|
perplexity/resources/async_/async_.py,sha256=p1-C_8m2cdS0NR3oa7FfdM8gxHH13LQWX6c9lh1gnFo,3510
|
|
34
34
|
perplexity/resources/async_/chat/__init__.py,sha256=BVAfz9TM3DT5W9f_mt0P9YRxL_MsUxKCWAH6u1iogmA,1041
|
|
35
35
|
perplexity/resources/async_/chat/chat.py,sha256=wOHHfLclvjAVv-btASi6EcdY5gJZQdwAdbR9Q9H4BKw,3658
|
|
36
|
-
perplexity/resources/async_/chat/completions.py,sha256=
|
|
36
|
+
perplexity/resources/async_/chat/completions.py,sha256=VGYNp5B-WSLgGRHlNJ1V4qkH-6s_pTZbw0ENGtFK9W0,14097
|
|
37
37
|
perplexity/resources/chat/__init__.py,sha256=BVAfz9TM3DT5W9f_mt0P9YRxL_MsUxKCWAH6u1iogmA,1041
|
|
38
38
|
perplexity/resources/chat/chat.py,sha256=P143HQo1m9MknnYtSq4JzmDofDtGHlXHzTaLEyr1a7k,3656
|
|
39
|
-
perplexity/resources/chat/completions.py,sha256=
|
|
40
|
-
perplexity/types/__init__.py,sha256=
|
|
41
|
-
perplexity/types/content_create_params.py,sha256=
|
|
42
|
-
perplexity/types/content_create_response.py,sha256=
|
|
43
|
-
perplexity/types/search_create_params.py,sha256=
|
|
44
|
-
perplexity/types/search_create_response.py,sha256=
|
|
39
|
+
perplexity/resources/chat/completions.py,sha256=lO0l-PulNqlWu0dLl3V4zow63BWwHO0HGwDgAAvnry8,19903
|
|
40
|
+
perplexity/types/__init__.py,sha256=PozMGI21_KXErLZnjOMd8UA6xHPk1vmCjYmPoyi-IK0,653
|
|
41
|
+
perplexity/types/content_create_params.py,sha256=NHj29NXYWhvY9CpcE2RuqHQ-H2_dP7yRRa3fFUbB2AM,338
|
|
42
|
+
perplexity/types/content_create_response.py,sha256=Wr2TbU5lbEb5tHhw68erei5AGtX6hfQHmc-y8DcatLc,388
|
|
43
|
+
perplexity/types/search_create_params.py,sha256=RHKT4toTErSF4T5g0DYD9DTDFDOvjKF0BIa0t5Pv7bk,916
|
|
44
|
+
perplexity/types/search_create_response.py,sha256=lOteaJs4qpULkx5GLtEs6HhetqIBhM0I1AC1moWTeI8,426
|
|
45
45
|
perplexity/types/async_/__init__.py,sha256=OKfJYcKb4NObdiRObqJV_dOyDQ8feXekDUge2o_4pXQ,122
|
|
46
|
-
perplexity/types/async_/chat/__init__.py,sha256=
|
|
47
|
-
perplexity/types/async_/chat/completion_create_params.py,sha256=
|
|
48
|
-
perplexity/types/async_/chat/completion_create_response.py,sha256=
|
|
49
|
-
perplexity/types/async_/chat/
|
|
50
|
-
perplexity/types/async_/chat/
|
|
51
|
-
perplexity/types/async_/chat/completion_list_response.py,sha256=
|
|
46
|
+
perplexity/types/async_/chat/__init__.py,sha256=xo2Cya_CfjEBRos2yvW_Wrq39PZiXFBT7ukZZBNvIUM,552
|
|
47
|
+
perplexity/types/async_/chat/completion_create_params.py,sha256=Mluv9hgXXl1Glurp8_KoexWDh42gFnK0kV2zZyHIXBk,5576
|
|
48
|
+
perplexity/types/async_/chat/completion_create_response.py,sha256=qI4fKrUGSd52BHoqTK9LnoGTvlnpaDbn3xCwUOG_sA8,1200
|
|
49
|
+
perplexity/types/async_/chat/completion_get_params.py,sha256=3nh10bMw1nYn3oriD5CIBPyL7hN25Xz4vbVfxEf33Zw,670
|
|
50
|
+
perplexity/types/async_/chat/completion_get_response.py,sha256=pKnUzzBSPaToucLTz-AS-dASl8Azscck48yE_G_qPic,1194
|
|
51
|
+
perplexity/types/async_/chat/completion_list_response.py,sha256=63QSRV-2YA6gMZhyrmiZuzxasjjwT-kM3MyFuadTnZs,658
|
|
52
52
|
perplexity/types/chat/__init__.py,sha256=A5VCUPqJZydjjOqEXC01GXmcDkKM3bq6zuCu9lmi5Es,303
|
|
53
|
-
perplexity/types/chat/completion_create_params.py,sha256=
|
|
54
|
-
perplexity/types/chat/completion_create_response.py,sha256=
|
|
55
|
-
perplexity/types/shared/__init__.py,sha256
|
|
56
|
-
perplexity/types/shared/
|
|
57
|
-
perplexity/types/shared/
|
|
58
|
-
perplexity/types/shared/
|
|
59
|
-
perplexity/types/shared/
|
|
60
|
-
perplexity/types/
|
|
61
|
-
perplexity/types/shared_params/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
perplexityai-0.
|
|
65
|
-
perplexityai-0.
|
|
53
|
+
perplexity/types/chat/completion_create_params.py,sha256=dXQwAuAuOd1ZRf_jS7Qzev9IpaM19U3mMeu1882LnX8,5190
|
|
54
|
+
perplexity/types/chat/completion_create_response.py,sha256=u4zFkOce7ER_H0j76a67B6RZlErUUI3xBed81iYklF0,795
|
|
55
|
+
perplexity/types/shared/__init__.py,sha256=-RlflcttJZ_q_lP6YD0mVWbKhU33j91tUVuMO5OqMAM,397
|
|
56
|
+
perplexity/types/shared/api_public_search_result.py,sha256=0Wu4nwHvyQqV6jLvCVdEMWndCZ9DG7lgL3Y174rISX0,364
|
|
57
|
+
perplexity/types/shared/chat_message_input.py,sha256=wgqL1qb6hHU-sZgybgjL3VdAJFHdY0HjjNecey6CHLU,6118
|
|
58
|
+
perplexity/types/shared/chat_message_output.py,sha256=ejnHnPuYphBCo44u5d9RKIc5tQJ98SHcbGLYR7St-CQ,6120
|
|
59
|
+
perplexity/types/shared/choice.py,sha256=enGVvSlz6W4fC6scq9j_E1zxvMnSG_IxU0plF9jYiJE,427
|
|
60
|
+
perplexity/types/shared/usage_info.py,sha256=_jE7Nal9cMxtEpJjT4t2SAs6z3MufrjwPugsRomqc9c,782
|
|
61
|
+
perplexity/types/shared_params/__init__.py,sha256=v5gr6-wq7IWgrQ8un401oApylzh3KnsIF_ilz-roX0s,241
|
|
62
|
+
perplexity/types/shared_params/api_public_search_result.py,sha256=n4VUQnGOFGGWUdwYd8P5o-vEqZKhRuI5R0dBs_ZsHtE,418
|
|
63
|
+
perplexity/types/shared_params/chat_message_input.py,sha256=BsNwhjwOFydvUo2OfrF9AHx--a1uPidSxdDyBGrK-sc,6690
|
|
64
|
+
perplexityai-0.8.0.dist-info/METADATA,sha256=UcF5JgpAJeCjXBxpF8cSxzL_JZZ7y7zLN0Gm3pktWQg,15980
|
|
65
|
+
perplexityai-0.8.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
66
|
+
perplexityai-0.8.0.dist-info/licenses/LICENSE,sha256=hkCriG3MT4vBhhc0roAOsrCE7IEDr1ywVEMonVHGmAQ,11340
|
|
67
|
+
perplexityai-0.8.0.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
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 TypedDict
|
|
6
|
-
|
|
7
|
-
__all__ = ["CompletionListParams"]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class CompletionListParams(TypedDict, total=False):
|
|
11
|
-
limit: int
|
|
12
|
-
"""Maximum number of requests to return"""
|
|
13
|
-
|
|
14
|
-
next_token: str
|
|
15
|
-
"""Token for fetching the next page of results"""
|