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,244 @@
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 ..shared_params.chat_message_input import ChatMessageInput
10
+
11
+ __all__ = [
12
+ "CompletionCreateParamsBase",
13
+ "ResponseFormat",
14
+ "ResponseFormatResponseFormatText",
15
+ "ResponseFormatResponseFormatJsonSchema",
16
+ "ResponseFormatResponseFormatJsonSchemaJsonSchema",
17
+ "ResponseFormatResponseFormatRegex",
18
+ "ResponseFormatResponseFormatRegexRegex",
19
+ "Tool",
20
+ "ToolFunction",
21
+ "ToolFunctionParameters",
22
+ "WebSearchOptions",
23
+ "WebSearchOptionsUserLocation",
24
+ "CompletionCreateParamsNonStreaming",
25
+ "CompletionCreateParamsStreaming",
26
+ ]
27
+
28
+
29
+ class CompletionCreateParamsBase(TypedDict, total=False):
30
+ messages: Required[Iterable[ChatMessageInput]]
31
+
32
+ model: Required[str]
33
+
34
+ _debug_pro_search: bool
35
+
36
+ _force_new_agent: Optional[bool]
37
+
38
+ _inputs: Optional[Iterable[int]]
39
+
40
+ _prompt_token_length: Optional[int]
41
+
42
+ best_of: Optional[int]
43
+
44
+ country: Optional[str]
45
+
46
+ cum_logprobs: Optional[bool]
47
+
48
+ disable_search: Optional[bool]
49
+
50
+ diverse_first_token: Optional[bool]
51
+
52
+ enable_search_classifier: Optional[bool]
53
+
54
+ file_workspace_id: Optional[str]
55
+
56
+ frequency_penalty: Optional[float]
57
+
58
+ has_image_url: bool
59
+
60
+ image_domain_filter: Optional[SequenceNotStr[str]]
61
+
62
+ image_format_filter: Optional[SequenceNotStr[str]]
63
+
64
+ language_preference: Optional[str]
65
+
66
+ last_updated_after_filter: Optional[str]
67
+
68
+ last_updated_before_filter: Optional[str]
69
+
70
+ latitude: Optional[float]
71
+
72
+ logprobs: Optional[bool]
73
+
74
+ longitude: Optional[float]
75
+
76
+ max_tokens: Optional[int]
77
+
78
+ n: Optional[int]
79
+
80
+ num_images: int
81
+
82
+ num_search_results: int
83
+
84
+ parallel_tool_calls: Optional[bool]
85
+
86
+ presence_penalty: Optional[float]
87
+
88
+ ranking_model: Optional[str]
89
+
90
+ reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]]
91
+
92
+ response_format: Optional[ResponseFormat]
93
+
94
+ response_metadata: Optional[Dict[str, object]]
95
+
96
+ return_images: Optional[bool]
97
+
98
+ return_related_questions: Optional[bool]
99
+
100
+ safe_search: Optional[bool]
101
+
102
+ search_after_date_filter: Optional[str]
103
+
104
+ search_before_date_filter: Optional[str]
105
+
106
+ search_domain_filter: Optional[SequenceNotStr[str]]
107
+
108
+ search_internal_properties: Optional[Dict[str, object]]
109
+
110
+ search_language_filter: Optional[SequenceNotStr[str]]
111
+
112
+ search_mode: Optional[Literal["web", "academic", "sec"]]
113
+
114
+ search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]]
115
+
116
+ search_tenant: Optional[str]
117
+
118
+ stop: Union[str, SequenceNotStr[str], None]
119
+
120
+ stream_mode: Literal["full", "concise"]
121
+
122
+ temperature: Optional[float]
123
+
124
+ thread_id: Optional[str]
125
+
126
+ tool_choice: Optional[Literal["none", "auto", "required"]]
127
+
128
+ tools: Optional[Iterable[Tool]]
129
+
130
+ top_k: Optional[int]
131
+
132
+ top_logprobs: Optional[int]
133
+
134
+ top_p: Optional[float]
135
+
136
+ updated_after_timestamp: Optional[int]
137
+
138
+ updated_before_timestamp: Optional[int]
139
+
140
+ use_threads: Optional[bool]
141
+
142
+ user_original_query: Optional[str]
143
+
144
+ web_search_options: WebSearchOptions
145
+
146
+
147
+ class ResponseFormatResponseFormatText(TypedDict, total=False):
148
+ type: Required[Literal["text"]]
149
+
150
+
151
+ class ResponseFormatResponseFormatJsonSchemaJsonSchema(TypedDict, total=False):
152
+ schema: Required[Dict[str, object]]
153
+
154
+ description: Optional[str]
155
+
156
+ name: Optional[str]
157
+
158
+ strict: Optional[bool]
159
+
160
+
161
+ class ResponseFormatResponseFormatJsonSchema(TypedDict, total=False):
162
+ json_schema: Required[ResponseFormatResponseFormatJsonSchemaJsonSchema]
163
+
164
+ type: Required[Literal["json_schema"]]
165
+
166
+
167
+ class ResponseFormatResponseFormatRegexRegex(TypedDict, total=False):
168
+ regex: Required[str]
169
+
170
+ description: Optional[str]
171
+
172
+ name: Optional[str]
173
+
174
+ strict: Optional[bool]
175
+
176
+
177
+ class ResponseFormatResponseFormatRegex(TypedDict, total=False):
178
+ regex: Required[ResponseFormatResponseFormatRegexRegex]
179
+
180
+ type: Required[Literal["regex"]]
181
+
182
+
183
+ ResponseFormat: TypeAlias = Union[
184
+ ResponseFormatResponseFormatText, ResponseFormatResponseFormatJsonSchema, ResponseFormatResponseFormatRegex
185
+ ]
186
+
187
+
188
+ class ToolFunctionParameters(TypedDict, total=False):
189
+ properties: Required[Dict[str, object]]
190
+
191
+ type: Required[str]
192
+
193
+ additional_properties: Optional[bool]
194
+
195
+ required: Optional[SequenceNotStr[str]]
196
+
197
+
198
+ class ToolFunction(TypedDict, total=False):
199
+ description: Required[str]
200
+
201
+ name: Required[str]
202
+
203
+ parameters: Required[ToolFunctionParameters]
204
+
205
+ strict: Optional[bool]
206
+
207
+
208
+ class Tool(TypedDict, total=False):
209
+ function: Required[ToolFunction]
210
+
211
+ type: Required[Literal["function"]]
212
+
213
+
214
+ class WebSearchOptionsUserLocation(TypedDict, total=False):
215
+ city: Optional[str]
216
+
217
+ country: Optional[str]
218
+
219
+ latitude: Optional[float]
220
+
221
+ longitude: Optional[float]
222
+
223
+ region: Optional[str]
224
+
225
+
226
+ class WebSearchOptions(TypedDict, total=False):
227
+ image_results_enhanced_relevance: bool
228
+
229
+ search_context_size: Literal["low", "medium", "high"]
230
+
231
+ search_type: Optional[Literal["fast", "pro", "auto"]]
232
+
233
+ user_location: Optional[WebSearchOptionsUserLocation]
234
+
235
+
236
+ class CompletionCreateParamsNonStreaming(CompletionCreateParamsBase, total=False):
237
+ stream: Optional[Literal[False]]
238
+
239
+
240
+ class CompletionCreateParamsStreaming(CompletionCreateParamsBase):
241
+ stream: Required[Literal[True]]
242
+
243
+
244
+ CompletionCreateParams = Union[CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming]
@@ -0,0 +1,40 @@
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, Optional
6
+ from typing_extensions import Literal, Required, TypedDict
7
+
8
+ from .._types import SequenceNotStr
9
+
10
+ __all__ = ["SearchCreateParams"]
11
+
12
+
13
+ class SearchCreateParams(TypedDict, total=False):
14
+ query: Required[Union[str, SequenceNotStr[str]]]
15
+
16
+ country: Optional[str]
17
+
18
+ display_server_time: bool
19
+
20
+ last_updated_after_filter: Optional[str]
21
+
22
+ last_updated_before_filter: Optional[str]
23
+
24
+ max_results: int
25
+
26
+ max_tokens: int
27
+
28
+ max_tokens_per_page: int
29
+
30
+ search_after_date_filter: Optional[str]
31
+
32
+ search_before_date_filter: Optional[str]
33
+
34
+ search_domain_filter: Optional[SequenceNotStr[str]]
35
+
36
+ search_language_filter: Optional[SequenceNotStr[str]]
37
+
38
+ search_mode: Optional[Literal["web", "academic", "sec"]]
39
+
40
+ search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]]
@@ -0,0 +1,27 @@
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__ = ["SearchCreateResponse", "Result"]
8
+
9
+
10
+ class Result(BaseModel):
11
+ snippet: str
12
+
13
+ title: str
14
+
15
+ url: str
16
+
17
+ date: Optional[str] = None
18
+
19
+ last_updated: Optional[str] = None
20
+
21
+
22
+ class SearchCreateResponse(BaseModel):
23
+ id: str
24
+
25
+ results: List[Result]
26
+
27
+ server_time: Optional[str] = None
@@ -0,0 +1,7 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .choice import Choice as Choice
4
+ from .usage_info import UsageInfo as UsageInfo
5
+ from .chat_message_input import ChatMessageInput as ChatMessageInput
6
+ from .chat_message_output import ChatMessageOutput as ChatMessageOutput
7
+ 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 typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ..._models import BaseModel
7
+
8
+ __all__ = ["APIPublicSearchResult"]
9
+
10
+
11
+ class APIPublicSearchResult(BaseModel):
12
+ title: str
13
+
14
+ url: str
15
+
16
+ date: Optional[str] = None
17
+
18
+ last_updated: Optional[str] = None
19
+
20
+ snippet: Optional[str] = None
21
+
22
+ source: Optional[Literal["web", "attachment"]] = None
@@ -0,0 +1,176 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import 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
+ "ChatMessageInput",
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
+ "ReasoningStepExecutePython",
27
+ "ReasoningStepFetchURLContent",
28
+ "ReasoningStepWebSearch",
29
+ "ToolCall",
30
+ "ToolCallFunction",
31
+ ]
32
+
33
+
34
+ class ContentStructuredContentChatMessageContentTextChunk(BaseModel):
35
+ text: str
36
+
37
+ type: Literal["text"]
38
+
39
+
40
+ class ContentStructuredContentChatMessageContentImageChunkImageURLURL(BaseModel):
41
+ url: str
42
+
43
+
44
+ ContentStructuredContentChatMessageContentImageChunkImageURL: TypeAlias = Union[
45
+ ContentStructuredContentChatMessageContentImageChunkImageURLURL, str
46
+ ]
47
+
48
+
49
+ class ContentStructuredContentChatMessageContentImageChunk(BaseModel):
50
+ image_url: ContentStructuredContentChatMessageContentImageChunkImageURL
51
+
52
+ type: Literal["image_url"]
53
+
54
+
55
+ class ContentStructuredContentChatMessageContentFileChunkFileURLURL(BaseModel):
56
+ url: str
57
+
58
+
59
+ ContentStructuredContentChatMessageContentFileChunkFileURL: TypeAlias = Union[
60
+ ContentStructuredContentChatMessageContentFileChunkFileURLURL, str
61
+ ]
62
+
63
+
64
+ class ContentStructuredContentChatMessageContentFileChunk(BaseModel):
65
+ file_url: ContentStructuredContentChatMessageContentFileChunkFileURL
66
+
67
+ type: Literal["file_url"]
68
+
69
+ file_name: Optional[str] = None
70
+
71
+
72
+ class ContentStructuredContentChatMessageContentPdfChunkPdfURLURL(BaseModel):
73
+ url: str
74
+
75
+
76
+ ContentStructuredContentChatMessageContentPdfChunkPdfURL: TypeAlias = Union[
77
+ ContentStructuredContentChatMessageContentPdfChunkPdfURLURL, str
78
+ ]
79
+
80
+
81
+ class ContentStructuredContentChatMessageContentPdfChunk(BaseModel):
82
+ pdf_url: ContentStructuredContentChatMessageContentPdfChunkPdfURL
83
+
84
+ type: Literal["pdf_url"]
85
+
86
+
87
+ class ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL(BaseModel):
88
+ url: str
89
+
90
+ frame_interval: Union[str, int, None] = None
91
+
92
+
93
+ ContentStructuredContentChatMessageContentVideoChunkVideoURL: TypeAlias = Union[
94
+ ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL, str
95
+ ]
96
+
97
+
98
+ class ContentStructuredContentChatMessageContentVideoChunk(BaseModel):
99
+ type: Literal["video_url"]
100
+
101
+ video_url: ContentStructuredContentChatMessageContentVideoChunkVideoURL
102
+
103
+
104
+ ContentStructuredContent: TypeAlias = Union[
105
+ ContentStructuredContentChatMessageContentTextChunk,
106
+ ContentStructuredContentChatMessageContentImageChunk,
107
+ ContentStructuredContentChatMessageContentFileChunk,
108
+ ContentStructuredContentChatMessageContentPdfChunk,
109
+ ContentStructuredContentChatMessageContentVideoChunk,
110
+ ]
111
+
112
+
113
+ class ReasoningStepExecutePython(BaseModel):
114
+ """Code generation step details wrapper class"""
115
+
116
+ code: str
117
+
118
+ result: str
119
+
120
+
121
+ class ReasoningStepFetchURLContent(BaseModel):
122
+ """Fetch url content step details wrapper class"""
123
+
124
+ contents: List[APIPublicSearchResult]
125
+
126
+
127
+ class ReasoningStepWebSearch(BaseModel):
128
+ """Web search step details wrapper class"""
129
+
130
+ search_keywords: List[str]
131
+
132
+ search_results: List[APIPublicSearchResult]
133
+
134
+
135
+ class ReasoningStep(BaseModel):
136
+ """Reasoning step wrapper class"""
137
+
138
+ thought: str
139
+
140
+ execute_python: Optional[ReasoningStepExecutePython] = None
141
+ """Code generation step details wrapper class"""
142
+
143
+ fetch_url_content: Optional[ReasoningStepFetchURLContent] = None
144
+ """Fetch url content step details wrapper class"""
145
+
146
+ type: Optional[str] = None
147
+
148
+ web_search: Optional[ReasoningStepWebSearch] = None
149
+ """Web search step details wrapper class"""
150
+
151
+
152
+ class ToolCallFunction(BaseModel):
153
+ arguments: Optional[str] = None
154
+
155
+ name: Optional[str] = None
156
+
157
+
158
+ class ToolCall(BaseModel):
159
+ id: Optional[str] = None
160
+
161
+ function: Optional[ToolCallFunction] = None
162
+
163
+ type: Optional[Literal["function"]] = None
164
+
165
+
166
+ class ChatMessageInput(BaseModel):
167
+ content: Union[str, List[ContentStructuredContent], None] = None
168
+
169
+ role: Literal["system", "user", "assistant", "tool"]
170
+ """Chat roles enum"""
171
+
172
+ reasoning_steps: Optional[List[ReasoningStep]] = None
173
+
174
+ tool_call_id: Optional[str] = None
175
+
176
+ tool_calls: Optional[List[ToolCall]] = None
@@ -0,0 +1,176 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import 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
+ "ReasoningStepExecutePython",
27
+ "ReasoningStepFetchURLContent",
28
+ "ReasoningStepWebSearch",
29
+ "ToolCall",
30
+ "ToolCallFunction",
31
+ ]
32
+
33
+
34
+ class ContentStructuredContentChatMessageContentTextChunk(BaseModel):
35
+ text: str
36
+
37
+ type: Literal["text"]
38
+
39
+
40
+ class ContentStructuredContentChatMessageContentImageChunkImageURLURL(BaseModel):
41
+ url: str
42
+
43
+
44
+ ContentStructuredContentChatMessageContentImageChunkImageURL: TypeAlias = Union[
45
+ ContentStructuredContentChatMessageContentImageChunkImageURLURL, str
46
+ ]
47
+
48
+
49
+ class ContentStructuredContentChatMessageContentImageChunk(BaseModel):
50
+ image_url: ContentStructuredContentChatMessageContentImageChunkImageURL
51
+
52
+ type: Literal["image_url"]
53
+
54
+
55
+ class ContentStructuredContentChatMessageContentFileChunkFileURLURL(BaseModel):
56
+ url: str
57
+
58
+
59
+ ContentStructuredContentChatMessageContentFileChunkFileURL: TypeAlias = Union[
60
+ ContentStructuredContentChatMessageContentFileChunkFileURLURL, str
61
+ ]
62
+
63
+
64
+ class ContentStructuredContentChatMessageContentFileChunk(BaseModel):
65
+ file_url: ContentStructuredContentChatMessageContentFileChunkFileURL
66
+
67
+ type: Literal["file_url"]
68
+
69
+ file_name: Optional[str] = None
70
+
71
+
72
+ class ContentStructuredContentChatMessageContentPdfChunkPdfURLURL(BaseModel):
73
+ url: str
74
+
75
+
76
+ ContentStructuredContentChatMessageContentPdfChunkPdfURL: TypeAlias = Union[
77
+ ContentStructuredContentChatMessageContentPdfChunkPdfURLURL, str
78
+ ]
79
+
80
+
81
+ class ContentStructuredContentChatMessageContentPdfChunk(BaseModel):
82
+ pdf_url: ContentStructuredContentChatMessageContentPdfChunkPdfURL
83
+
84
+ type: Literal["pdf_url"]
85
+
86
+
87
+ class ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL(BaseModel):
88
+ url: str
89
+
90
+ frame_interval: Union[str, int, None] = None
91
+
92
+
93
+ ContentStructuredContentChatMessageContentVideoChunkVideoURL: TypeAlias = Union[
94
+ ContentStructuredContentChatMessageContentVideoChunkVideoURLVideoURL, str
95
+ ]
96
+
97
+
98
+ class ContentStructuredContentChatMessageContentVideoChunk(BaseModel):
99
+ type: Literal["video_url"]
100
+
101
+ video_url: ContentStructuredContentChatMessageContentVideoChunkVideoURL
102
+
103
+
104
+ ContentStructuredContent: TypeAlias = Union[
105
+ ContentStructuredContentChatMessageContentTextChunk,
106
+ ContentStructuredContentChatMessageContentImageChunk,
107
+ ContentStructuredContentChatMessageContentFileChunk,
108
+ ContentStructuredContentChatMessageContentPdfChunk,
109
+ ContentStructuredContentChatMessageContentVideoChunk,
110
+ ]
111
+
112
+
113
+ class ReasoningStepExecutePython(BaseModel):
114
+ """Code generation step details wrapper class"""
115
+
116
+ code: str
117
+
118
+ result: str
119
+
120
+
121
+ class ReasoningStepFetchURLContent(BaseModel):
122
+ """Fetch url content step details wrapper class"""
123
+
124
+ contents: List[APIPublicSearchResult]
125
+
126
+
127
+ class ReasoningStepWebSearch(BaseModel):
128
+ """Web search step details wrapper class"""
129
+
130
+ search_keywords: List[str]
131
+
132
+ search_results: List[APIPublicSearchResult]
133
+
134
+
135
+ class ReasoningStep(BaseModel):
136
+ """Reasoning step wrapper class"""
137
+
138
+ thought: str
139
+
140
+ execute_python: Optional[ReasoningStepExecutePython] = None
141
+ """Code generation step details wrapper class"""
142
+
143
+ fetch_url_content: Optional[ReasoningStepFetchURLContent] = None
144
+ """Fetch url content step details wrapper class"""
145
+
146
+ type: Optional[str] = None
147
+
148
+ web_search: Optional[ReasoningStepWebSearch] = None
149
+ """Web search step details wrapper class"""
150
+
151
+
152
+ class ToolCallFunction(BaseModel):
153
+ arguments: Optional[str] = None
154
+
155
+ name: Optional[str] = None
156
+
157
+
158
+ class ToolCall(BaseModel):
159
+ id: Optional[str] = None
160
+
161
+ function: Optional[ToolCallFunction] = None
162
+
163
+ type: Optional[Literal["function"]] = None
164
+
165
+
166
+ class ChatMessageOutput(BaseModel):
167
+ content: Union[str, List[ContentStructuredContent], None] = None
168
+
169
+ role: Literal["system", "user", "assistant", "tool"]
170
+ """Chat roles enum"""
171
+
172
+ reasoning_steps: Optional[List[ReasoningStep]] = None
173
+
174
+ tool_call_id: Optional[str] = None
175
+
176
+ tool_calls: Optional[List[ToolCall]] = None