perplexityai 0.12.1__py3-none-any.whl → 0.14.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 +4 -0
- perplexity/_streaming.py +40 -2
- perplexity/_version.py +1 -1
- perplexity/resources/async_/chat/completions.py +10 -12
- perplexity/resources/chat/completions.py +514 -13
- perplexity/resources/search.py +6 -6
- perplexity/types/__init__.py +1 -0
- perplexity/types/async_/chat/completion_create_params.py +9 -1
- perplexity/types/async_/chat/completion_create_response.py +4 -28
- perplexity/types/async_/chat/completion_get_params.py +2 -0
- perplexity/types/async_/chat/completion_get_response.py +4 -28
- perplexity/types/chat/__init__.py +0 -1
- perplexity/types/chat/completion_create_params.py +23 -4
- perplexity/types/search_create_params.py +1 -1
- perplexity/types/search_create_response.py +2 -0
- perplexity/types/shared/api_public_search_result.py +3 -0
- perplexity/types/shared_params/api_public_search_result.py +3 -1
- perplexity/types/{chat/completion_create_response.py → stream_chunk.py} +8 -8
- {perplexityai-0.12.1.dist-info → perplexityai-0.14.0.dist-info}/METADATA +53 -9
- {perplexityai-0.12.1.dist-info → perplexityai-0.14.0.dist-info}/RECORD +22 -22
- {perplexityai-0.12.1.dist-info → perplexityai-0.14.0.dist-info}/WHEEL +0 -0
- {perplexityai-0.12.1.dist-info → perplexityai-0.14.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from typing import Dict, Union, Iterable, Optional
|
|
6
|
-
from typing_extensions import Literal
|
|
6
|
+
from typing_extensions import Literal, overload
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
10
|
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
11
|
-
from ..._utils import maybe_transform, async_maybe_transform
|
|
11
|
+
from ..._utils import required_args, maybe_transform, async_maybe_transform
|
|
12
12
|
from ..._compat import cached_property
|
|
13
13
|
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
14
14
|
from ..._response import (
|
|
@@ -17,9 +17,10 @@ from ..._response import (
|
|
|
17
17
|
async_to_raw_response_wrapper,
|
|
18
18
|
async_to_streamed_response_wrapper,
|
|
19
19
|
)
|
|
20
|
+
from ..._streaming import Stream, AsyncStream
|
|
20
21
|
from ...types.chat import completion_create_params
|
|
21
22
|
from ..._base_client import make_request_options
|
|
22
|
-
from ...types.
|
|
23
|
+
from ...types.stream_chunk import StreamChunk
|
|
23
24
|
from ...types.shared_params.chat_message_input import ChatMessageInput
|
|
24
25
|
|
|
25
26
|
__all__ = ["CompletionsResource", "AsyncCompletionsResource"]
|
|
@@ -45,6 +46,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
45
46
|
"""
|
|
46
47
|
return CompletionsResourceWithStreamingResponse(self)
|
|
47
48
|
|
|
49
|
+
@overload
|
|
48
50
|
def create(
|
|
49
51
|
self,
|
|
50
52
|
*,
|
|
@@ -66,6 +68,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
66
68
|
has_image_url: bool | Omit = omit,
|
|
67
69
|
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
68
70
|
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
71
|
+
language_preference: Optional[str] | Omit = omit,
|
|
69
72
|
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
70
73
|
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
71
74
|
latitude: Optional[float] | Omit = omit,
|
|
@@ -92,8 +95,10 @@ class CompletionsResource(SyncAPIResource):
|
|
|
92
95
|
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
93
96
|
search_tenant: Optional[str] | Omit = omit,
|
|
94
97
|
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
95
|
-
stream: Optional[
|
|
98
|
+
stream: Optional[Literal[False]] | Omit = omit,
|
|
99
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
96
100
|
temperature: Optional[float] | Omit = omit,
|
|
101
|
+
thread_id: Optional[str] | Omit = omit,
|
|
97
102
|
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
98
103
|
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
99
104
|
top_k: Optional[int] | Omit = omit,
|
|
@@ -101,6 +106,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
101
106
|
top_p: Optional[float] | Omit = omit,
|
|
102
107
|
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
103
108
|
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
109
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
104
110
|
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
105
111
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
106
112
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
@@ -108,9 +114,9 @@ class CompletionsResource(SyncAPIResource):
|
|
|
108
114
|
extra_query: Query | None = None,
|
|
109
115
|
extra_body: Body | None = None,
|
|
110
116
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
111
|
-
) ->
|
|
117
|
+
) -> StreamChunk:
|
|
112
118
|
"""
|
|
113
|
-
|
|
119
|
+
Generate a chat completion response for the given conversation.
|
|
114
120
|
|
|
115
121
|
Args:
|
|
116
122
|
extra_headers: Send extra headers
|
|
@@ -121,6 +127,243 @@ class CompletionsResource(SyncAPIResource):
|
|
|
121
127
|
|
|
122
128
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
123
129
|
"""
|
|
130
|
+
...
|
|
131
|
+
|
|
132
|
+
@overload
|
|
133
|
+
def create(
|
|
134
|
+
self,
|
|
135
|
+
*,
|
|
136
|
+
messages: Iterable[ChatMessageInput],
|
|
137
|
+
model: str,
|
|
138
|
+
stream: Literal[True],
|
|
139
|
+
_debug_pro_search: bool | Omit = omit,
|
|
140
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
141
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
142
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
143
|
+
best_of: Optional[int] | Omit = omit,
|
|
144
|
+
country: Optional[str] | Omit = omit,
|
|
145
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
146
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
147
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
148
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
149
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
150
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
151
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
152
|
+
has_image_url: bool | Omit = omit,
|
|
153
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
154
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
155
|
+
language_preference: Optional[str] | Omit = omit,
|
|
156
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
157
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
158
|
+
latitude: Optional[float] | Omit = omit,
|
|
159
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
160
|
+
longitude: Optional[float] | Omit = omit,
|
|
161
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
162
|
+
n: Optional[int] | Omit = omit,
|
|
163
|
+
num_images: int | Omit = omit,
|
|
164
|
+
num_search_results: int | Omit = omit,
|
|
165
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
166
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
167
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
168
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
169
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
170
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
171
|
+
return_images: Optional[bool] | Omit = omit,
|
|
172
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
173
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
174
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
175
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
176
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
177
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
178
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
179
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
180
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
181
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
182
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
183
|
+
temperature: Optional[float] | Omit = omit,
|
|
184
|
+
thread_id: Optional[str] | Omit = omit,
|
|
185
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
186
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
187
|
+
top_k: Optional[int] | Omit = omit,
|
|
188
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
189
|
+
top_p: Optional[float] | Omit = omit,
|
|
190
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
191
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
192
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
193
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
194
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
195
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
196
|
+
extra_headers: Headers | None = None,
|
|
197
|
+
extra_query: Query | None = None,
|
|
198
|
+
extra_body: Body | None = None,
|
|
199
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
200
|
+
) -> Stream[StreamChunk]:
|
|
201
|
+
"""
|
|
202
|
+
Generate a chat completion response for the given conversation.
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
extra_headers: Send extra headers
|
|
206
|
+
|
|
207
|
+
extra_query: Add additional query parameters to the request
|
|
208
|
+
|
|
209
|
+
extra_body: Add additional JSON properties to the request
|
|
210
|
+
|
|
211
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
212
|
+
"""
|
|
213
|
+
...
|
|
214
|
+
|
|
215
|
+
@overload
|
|
216
|
+
def create(
|
|
217
|
+
self,
|
|
218
|
+
*,
|
|
219
|
+
messages: Iterable[ChatMessageInput],
|
|
220
|
+
model: str,
|
|
221
|
+
stream: bool,
|
|
222
|
+
_debug_pro_search: bool | Omit = omit,
|
|
223
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
224
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
225
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
226
|
+
best_of: Optional[int] | Omit = omit,
|
|
227
|
+
country: Optional[str] | Omit = omit,
|
|
228
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
229
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
230
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
231
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
232
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
233
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
234
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
235
|
+
has_image_url: bool | Omit = omit,
|
|
236
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
237
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
238
|
+
language_preference: Optional[str] | Omit = omit,
|
|
239
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
240
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
241
|
+
latitude: Optional[float] | Omit = omit,
|
|
242
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
243
|
+
longitude: Optional[float] | Omit = omit,
|
|
244
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
245
|
+
n: Optional[int] | Omit = omit,
|
|
246
|
+
num_images: int | Omit = omit,
|
|
247
|
+
num_search_results: int | Omit = omit,
|
|
248
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
249
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
250
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
251
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
252
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
253
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
254
|
+
return_images: Optional[bool] | Omit = omit,
|
|
255
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
256
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
257
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
258
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
259
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
260
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
261
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
262
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
263
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
264
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
265
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
266
|
+
temperature: Optional[float] | Omit = omit,
|
|
267
|
+
thread_id: Optional[str] | Omit = omit,
|
|
268
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
269
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
270
|
+
top_k: Optional[int] | Omit = omit,
|
|
271
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
272
|
+
top_p: Optional[float] | Omit = omit,
|
|
273
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
274
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
275
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
276
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
277
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
278
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
279
|
+
extra_headers: Headers | None = None,
|
|
280
|
+
extra_query: Query | None = None,
|
|
281
|
+
extra_body: Body | None = None,
|
|
282
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
283
|
+
) -> StreamChunk | Stream[StreamChunk]:
|
|
284
|
+
"""
|
|
285
|
+
Generate a chat completion response for the given conversation.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
extra_headers: Send extra headers
|
|
289
|
+
|
|
290
|
+
extra_query: Add additional query parameters to the request
|
|
291
|
+
|
|
292
|
+
extra_body: Add additional JSON properties to the request
|
|
293
|
+
|
|
294
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
295
|
+
"""
|
|
296
|
+
...
|
|
297
|
+
|
|
298
|
+
@required_args(["messages", "model"], ["messages", "model", "stream"])
|
|
299
|
+
def create(
|
|
300
|
+
self,
|
|
301
|
+
*,
|
|
302
|
+
messages: Iterable[ChatMessageInput],
|
|
303
|
+
model: str,
|
|
304
|
+
_debug_pro_search: bool | Omit = omit,
|
|
305
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
306
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
307
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
308
|
+
best_of: Optional[int] | Omit = omit,
|
|
309
|
+
country: Optional[str] | Omit = omit,
|
|
310
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
311
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
312
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
313
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
314
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
315
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
316
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
317
|
+
has_image_url: bool | Omit = omit,
|
|
318
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
319
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
320
|
+
language_preference: Optional[str] | Omit = omit,
|
|
321
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
322
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
323
|
+
latitude: Optional[float] | Omit = omit,
|
|
324
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
325
|
+
longitude: Optional[float] | Omit = omit,
|
|
326
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
327
|
+
n: Optional[int] | Omit = omit,
|
|
328
|
+
num_images: int | Omit = omit,
|
|
329
|
+
num_search_results: int | Omit = omit,
|
|
330
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
331
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
332
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
333
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
334
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
335
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
336
|
+
return_images: Optional[bool] | Omit = omit,
|
|
337
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
338
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
339
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
340
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
341
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
342
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
343
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
344
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
345
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
346
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
347
|
+
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
|
|
348
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
349
|
+
temperature: Optional[float] | Omit = omit,
|
|
350
|
+
thread_id: Optional[str] | Omit = omit,
|
|
351
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
352
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
353
|
+
top_k: Optional[int] | Omit = omit,
|
|
354
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
355
|
+
top_p: Optional[float] | Omit = omit,
|
|
356
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
357
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
358
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
359
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
360
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
361
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
362
|
+
extra_headers: Headers | None = None,
|
|
363
|
+
extra_query: Query | None = None,
|
|
364
|
+
extra_body: Body | None = None,
|
|
365
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
366
|
+
) -> StreamChunk | Stream[StreamChunk]:
|
|
124
367
|
return self._post(
|
|
125
368
|
"/chat/completions",
|
|
126
369
|
body=maybe_transform(
|
|
@@ -143,6 +386,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
143
386
|
"has_image_url": has_image_url,
|
|
144
387
|
"image_domain_filter": image_domain_filter,
|
|
145
388
|
"image_format_filter": image_format_filter,
|
|
389
|
+
"language_preference": language_preference,
|
|
146
390
|
"last_updated_after_filter": last_updated_after_filter,
|
|
147
391
|
"last_updated_before_filter": last_updated_before_filter,
|
|
148
392
|
"latitude": latitude,
|
|
@@ -170,7 +414,9 @@ class CompletionsResource(SyncAPIResource):
|
|
|
170
414
|
"search_tenant": search_tenant,
|
|
171
415
|
"stop": stop,
|
|
172
416
|
"stream": stream,
|
|
417
|
+
"stream_mode": stream_mode,
|
|
173
418
|
"temperature": temperature,
|
|
419
|
+
"thread_id": thread_id,
|
|
174
420
|
"tool_choice": tool_choice,
|
|
175
421
|
"tools": tools,
|
|
176
422
|
"top_k": top_k,
|
|
@@ -178,14 +424,19 @@ class CompletionsResource(SyncAPIResource):
|
|
|
178
424
|
"top_p": top_p,
|
|
179
425
|
"updated_after_timestamp": updated_after_timestamp,
|
|
180
426
|
"updated_before_timestamp": updated_before_timestamp,
|
|
427
|
+
"use_threads": use_threads,
|
|
181
428
|
"web_search_options": web_search_options,
|
|
182
429
|
},
|
|
183
|
-
completion_create_params.
|
|
430
|
+
completion_create_params.CompletionCreateParamsStreaming
|
|
431
|
+
if stream
|
|
432
|
+
else completion_create_params.CompletionCreateParamsNonStreaming,
|
|
184
433
|
),
|
|
185
434
|
options=make_request_options(
|
|
186
435
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
187
436
|
),
|
|
188
|
-
cast_to=
|
|
437
|
+
cast_to=StreamChunk,
|
|
438
|
+
stream=stream or False,
|
|
439
|
+
stream_cls=Stream[StreamChunk],
|
|
189
440
|
)
|
|
190
441
|
|
|
191
442
|
|
|
@@ -209,6 +460,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
209
460
|
"""
|
|
210
461
|
return AsyncCompletionsResourceWithStreamingResponse(self)
|
|
211
462
|
|
|
463
|
+
@overload
|
|
212
464
|
async def create(
|
|
213
465
|
self,
|
|
214
466
|
*,
|
|
@@ -230,6 +482,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
230
482
|
has_image_url: bool | Omit = omit,
|
|
231
483
|
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
232
484
|
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
485
|
+
language_preference: Optional[str] | Omit = omit,
|
|
233
486
|
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
234
487
|
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
235
488
|
latitude: Optional[float] | Omit = omit,
|
|
@@ -256,8 +509,10 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
256
509
|
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
257
510
|
search_tenant: Optional[str] | Omit = omit,
|
|
258
511
|
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
259
|
-
stream: Optional[
|
|
512
|
+
stream: Optional[Literal[False]] | Omit = omit,
|
|
513
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
260
514
|
temperature: Optional[float] | Omit = omit,
|
|
515
|
+
thread_id: Optional[str] | Omit = omit,
|
|
261
516
|
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
262
517
|
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
263
518
|
top_k: Optional[int] | Omit = omit,
|
|
@@ -265,6 +520,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
265
520
|
top_p: Optional[float] | Omit = omit,
|
|
266
521
|
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
267
522
|
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
523
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
268
524
|
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
269
525
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
270
526
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
@@ -272,9 +528,9 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
272
528
|
extra_query: Query | None = None,
|
|
273
529
|
extra_body: Body | None = None,
|
|
274
530
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
275
|
-
) ->
|
|
531
|
+
) -> StreamChunk:
|
|
276
532
|
"""
|
|
277
|
-
|
|
533
|
+
Generate a chat completion response for the given conversation.
|
|
278
534
|
|
|
279
535
|
Args:
|
|
280
536
|
extra_headers: Send extra headers
|
|
@@ -285,6 +541,243 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
285
541
|
|
|
286
542
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
287
543
|
"""
|
|
544
|
+
...
|
|
545
|
+
|
|
546
|
+
@overload
|
|
547
|
+
async def create(
|
|
548
|
+
self,
|
|
549
|
+
*,
|
|
550
|
+
messages: Iterable[ChatMessageInput],
|
|
551
|
+
model: str,
|
|
552
|
+
stream: Literal[True],
|
|
553
|
+
_debug_pro_search: bool | Omit = omit,
|
|
554
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
555
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
556
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
557
|
+
best_of: Optional[int] | Omit = omit,
|
|
558
|
+
country: Optional[str] | Omit = omit,
|
|
559
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
560
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
561
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
562
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
563
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
564
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
565
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
566
|
+
has_image_url: bool | Omit = omit,
|
|
567
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
568
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
569
|
+
language_preference: Optional[str] | Omit = omit,
|
|
570
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
571
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
572
|
+
latitude: Optional[float] | Omit = omit,
|
|
573
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
574
|
+
longitude: Optional[float] | Omit = omit,
|
|
575
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
576
|
+
n: Optional[int] | Omit = omit,
|
|
577
|
+
num_images: int | Omit = omit,
|
|
578
|
+
num_search_results: int | Omit = omit,
|
|
579
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
580
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
581
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
582
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
583
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
584
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
585
|
+
return_images: Optional[bool] | Omit = omit,
|
|
586
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
587
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
588
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
589
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
590
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
591
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
592
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
593
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
594
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
595
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
596
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
597
|
+
temperature: Optional[float] | Omit = omit,
|
|
598
|
+
thread_id: Optional[str] | Omit = omit,
|
|
599
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
600
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
601
|
+
top_k: Optional[int] | Omit = omit,
|
|
602
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
603
|
+
top_p: Optional[float] | Omit = omit,
|
|
604
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
605
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
606
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
607
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
608
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
609
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
610
|
+
extra_headers: Headers | None = None,
|
|
611
|
+
extra_query: Query | None = None,
|
|
612
|
+
extra_body: Body | None = None,
|
|
613
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
614
|
+
) -> AsyncStream[StreamChunk]:
|
|
615
|
+
"""
|
|
616
|
+
Generate a chat completion response for the given conversation.
|
|
617
|
+
|
|
618
|
+
Args:
|
|
619
|
+
extra_headers: Send extra headers
|
|
620
|
+
|
|
621
|
+
extra_query: Add additional query parameters to the request
|
|
622
|
+
|
|
623
|
+
extra_body: Add additional JSON properties to the request
|
|
624
|
+
|
|
625
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
626
|
+
"""
|
|
627
|
+
...
|
|
628
|
+
|
|
629
|
+
@overload
|
|
630
|
+
async def create(
|
|
631
|
+
self,
|
|
632
|
+
*,
|
|
633
|
+
messages: Iterable[ChatMessageInput],
|
|
634
|
+
model: str,
|
|
635
|
+
stream: bool,
|
|
636
|
+
_debug_pro_search: bool | Omit = omit,
|
|
637
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
638
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
639
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
640
|
+
best_of: Optional[int] | Omit = omit,
|
|
641
|
+
country: Optional[str] | Omit = omit,
|
|
642
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
643
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
644
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
645
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
646
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
647
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
648
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
649
|
+
has_image_url: bool | Omit = omit,
|
|
650
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
651
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
652
|
+
language_preference: Optional[str] | Omit = omit,
|
|
653
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
654
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
655
|
+
latitude: Optional[float] | Omit = omit,
|
|
656
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
657
|
+
longitude: Optional[float] | Omit = omit,
|
|
658
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
659
|
+
n: Optional[int] | Omit = omit,
|
|
660
|
+
num_images: int | Omit = omit,
|
|
661
|
+
num_search_results: int | Omit = omit,
|
|
662
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
663
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
664
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
665
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
666
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
667
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
668
|
+
return_images: Optional[bool] | Omit = omit,
|
|
669
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
670
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
671
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
672
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
673
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
674
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
675
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
676
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
677
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
678
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
679
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
680
|
+
temperature: Optional[float] | Omit = omit,
|
|
681
|
+
thread_id: Optional[str] | Omit = omit,
|
|
682
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
683
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
684
|
+
top_k: Optional[int] | Omit = omit,
|
|
685
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
686
|
+
top_p: Optional[float] | Omit = omit,
|
|
687
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
688
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
689
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
690
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
691
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
692
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
693
|
+
extra_headers: Headers | None = None,
|
|
694
|
+
extra_query: Query | None = None,
|
|
695
|
+
extra_body: Body | None = None,
|
|
696
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
697
|
+
) -> StreamChunk | AsyncStream[StreamChunk]:
|
|
698
|
+
"""
|
|
699
|
+
Generate a chat completion response for the given conversation.
|
|
700
|
+
|
|
701
|
+
Args:
|
|
702
|
+
extra_headers: Send extra headers
|
|
703
|
+
|
|
704
|
+
extra_query: Add additional query parameters to the request
|
|
705
|
+
|
|
706
|
+
extra_body: Add additional JSON properties to the request
|
|
707
|
+
|
|
708
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
709
|
+
"""
|
|
710
|
+
...
|
|
711
|
+
|
|
712
|
+
@required_args(["messages", "model"], ["messages", "model", "stream"])
|
|
713
|
+
async def create(
|
|
714
|
+
self,
|
|
715
|
+
*,
|
|
716
|
+
messages: Iterable[ChatMessageInput],
|
|
717
|
+
model: str,
|
|
718
|
+
_debug_pro_search: bool | Omit = omit,
|
|
719
|
+
_inputs: Optional[Iterable[int]] | Omit = omit,
|
|
720
|
+
_is_browser_agent: Optional[bool] | Omit = omit,
|
|
721
|
+
_prompt_token_length: Optional[int] | Omit = omit,
|
|
722
|
+
best_of: Optional[int] | Omit = omit,
|
|
723
|
+
country: Optional[str] | Omit = omit,
|
|
724
|
+
cum_logprobs: Optional[bool] | Omit = omit,
|
|
725
|
+
debug_params: Optional[completion_create_params.DebugParams] | Omit = omit,
|
|
726
|
+
disable_search: Optional[bool] | Omit = omit,
|
|
727
|
+
diverse_first_token: Optional[bool] | Omit = omit,
|
|
728
|
+
enable_search_classifier: Optional[bool] | Omit = omit,
|
|
729
|
+
file_workspace_id: Optional[str] | Omit = omit,
|
|
730
|
+
frequency_penalty: Optional[float] | Omit = omit,
|
|
731
|
+
has_image_url: bool | Omit = omit,
|
|
732
|
+
image_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
733
|
+
image_format_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
734
|
+
language_preference: Optional[str] | Omit = omit,
|
|
735
|
+
last_updated_after_filter: Optional[str] | Omit = omit,
|
|
736
|
+
last_updated_before_filter: Optional[str] | Omit = omit,
|
|
737
|
+
latitude: Optional[float] | Omit = omit,
|
|
738
|
+
logprobs: Optional[bool] | Omit = omit,
|
|
739
|
+
longitude: Optional[float] | Omit = omit,
|
|
740
|
+
max_tokens: Optional[int] | Omit = omit,
|
|
741
|
+
n: Optional[int] | Omit = omit,
|
|
742
|
+
num_images: int | Omit = omit,
|
|
743
|
+
num_search_results: int | Omit = omit,
|
|
744
|
+
parallel_tool_calls: Optional[bool] | Omit = omit,
|
|
745
|
+
presence_penalty: Optional[float] | Omit = omit,
|
|
746
|
+
ranking_model: Optional[str] | Omit = omit,
|
|
747
|
+
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
|
|
748
|
+
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
|
|
749
|
+
response_metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
750
|
+
return_images: Optional[bool] | Omit = omit,
|
|
751
|
+
return_related_questions: Optional[bool] | Omit = omit,
|
|
752
|
+
safe_search: Optional[bool] | Omit = omit,
|
|
753
|
+
search_after_date_filter: Optional[str] | Omit = omit,
|
|
754
|
+
search_before_date_filter: Optional[str] | Omit = omit,
|
|
755
|
+
search_domain_filter: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
756
|
+
search_internal_properties: Optional[Dict[str, object]] | Omit = omit,
|
|
757
|
+
search_mode: Optional[Literal["web", "academic", "sec"]] | Omit = omit,
|
|
758
|
+
search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit,
|
|
759
|
+
search_tenant: Optional[str] | Omit = omit,
|
|
760
|
+
stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
|
|
761
|
+
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
|
|
762
|
+
stream_mode: Literal["full", "concise"] | Omit = omit,
|
|
763
|
+
temperature: Optional[float] | Omit = omit,
|
|
764
|
+
thread_id: Optional[str] | Omit = omit,
|
|
765
|
+
tool_choice: Optional[Literal["none", "auto", "required"]] | Omit = omit,
|
|
766
|
+
tools: Optional[Iterable[completion_create_params.Tool]] | Omit = omit,
|
|
767
|
+
top_k: Optional[int] | Omit = omit,
|
|
768
|
+
top_logprobs: Optional[int] | Omit = omit,
|
|
769
|
+
top_p: Optional[float] | Omit = omit,
|
|
770
|
+
updated_after_timestamp: Optional[int] | Omit = omit,
|
|
771
|
+
updated_before_timestamp: Optional[int] | Omit = omit,
|
|
772
|
+
use_threads: Optional[bool] | Omit = omit,
|
|
773
|
+
web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
|
|
774
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
775
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
776
|
+
extra_headers: Headers | None = None,
|
|
777
|
+
extra_query: Query | None = None,
|
|
778
|
+
extra_body: Body | None = None,
|
|
779
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
780
|
+
) -> StreamChunk | AsyncStream[StreamChunk]:
|
|
288
781
|
return await self._post(
|
|
289
782
|
"/chat/completions",
|
|
290
783
|
body=await async_maybe_transform(
|
|
@@ -307,6 +800,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
307
800
|
"has_image_url": has_image_url,
|
|
308
801
|
"image_domain_filter": image_domain_filter,
|
|
309
802
|
"image_format_filter": image_format_filter,
|
|
803
|
+
"language_preference": language_preference,
|
|
310
804
|
"last_updated_after_filter": last_updated_after_filter,
|
|
311
805
|
"last_updated_before_filter": last_updated_before_filter,
|
|
312
806
|
"latitude": latitude,
|
|
@@ -334,7 +828,9 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
334
828
|
"search_tenant": search_tenant,
|
|
335
829
|
"stop": stop,
|
|
336
830
|
"stream": stream,
|
|
831
|
+
"stream_mode": stream_mode,
|
|
337
832
|
"temperature": temperature,
|
|
833
|
+
"thread_id": thread_id,
|
|
338
834
|
"tool_choice": tool_choice,
|
|
339
835
|
"tools": tools,
|
|
340
836
|
"top_k": top_k,
|
|
@@ -342,14 +838,19 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
342
838
|
"top_p": top_p,
|
|
343
839
|
"updated_after_timestamp": updated_after_timestamp,
|
|
344
840
|
"updated_before_timestamp": updated_before_timestamp,
|
|
841
|
+
"use_threads": use_threads,
|
|
345
842
|
"web_search_options": web_search_options,
|
|
346
843
|
},
|
|
347
|
-
completion_create_params.
|
|
844
|
+
completion_create_params.CompletionCreateParamsStreaming
|
|
845
|
+
if stream
|
|
846
|
+
else completion_create_params.CompletionCreateParamsNonStreaming,
|
|
348
847
|
),
|
|
349
848
|
options=make_request_options(
|
|
350
849
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
351
850
|
),
|
|
352
|
-
cast_to=
|
|
851
|
+
cast_to=StreamChunk,
|
|
852
|
+
stream=stream or False,
|
|
853
|
+
stream_cls=AsyncStream[StreamChunk],
|
|
353
854
|
)
|
|
354
855
|
|
|
355
856
|
|