perplexityai 0.7.2__py3-none-any.whl → 0.9.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 +1 -9
- perplexity/_models.py +10 -4
- perplexity/_version.py +1 -1
- perplexity/resources/__init__.py +0 -14
- perplexity/resources/async_/chat/completions.py +90 -76
- perplexity/resources/chat/completions.py +174 -80
- perplexity/resources/search.py +2 -60
- perplexity/types/__init__.py +4 -5
- perplexity/types/async_/chat/__init__.py +1 -1
- perplexity/types/async_/chat/completion_create_params.py +185 -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 +180 -40
- perplexity/types/chat/completion_create_response.py +13 -10
- 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.2.dist-info → perplexityai-0.9.0.dist-info}/METADATA +4 -4
- {perplexityai-0.7.2.dist-info → perplexityai-0.9.0.dist-info}/RECORD +31 -32
- perplexity/resources/content.py +0 -167
- perplexity/types/async_/chat/completion_list_params.py +0 -15
- perplexity/types/content_create_params.py +0 -14
- perplexity/types/content_create_response.py +0 -29
- perplexity/types/shared/chat_message.py +0 -31
- perplexity/types/shared_params/chat_message.py +0 -31
- {perplexityai-0.7.2.dist-info → perplexityai-0.9.0.dist-info}/WHEEL +0 -0
- {perplexityai-0.7.2.dist-info → perplexityai-0.9.0.dist-info}/licenses/LICENSE +0 -0
perplexity/_client.py
CHANGED
|
@@ -21,7 +21,7 @@ from ._types import (
|
|
|
21
21
|
)
|
|
22
22
|
from ._utils import is_given, get_async_library
|
|
23
23
|
from ._version import __version__
|
|
24
|
-
from .resources import search
|
|
24
|
+
from .resources import search
|
|
25
25
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
26
26
|
from ._exceptions import APIStatusError, PerplexityError
|
|
27
27
|
from ._base_client import (
|
|
@@ -48,7 +48,6 @@ class Perplexity(SyncAPIClient):
|
|
|
48
48
|
chat: chat.ChatResource
|
|
49
49
|
async_: async_.AsyncResource
|
|
50
50
|
search: search.SearchResource
|
|
51
|
-
content: content.ContentResource
|
|
52
51
|
with_raw_response: PerplexityWithRawResponse
|
|
53
52
|
with_streaming_response: PerplexityWithStreamedResponse
|
|
54
53
|
|
|
@@ -109,7 +108,6 @@ class Perplexity(SyncAPIClient):
|
|
|
109
108
|
self.chat = chat.ChatResource(self)
|
|
110
109
|
self.async_ = async_.AsyncResource(self)
|
|
111
110
|
self.search = search.SearchResource(self)
|
|
112
|
-
self.content = content.ContentResource(self)
|
|
113
111
|
self.with_raw_response = PerplexityWithRawResponse(self)
|
|
114
112
|
self.with_streaming_response = PerplexityWithStreamedResponse(self)
|
|
115
113
|
|
|
@@ -222,7 +220,6 @@ class AsyncPerplexity(AsyncAPIClient):
|
|
|
222
220
|
chat: chat.AsyncChatResource
|
|
223
221
|
async_: async_.AsyncAsyncResource
|
|
224
222
|
search: search.AsyncSearchResource
|
|
225
|
-
content: content.AsyncContentResource
|
|
226
223
|
with_raw_response: AsyncPerplexityWithRawResponse
|
|
227
224
|
with_streaming_response: AsyncPerplexityWithStreamedResponse
|
|
228
225
|
|
|
@@ -283,7 +280,6 @@ class AsyncPerplexity(AsyncAPIClient):
|
|
|
283
280
|
self.chat = chat.AsyncChatResource(self)
|
|
284
281
|
self.async_ = async_.AsyncAsyncResource(self)
|
|
285
282
|
self.search = search.AsyncSearchResource(self)
|
|
286
|
-
self.content = content.AsyncContentResource(self)
|
|
287
283
|
self.with_raw_response = AsyncPerplexityWithRawResponse(self)
|
|
288
284
|
self.with_streaming_response = AsyncPerplexityWithStreamedResponse(self)
|
|
289
285
|
|
|
@@ -397,7 +393,6 @@ class PerplexityWithRawResponse:
|
|
|
397
393
|
self.chat = chat.ChatResourceWithRawResponse(client.chat)
|
|
398
394
|
self.async_ = async_.AsyncResourceWithRawResponse(client.async_)
|
|
399
395
|
self.search = search.SearchResourceWithRawResponse(client.search)
|
|
400
|
-
self.content = content.ContentResourceWithRawResponse(client.content)
|
|
401
396
|
|
|
402
397
|
|
|
403
398
|
class AsyncPerplexityWithRawResponse:
|
|
@@ -405,7 +400,6 @@ class AsyncPerplexityWithRawResponse:
|
|
|
405
400
|
self.chat = chat.AsyncChatResourceWithRawResponse(client.chat)
|
|
406
401
|
self.async_ = async_.AsyncAsyncResourceWithRawResponse(client.async_)
|
|
407
402
|
self.search = search.AsyncSearchResourceWithRawResponse(client.search)
|
|
408
|
-
self.content = content.AsyncContentResourceWithRawResponse(client.content)
|
|
409
403
|
|
|
410
404
|
|
|
411
405
|
class PerplexityWithStreamedResponse:
|
|
@@ -413,7 +407,6 @@ class PerplexityWithStreamedResponse:
|
|
|
413
407
|
self.chat = chat.ChatResourceWithStreamingResponse(client.chat)
|
|
414
408
|
self.async_ = async_.AsyncResourceWithStreamingResponse(client.async_)
|
|
415
409
|
self.search = search.SearchResourceWithStreamingResponse(client.search)
|
|
416
|
-
self.content = content.ContentResourceWithStreamingResponse(client.content)
|
|
417
410
|
|
|
418
411
|
|
|
419
412
|
class AsyncPerplexityWithStreamedResponse:
|
|
@@ -421,7 +414,6 @@ class AsyncPerplexityWithStreamedResponse:
|
|
|
421
414
|
self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat)
|
|
422
415
|
self.async_ = async_.AsyncAsyncResourceWithStreamingResponse(client.async_)
|
|
423
416
|
self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
|
|
424
|
-
self.content = content.AsyncContentResourceWithStreamingResponse(client.content)
|
|
425
417
|
|
|
426
418
|
|
|
427
419
|
Client = Perplexity
|
perplexity/_models.py
CHANGED
|
@@ -256,7 +256,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
256
256
|
mode: Literal["json", "python"] | str = "python",
|
|
257
257
|
include: IncEx | None = None,
|
|
258
258
|
exclude: IncEx | None = None,
|
|
259
|
-
by_alias: bool =
|
|
259
|
+
by_alias: bool | None = None,
|
|
260
260
|
exclude_unset: bool = False,
|
|
261
261
|
exclude_defaults: bool = False,
|
|
262
262
|
exclude_none: bool = False,
|
|
@@ -264,6 +264,7 @@ class BaseModel(pydantic.BaseModel):
|
|
|
264
264
|
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
265
265
|
context: dict[str, Any] | None = None,
|
|
266
266
|
serialize_as_any: bool = False,
|
|
267
|
+
fallback: Callable[[Any], Any] | None = None,
|
|
267
268
|
) -> dict[str, Any]:
|
|
268
269
|
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
|
|
269
270
|
|
|
@@ -295,10 +296,12 @@ class BaseModel(pydantic.BaseModel):
|
|
|
295
296
|
raise ValueError("context is only supported in Pydantic v2")
|
|
296
297
|
if serialize_as_any != False:
|
|
297
298
|
raise ValueError("serialize_as_any is only supported in Pydantic v2")
|
|
299
|
+
if fallback is not None:
|
|
300
|
+
raise ValueError("fallback is only supported in Pydantic v2")
|
|
298
301
|
dumped = super().dict( # pyright: ignore[reportDeprecated]
|
|
299
302
|
include=include,
|
|
300
303
|
exclude=exclude,
|
|
301
|
-
by_alias=by_alias,
|
|
304
|
+
by_alias=by_alias if by_alias is not None else False,
|
|
302
305
|
exclude_unset=exclude_unset,
|
|
303
306
|
exclude_defaults=exclude_defaults,
|
|
304
307
|
exclude_none=exclude_none,
|
|
@@ -313,13 +316,14 @@ class BaseModel(pydantic.BaseModel):
|
|
|
313
316
|
indent: int | None = None,
|
|
314
317
|
include: IncEx | None = None,
|
|
315
318
|
exclude: IncEx | None = None,
|
|
316
|
-
by_alias: bool =
|
|
319
|
+
by_alias: bool | None = None,
|
|
317
320
|
exclude_unset: bool = False,
|
|
318
321
|
exclude_defaults: bool = False,
|
|
319
322
|
exclude_none: bool = False,
|
|
320
323
|
round_trip: bool = False,
|
|
321
324
|
warnings: bool | Literal["none", "warn", "error"] = True,
|
|
322
325
|
context: dict[str, Any] | None = None,
|
|
326
|
+
fallback: Callable[[Any], Any] | None = None,
|
|
323
327
|
serialize_as_any: bool = False,
|
|
324
328
|
) -> str:
|
|
325
329
|
"""Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
|
|
@@ -348,11 +352,13 @@ class BaseModel(pydantic.BaseModel):
|
|
|
348
352
|
raise ValueError("context is only supported in Pydantic v2")
|
|
349
353
|
if serialize_as_any != False:
|
|
350
354
|
raise ValueError("serialize_as_any is only supported in Pydantic v2")
|
|
355
|
+
if fallback is not None:
|
|
356
|
+
raise ValueError("fallback is only supported in Pydantic v2")
|
|
351
357
|
return super().json( # type: ignore[reportDeprecated]
|
|
352
358
|
indent=indent,
|
|
353
359
|
include=include,
|
|
354
360
|
exclude=exclude,
|
|
355
|
-
by_alias=by_alias,
|
|
361
|
+
by_alias=by_alias if by_alias is not None else False,
|
|
356
362
|
exclude_unset=exclude_unset,
|
|
357
363
|
exclude_defaults=exclude_defaults,
|
|
358
364
|
exclude_none=exclude_none,
|
perplexity/_version.py
CHANGED
perplexity/resources/__init__.py
CHANGED
|
@@ -24,14 +24,6 @@ from .search import (
|
|
|
24
24
|
SearchResourceWithStreamingResponse,
|
|
25
25
|
AsyncSearchResourceWithStreamingResponse,
|
|
26
26
|
)
|
|
27
|
-
from .content import (
|
|
28
|
-
ContentResource,
|
|
29
|
-
AsyncContentResource,
|
|
30
|
-
ContentResourceWithRawResponse,
|
|
31
|
-
AsyncContentResourceWithRawResponse,
|
|
32
|
-
ContentResourceWithStreamingResponse,
|
|
33
|
-
AsyncContentResourceWithStreamingResponse,
|
|
34
|
-
)
|
|
35
27
|
|
|
36
28
|
__all__ = [
|
|
37
29
|
"ChatResource",
|
|
@@ -52,10 +44,4 @@ __all__ = [
|
|
|
52
44
|
"AsyncSearchResourceWithRawResponse",
|
|
53
45
|
"SearchResourceWithStreamingResponse",
|
|
54
46
|
"AsyncSearchResourceWithStreamingResponse",
|
|
55
|
-
"ContentResource",
|
|
56
|
-
"AsyncContentResource",
|
|
57
|
-
"ContentResourceWithRawResponse",
|
|
58
|
-
"AsyncContentResourceWithRawResponse",
|
|
59
|
-
"ContentResourceWithStreamingResponse",
|
|
60
|
-
"AsyncContentResourceWithStreamingResponse",
|
|
61
47
|
]
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
5
7
|
import httpx
|
|
6
8
|
|
|
7
9
|
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
8
|
-
from ...._utils import maybe_transform, async_maybe_transform
|
|
10
|
+
from ...._utils import maybe_transform, strip_not_given, async_maybe_transform
|
|
9
11
|
from ...._compat import cached_property
|
|
10
12
|
from ...._resource import SyncAPIResource, AsyncAPIResource
|
|
11
13
|
from ...._response import (
|
|
@@ -15,7 +17,7 @@ from ...._response import (
|
|
|
15
17
|
async_to_streamed_response_wrapper,
|
|
16
18
|
)
|
|
17
19
|
from ...._base_client import make_request_options
|
|
18
|
-
from ....types.async_.chat import
|
|
20
|
+
from ....types.async_.chat import completion_get_params, completion_create_params
|
|
19
21
|
from ....types.async_.chat.completion_get_response import CompletionGetResponse
|
|
20
22
|
from ....types.async_.chat.completion_list_response import CompletionListResponse
|
|
21
23
|
from ....types.async_.chat.completion_create_response import CompletionCreateResponse
|
|
@@ -47,6 +49,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
47
49
|
self,
|
|
48
50
|
*,
|
|
49
51
|
request: completion_create_params.Request,
|
|
52
|
+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
|
|
50
53
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
51
54
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
52
55
|
extra_headers: Headers | None = None,
|
|
@@ -55,7 +58,10 @@ class CompletionsResource(SyncAPIResource):
|
|
|
55
58
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
56
59
|
) -> CompletionCreateResponse:
|
|
57
60
|
"""
|
|
58
|
-
|
|
61
|
+
FastAPI wrapper around async chat completions
|
|
62
|
+
|
|
63
|
+
This endpoint creates an asynchronous chat completion job and returns a job ID
|
|
64
|
+
that can be used to poll for results.
|
|
59
65
|
|
|
60
66
|
Args:
|
|
61
67
|
extra_headers: Send extra headers
|
|
@@ -68,7 +74,13 @@ class CompletionsResource(SyncAPIResource):
|
|
|
68
74
|
"""
|
|
69
75
|
return self._post(
|
|
70
76
|
"/async/chat/completions",
|
|
71
|
-
body=maybe_transform(
|
|
77
|
+
body=maybe_transform(
|
|
78
|
+
{
|
|
79
|
+
"request": request,
|
|
80
|
+
"idempotency_key": idempotency_key,
|
|
81
|
+
},
|
|
82
|
+
completion_create_params.CompletionCreateParams,
|
|
83
|
+
),
|
|
72
84
|
options=make_request_options(
|
|
73
85
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
74
86
|
),
|
|
@@ -78,8 +90,6 @@ class CompletionsResource(SyncAPIResource):
|
|
|
78
90
|
def list(
|
|
79
91
|
self,
|
|
80
92
|
*,
|
|
81
|
-
limit: int | NotGiven = NOT_GIVEN,
|
|
82
|
-
next_token: str | NotGiven = NOT_GIVEN,
|
|
83
93
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
84
94
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
85
95
|
extra_headers: Headers | None = None,
|
|
@@ -87,44 +97,25 @@ class CompletionsResource(SyncAPIResource):
|
|
|
87
97
|
extra_body: Body | None = None,
|
|
88
98
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
89
99
|
) -> CompletionListResponse:
|
|
90
|
-
"""
|
|
91
|
-
Lists all asynchronous chat completion requests for the authenticated user
|
|
92
|
-
|
|
93
|
-
Args:
|
|
94
|
-
limit: Maximum number of requests to return
|
|
95
|
-
|
|
96
|
-
next_token: Token for fetching the next page of results
|
|
97
|
-
|
|
98
|
-
extra_headers: Send extra headers
|
|
99
|
-
|
|
100
|
-
extra_query: Add additional query parameters to the request
|
|
101
|
-
|
|
102
|
-
extra_body: Add additional JSON properties to the request
|
|
103
|
-
|
|
104
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
105
|
-
"""
|
|
100
|
+
"""list all async chat completion requests for a given user."""
|
|
106
101
|
return self._get(
|
|
107
102
|
"/async/chat/completions",
|
|
108
103
|
options=make_request_options(
|
|
109
|
-
extra_headers=extra_headers,
|
|
110
|
-
extra_query=extra_query,
|
|
111
|
-
extra_body=extra_body,
|
|
112
|
-
timeout=timeout,
|
|
113
|
-
query=maybe_transform(
|
|
114
|
-
{
|
|
115
|
-
"limit": limit,
|
|
116
|
-
"next_token": next_token,
|
|
117
|
-
},
|
|
118
|
-
completion_list_params.CompletionListParams,
|
|
119
|
-
),
|
|
104
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
120
105
|
),
|
|
121
106
|
cast_to=CompletionListResponse,
|
|
122
107
|
)
|
|
123
108
|
|
|
124
109
|
def get(
|
|
125
110
|
self,
|
|
126
|
-
|
|
111
|
+
api_request: str,
|
|
127
112
|
*,
|
|
113
|
+
local_mode: bool | NotGiven = NOT_GIVEN,
|
|
114
|
+
x_client_env: str | NotGiven = NOT_GIVEN,
|
|
115
|
+
x_client_name: str | NotGiven = NOT_GIVEN,
|
|
116
|
+
x_request_time: str | NotGiven = NOT_GIVEN,
|
|
117
|
+
x_usage_tier: str | NotGiven = NOT_GIVEN,
|
|
118
|
+
x_user_id: str | NotGiven = NOT_GIVEN,
|
|
128
119
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
129
120
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
130
121
|
extra_headers: Headers | None = None,
|
|
@@ -133,7 +124,7 @@ class CompletionsResource(SyncAPIResource):
|
|
|
133
124
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
134
125
|
) -> CompletionGetResponse:
|
|
135
126
|
"""
|
|
136
|
-
|
|
127
|
+
get the response for a given async chat completion request.
|
|
137
128
|
|
|
138
129
|
Args:
|
|
139
130
|
extra_headers: Send extra headers
|
|
@@ -144,12 +135,28 @@ class CompletionsResource(SyncAPIResource):
|
|
|
144
135
|
|
|
145
136
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
146
137
|
"""
|
|
147
|
-
if not
|
|
148
|
-
raise ValueError(f"Expected a non-empty value for `
|
|
138
|
+
if not api_request:
|
|
139
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
140
|
+
extra_headers = {
|
|
141
|
+
**strip_not_given(
|
|
142
|
+
{
|
|
143
|
+
"x-client-env": x_client_env,
|
|
144
|
+
"x-client-name": x_client_name,
|
|
145
|
+
"x-request-time": x_request_time,
|
|
146
|
+
"x-usage-tier": x_usage_tier,
|
|
147
|
+
"x-user-id": x_user_id,
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
**(extra_headers or {}),
|
|
151
|
+
}
|
|
149
152
|
return self._get(
|
|
150
|
-
f"/async/chat/completions/{
|
|
153
|
+
f"/async/chat/completions/{api_request}",
|
|
151
154
|
options=make_request_options(
|
|
152
|
-
extra_headers=extra_headers,
|
|
155
|
+
extra_headers=extra_headers,
|
|
156
|
+
extra_query=extra_query,
|
|
157
|
+
extra_body=extra_body,
|
|
158
|
+
timeout=timeout,
|
|
159
|
+
query=maybe_transform({"local_mode": local_mode}, completion_get_params.CompletionGetParams),
|
|
153
160
|
),
|
|
154
161
|
cast_to=CompletionGetResponse,
|
|
155
162
|
)
|
|
@@ -179,6 +186,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
179
186
|
self,
|
|
180
187
|
*,
|
|
181
188
|
request: completion_create_params.Request,
|
|
189
|
+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
|
|
182
190
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
183
191
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
184
192
|
extra_headers: Headers | None = None,
|
|
@@ -187,7 +195,10 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
187
195
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
188
196
|
) -> CompletionCreateResponse:
|
|
189
197
|
"""
|
|
190
|
-
|
|
198
|
+
FastAPI wrapper around async chat completions
|
|
199
|
+
|
|
200
|
+
This endpoint creates an asynchronous chat completion job and returns a job ID
|
|
201
|
+
that can be used to poll for results.
|
|
191
202
|
|
|
192
203
|
Args:
|
|
193
204
|
extra_headers: Send extra headers
|
|
@@ -200,7 +211,13 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
200
211
|
"""
|
|
201
212
|
return await self._post(
|
|
202
213
|
"/async/chat/completions",
|
|
203
|
-
body=await async_maybe_transform(
|
|
214
|
+
body=await async_maybe_transform(
|
|
215
|
+
{
|
|
216
|
+
"request": request,
|
|
217
|
+
"idempotency_key": idempotency_key,
|
|
218
|
+
},
|
|
219
|
+
completion_create_params.CompletionCreateParams,
|
|
220
|
+
),
|
|
204
221
|
options=make_request_options(
|
|
205
222
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
206
223
|
),
|
|
@@ -210,8 +227,6 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
210
227
|
async def list(
|
|
211
228
|
self,
|
|
212
229
|
*,
|
|
213
|
-
limit: int | NotGiven = NOT_GIVEN,
|
|
214
|
-
next_token: str | NotGiven = NOT_GIVEN,
|
|
215
230
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
216
231
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
217
232
|
extra_headers: Headers | None = None,
|
|
@@ -219,44 +234,25 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
219
234
|
extra_body: Body | None = None,
|
|
220
235
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
221
236
|
) -> CompletionListResponse:
|
|
222
|
-
"""
|
|
223
|
-
Lists all asynchronous chat completion requests for the authenticated user
|
|
224
|
-
|
|
225
|
-
Args:
|
|
226
|
-
limit: Maximum number of requests to return
|
|
227
|
-
|
|
228
|
-
next_token: Token for fetching the next page of results
|
|
229
|
-
|
|
230
|
-
extra_headers: Send extra headers
|
|
231
|
-
|
|
232
|
-
extra_query: Add additional query parameters to the request
|
|
233
|
-
|
|
234
|
-
extra_body: Add additional JSON properties to the request
|
|
235
|
-
|
|
236
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
237
|
-
"""
|
|
237
|
+
"""list all async chat completion requests for a given user."""
|
|
238
238
|
return await self._get(
|
|
239
239
|
"/async/chat/completions",
|
|
240
240
|
options=make_request_options(
|
|
241
|
-
extra_headers=extra_headers,
|
|
242
|
-
extra_query=extra_query,
|
|
243
|
-
extra_body=extra_body,
|
|
244
|
-
timeout=timeout,
|
|
245
|
-
query=await async_maybe_transform(
|
|
246
|
-
{
|
|
247
|
-
"limit": limit,
|
|
248
|
-
"next_token": next_token,
|
|
249
|
-
},
|
|
250
|
-
completion_list_params.CompletionListParams,
|
|
251
|
-
),
|
|
241
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
252
242
|
),
|
|
253
243
|
cast_to=CompletionListResponse,
|
|
254
244
|
)
|
|
255
245
|
|
|
256
246
|
async def get(
|
|
257
247
|
self,
|
|
258
|
-
|
|
248
|
+
api_request: str,
|
|
259
249
|
*,
|
|
250
|
+
local_mode: bool | NotGiven = NOT_GIVEN,
|
|
251
|
+
x_client_env: str | NotGiven = NOT_GIVEN,
|
|
252
|
+
x_client_name: str | NotGiven = NOT_GIVEN,
|
|
253
|
+
x_request_time: str | NotGiven = NOT_GIVEN,
|
|
254
|
+
x_usage_tier: str | NotGiven = NOT_GIVEN,
|
|
255
|
+
x_user_id: str | NotGiven = NOT_GIVEN,
|
|
260
256
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
261
257
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
262
258
|
extra_headers: Headers | None = None,
|
|
@@ -265,7 +261,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
265
261
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
266
262
|
) -> CompletionGetResponse:
|
|
267
263
|
"""
|
|
268
|
-
|
|
264
|
+
get the response for a given async chat completion request.
|
|
269
265
|
|
|
270
266
|
Args:
|
|
271
267
|
extra_headers: Send extra headers
|
|
@@ -276,12 +272,30 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
276
272
|
|
|
277
273
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
278
274
|
"""
|
|
279
|
-
if not
|
|
280
|
-
raise ValueError(f"Expected a non-empty value for `
|
|
275
|
+
if not api_request:
|
|
276
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
277
|
+
extra_headers = {
|
|
278
|
+
**strip_not_given(
|
|
279
|
+
{
|
|
280
|
+
"x-client-env": x_client_env,
|
|
281
|
+
"x-client-name": x_client_name,
|
|
282
|
+
"x-request-time": x_request_time,
|
|
283
|
+
"x-usage-tier": x_usage_tier,
|
|
284
|
+
"x-user-id": x_user_id,
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
**(extra_headers or {}),
|
|
288
|
+
}
|
|
281
289
|
return await self._get(
|
|
282
|
-
f"/async/chat/completions/{
|
|
290
|
+
f"/async/chat/completions/{api_request}",
|
|
283
291
|
options=make_request_options(
|
|
284
|
-
extra_headers=extra_headers,
|
|
292
|
+
extra_headers=extra_headers,
|
|
293
|
+
extra_query=extra_query,
|
|
294
|
+
extra_body=extra_body,
|
|
295
|
+
timeout=timeout,
|
|
296
|
+
query=await async_maybe_transform(
|
|
297
|
+
{"local_mode": local_mode}, completion_get_params.CompletionGetParams
|
|
298
|
+
),
|
|
285
299
|
),
|
|
286
300
|
cast_to=CompletionGetResponse,
|
|
287
301
|
)
|