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.
- perplexity/__init__.py +102 -0
- perplexity/_base_client.py +2001 -0
- perplexity/_client.py +529 -0
- perplexity/_compat.py +219 -0
- perplexity/_constants.py +14 -0
- perplexity/_exceptions.py +108 -0
- perplexity/_files.py +123 -0
- perplexity/_models.py +857 -0
- perplexity/_qs.py +150 -0
- perplexity/_resource.py +43 -0
- perplexity/_response.py +832 -0
- perplexity/_streaming.py +371 -0
- perplexity/_types.py +261 -0
- perplexity/_utils/__init__.py +64 -0
- perplexity/_utils/_compat.py +45 -0
- perplexity/_utils/_datetime_parse.py +136 -0
- perplexity/_utils/_logs.py +25 -0
- perplexity/_utils/_proxy.py +65 -0
- perplexity/_utils/_reflection.py +42 -0
- perplexity/_utils/_resources_proxy.py +24 -0
- perplexity/_utils/_streams.py +12 -0
- perplexity/_utils/_sync.py +58 -0
- perplexity/_utils/_transform.py +457 -0
- perplexity/_utils/_typing.py +156 -0
- perplexity/_utils/_utils.py +421 -0
- perplexity/_version.py +4 -0
- perplexity/lib/.keep +4 -0
- perplexity/py.typed +0 -0
- perplexity/resources/__init__.py +47 -0
- perplexity/resources/async_/__init__.py +33 -0
- perplexity/resources/async_/async_.py +102 -0
- perplexity/resources/async_/chat/__init__.py +33 -0
- perplexity/resources/async_/chat/chat.py +102 -0
- perplexity/resources/async_/chat/completions.py +359 -0
- perplexity/resources/chat/__init__.py +33 -0
- perplexity/resources/chat/chat.py +102 -0
- perplexity/resources/chat/completions.py +900 -0
- perplexity/resources/search.py +228 -0
- perplexity/types/__init__.py +14 -0
- perplexity/types/async_/__init__.py +3 -0
- perplexity/types/async_/chat/__init__.py +9 -0
- perplexity/types/async_/chat/completion_create_params.py +242 -0
- perplexity/types/async_/chat/completion_create_response.py +30 -0
- perplexity/types/async_/chat/completion_get_params.py +25 -0
- perplexity/types/async_/chat/completion_get_response.py +30 -0
- perplexity/types/async_/chat/completion_list_response.py +31 -0
- perplexity/types/chat/__init__.py +5 -0
- perplexity/types/chat/completion_create_params.py +244 -0
- perplexity/types/search_create_params.py +40 -0
- perplexity/types/search_create_response.py +27 -0
- perplexity/types/shared/__init__.py +7 -0
- perplexity/types/shared/api_public_search_result.py +22 -0
- perplexity/types/shared/chat_message_input.py +176 -0
- perplexity/types/shared/chat_message_output.py +176 -0
- perplexity/types/shared/choice.py +19 -0
- perplexity/types/shared/usage_info.py +41 -0
- perplexity/types/shared_params/__init__.py +4 -0
- perplexity/types/shared_params/api_public_search_result.py +22 -0
- perplexity/types/shared_params/chat_message_input.py +178 -0
- perplexity/types/stream_chunk.py +33 -0
- perplexityai-0.22.3.dist-info/METADATA +548 -0
- perplexityai-0.22.3.dist-info/RECORD +64 -0
- perplexityai-0.22.3.dist-info/WHEEL +4 -0
- perplexityai-0.22.3.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from ...._compat import cached_property
|
|
6
|
+
from .completions import (
|
|
7
|
+
CompletionsResource,
|
|
8
|
+
AsyncCompletionsResource,
|
|
9
|
+
CompletionsResourceWithRawResponse,
|
|
10
|
+
AsyncCompletionsResourceWithRawResponse,
|
|
11
|
+
CompletionsResourceWithStreamingResponse,
|
|
12
|
+
AsyncCompletionsResourceWithStreamingResponse,
|
|
13
|
+
)
|
|
14
|
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
|
15
|
+
|
|
16
|
+
__all__ = ["ChatResource", "AsyncChatResource"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ChatResource(SyncAPIResource):
|
|
20
|
+
@cached_property
|
|
21
|
+
def completions(self) -> CompletionsResource:
|
|
22
|
+
return CompletionsResource(self._client)
|
|
23
|
+
|
|
24
|
+
@cached_property
|
|
25
|
+
def with_raw_response(self) -> ChatResourceWithRawResponse:
|
|
26
|
+
"""
|
|
27
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
28
|
+
the raw response object instead of the parsed content.
|
|
29
|
+
|
|
30
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
31
|
+
"""
|
|
32
|
+
return ChatResourceWithRawResponse(self)
|
|
33
|
+
|
|
34
|
+
@cached_property
|
|
35
|
+
def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
|
|
36
|
+
"""
|
|
37
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
38
|
+
|
|
39
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
40
|
+
"""
|
|
41
|
+
return ChatResourceWithStreamingResponse(self)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class AsyncChatResource(AsyncAPIResource):
|
|
45
|
+
@cached_property
|
|
46
|
+
def completions(self) -> AsyncCompletionsResource:
|
|
47
|
+
return AsyncCompletionsResource(self._client)
|
|
48
|
+
|
|
49
|
+
@cached_property
|
|
50
|
+
def with_raw_response(self) -> AsyncChatResourceWithRawResponse:
|
|
51
|
+
"""
|
|
52
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
53
|
+
the raw response object instead of the parsed content.
|
|
54
|
+
|
|
55
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
56
|
+
"""
|
|
57
|
+
return AsyncChatResourceWithRawResponse(self)
|
|
58
|
+
|
|
59
|
+
@cached_property
|
|
60
|
+
def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
|
|
61
|
+
"""
|
|
62
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
63
|
+
|
|
64
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
65
|
+
"""
|
|
66
|
+
return AsyncChatResourceWithStreamingResponse(self)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ChatResourceWithRawResponse:
|
|
70
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
71
|
+
self._chat = chat
|
|
72
|
+
|
|
73
|
+
@cached_property
|
|
74
|
+
def completions(self) -> CompletionsResourceWithRawResponse:
|
|
75
|
+
return CompletionsResourceWithRawResponse(self._chat.completions)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class AsyncChatResourceWithRawResponse:
|
|
79
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
80
|
+
self._chat = chat
|
|
81
|
+
|
|
82
|
+
@cached_property
|
|
83
|
+
def completions(self) -> AsyncCompletionsResourceWithRawResponse:
|
|
84
|
+
return AsyncCompletionsResourceWithRawResponse(self._chat.completions)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ChatResourceWithStreamingResponse:
|
|
88
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
89
|
+
self._chat = chat
|
|
90
|
+
|
|
91
|
+
@cached_property
|
|
92
|
+
def completions(self) -> CompletionsResourceWithStreamingResponse:
|
|
93
|
+
return CompletionsResourceWithStreamingResponse(self._chat.completions)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AsyncChatResourceWithStreamingResponse:
|
|
97
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
98
|
+
self._chat = chat
|
|
99
|
+
|
|
100
|
+
@cached_property
|
|
101
|
+
def completions(self) -> AsyncCompletionsResourceWithStreamingResponse:
|
|
102
|
+
return AsyncCompletionsResourceWithStreamingResponse(self._chat.completions)
|
|
@@ -0,0 +1,359 @@
|
|
|
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
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
10
|
+
from ...._utils import maybe_transform, strip_not_given, async_maybe_transform
|
|
11
|
+
from ...._compat import cached_property
|
|
12
|
+
from ...._resource import SyncAPIResource, AsyncAPIResource
|
|
13
|
+
from ...._response import (
|
|
14
|
+
to_raw_response_wrapper,
|
|
15
|
+
to_streamed_response_wrapper,
|
|
16
|
+
async_to_raw_response_wrapper,
|
|
17
|
+
async_to_streamed_response_wrapper,
|
|
18
|
+
)
|
|
19
|
+
from ...._base_client import make_request_options
|
|
20
|
+
from ....types.async_.chat import completion_get_params, completion_create_params
|
|
21
|
+
from ....types.async_.chat.completion_get_response import CompletionGetResponse
|
|
22
|
+
from ....types.async_.chat.completion_list_response import CompletionListResponse
|
|
23
|
+
from ....types.async_.chat.completion_create_response import CompletionCreateResponse
|
|
24
|
+
|
|
25
|
+
__all__ = ["CompletionsResource", "AsyncCompletionsResource"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CompletionsResource(SyncAPIResource):
|
|
29
|
+
@cached_property
|
|
30
|
+
def with_raw_response(self) -> CompletionsResourceWithRawResponse:
|
|
31
|
+
"""
|
|
32
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
33
|
+
the raw response object instead of the parsed content.
|
|
34
|
+
|
|
35
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
36
|
+
"""
|
|
37
|
+
return CompletionsResourceWithRawResponse(self)
|
|
38
|
+
|
|
39
|
+
@cached_property
|
|
40
|
+
def with_streaming_response(self) -> CompletionsResourceWithStreamingResponse:
|
|
41
|
+
"""
|
|
42
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
43
|
+
|
|
44
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
45
|
+
"""
|
|
46
|
+
return CompletionsResourceWithStreamingResponse(self)
|
|
47
|
+
|
|
48
|
+
def create(
|
|
49
|
+
self,
|
|
50
|
+
*,
|
|
51
|
+
request: completion_create_params.Request,
|
|
52
|
+
idempotency_key: Optional[str] | Omit = omit,
|
|
53
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
54
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
55
|
+
extra_headers: Headers | None = None,
|
|
56
|
+
extra_query: Query | None = None,
|
|
57
|
+
extra_body: Body | None = None,
|
|
58
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
59
|
+
) -> CompletionCreateResponse:
|
|
60
|
+
"""
|
|
61
|
+
Submit an asynchronous chat completion request.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
extra_headers: Send extra headers
|
|
65
|
+
|
|
66
|
+
extra_query: Add additional query parameters to the request
|
|
67
|
+
|
|
68
|
+
extra_body: Add additional JSON properties to the request
|
|
69
|
+
|
|
70
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
71
|
+
"""
|
|
72
|
+
return self._post(
|
|
73
|
+
"/async/chat/completions",
|
|
74
|
+
body=maybe_transform(
|
|
75
|
+
{
|
|
76
|
+
"request": request,
|
|
77
|
+
"idempotency_key": idempotency_key,
|
|
78
|
+
},
|
|
79
|
+
completion_create_params.CompletionCreateParams,
|
|
80
|
+
),
|
|
81
|
+
options=make_request_options(
|
|
82
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
83
|
+
),
|
|
84
|
+
cast_to=CompletionCreateResponse,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def list(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
91
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
92
|
+
extra_headers: Headers | None = None,
|
|
93
|
+
extra_query: Query | None = None,
|
|
94
|
+
extra_body: Body | None = None,
|
|
95
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
96
|
+
) -> CompletionListResponse:
|
|
97
|
+
"""Retrieve a list of all asynchronous chat completion requests for a given user."""
|
|
98
|
+
return self._get(
|
|
99
|
+
"/async/chat/completions",
|
|
100
|
+
options=make_request_options(
|
|
101
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
102
|
+
),
|
|
103
|
+
cast_to=CompletionListResponse,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def get(
|
|
107
|
+
self,
|
|
108
|
+
api_request: str,
|
|
109
|
+
*,
|
|
110
|
+
local_mode: bool | Omit = omit,
|
|
111
|
+
x_client_env: str | Omit = omit,
|
|
112
|
+
x_client_name: str | Omit = omit,
|
|
113
|
+
x_created_at_epoch_seconds: str | Omit = omit,
|
|
114
|
+
x_request_time: str | Omit = omit,
|
|
115
|
+
x_usage_tier: str | Omit = omit,
|
|
116
|
+
x_user_id: str | Omit = omit,
|
|
117
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
118
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
119
|
+
extra_headers: Headers | None = None,
|
|
120
|
+
extra_query: Query | None = None,
|
|
121
|
+
extra_body: Body | None = None,
|
|
122
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
123
|
+
) -> CompletionGetResponse:
|
|
124
|
+
"""
|
|
125
|
+
Retrieve the response for a given asynchronous chat completion request.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
extra_headers: Send extra headers
|
|
129
|
+
|
|
130
|
+
extra_query: Add additional query parameters to the request
|
|
131
|
+
|
|
132
|
+
extra_body: Add additional JSON properties to the request
|
|
133
|
+
|
|
134
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
135
|
+
"""
|
|
136
|
+
if not api_request:
|
|
137
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
138
|
+
extra_headers = {
|
|
139
|
+
**strip_not_given(
|
|
140
|
+
{
|
|
141
|
+
"x-client-env": x_client_env,
|
|
142
|
+
"x-client-name": x_client_name,
|
|
143
|
+
"x-created-at-epoch-seconds": x_created_at_epoch_seconds,
|
|
144
|
+
"x-request-time": x_request_time,
|
|
145
|
+
"x-usage-tier": x_usage_tier,
|
|
146
|
+
"x-user-id": x_user_id,
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
**(extra_headers or {}),
|
|
150
|
+
}
|
|
151
|
+
return self._get(
|
|
152
|
+
f"/async/chat/completions/{api_request}",
|
|
153
|
+
options=make_request_options(
|
|
154
|
+
extra_headers=extra_headers,
|
|
155
|
+
extra_query=extra_query,
|
|
156
|
+
extra_body=extra_body,
|
|
157
|
+
timeout=timeout,
|
|
158
|
+
query=maybe_transform({"local_mode": local_mode}, completion_get_params.CompletionGetParams),
|
|
159
|
+
),
|
|
160
|
+
cast_to=CompletionGetResponse,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class AsyncCompletionsResource(AsyncAPIResource):
|
|
165
|
+
@cached_property
|
|
166
|
+
def with_raw_response(self) -> AsyncCompletionsResourceWithRawResponse:
|
|
167
|
+
"""
|
|
168
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
169
|
+
the raw response object instead of the parsed content.
|
|
170
|
+
|
|
171
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
172
|
+
"""
|
|
173
|
+
return AsyncCompletionsResourceWithRawResponse(self)
|
|
174
|
+
|
|
175
|
+
@cached_property
|
|
176
|
+
def with_streaming_response(self) -> AsyncCompletionsResourceWithStreamingResponse:
|
|
177
|
+
"""
|
|
178
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
179
|
+
|
|
180
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
181
|
+
"""
|
|
182
|
+
return AsyncCompletionsResourceWithStreamingResponse(self)
|
|
183
|
+
|
|
184
|
+
async def create(
|
|
185
|
+
self,
|
|
186
|
+
*,
|
|
187
|
+
request: completion_create_params.Request,
|
|
188
|
+
idempotency_key: Optional[str] | Omit = omit,
|
|
189
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
190
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
191
|
+
extra_headers: Headers | None = None,
|
|
192
|
+
extra_query: Query | None = None,
|
|
193
|
+
extra_body: Body | None = None,
|
|
194
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
195
|
+
) -> CompletionCreateResponse:
|
|
196
|
+
"""
|
|
197
|
+
Submit an asynchronous chat completion request.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
extra_headers: Send extra headers
|
|
201
|
+
|
|
202
|
+
extra_query: Add additional query parameters to the request
|
|
203
|
+
|
|
204
|
+
extra_body: Add additional JSON properties to the request
|
|
205
|
+
|
|
206
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
207
|
+
"""
|
|
208
|
+
return await self._post(
|
|
209
|
+
"/async/chat/completions",
|
|
210
|
+
body=await async_maybe_transform(
|
|
211
|
+
{
|
|
212
|
+
"request": request,
|
|
213
|
+
"idempotency_key": idempotency_key,
|
|
214
|
+
},
|
|
215
|
+
completion_create_params.CompletionCreateParams,
|
|
216
|
+
),
|
|
217
|
+
options=make_request_options(
|
|
218
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
219
|
+
),
|
|
220
|
+
cast_to=CompletionCreateResponse,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
async def list(
|
|
224
|
+
self,
|
|
225
|
+
*,
|
|
226
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
227
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
228
|
+
extra_headers: Headers | None = None,
|
|
229
|
+
extra_query: Query | None = None,
|
|
230
|
+
extra_body: Body | None = None,
|
|
231
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
232
|
+
) -> CompletionListResponse:
|
|
233
|
+
"""Retrieve a list of all asynchronous chat completion requests for a given user."""
|
|
234
|
+
return await self._get(
|
|
235
|
+
"/async/chat/completions",
|
|
236
|
+
options=make_request_options(
|
|
237
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
238
|
+
),
|
|
239
|
+
cast_to=CompletionListResponse,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
async def get(
|
|
243
|
+
self,
|
|
244
|
+
api_request: str,
|
|
245
|
+
*,
|
|
246
|
+
local_mode: bool | Omit = omit,
|
|
247
|
+
x_client_env: str | Omit = omit,
|
|
248
|
+
x_client_name: str | Omit = omit,
|
|
249
|
+
x_created_at_epoch_seconds: str | Omit = omit,
|
|
250
|
+
x_request_time: str | Omit = omit,
|
|
251
|
+
x_usage_tier: str | Omit = omit,
|
|
252
|
+
x_user_id: str | Omit = omit,
|
|
253
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
254
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
255
|
+
extra_headers: Headers | None = None,
|
|
256
|
+
extra_query: Query | None = None,
|
|
257
|
+
extra_body: Body | None = None,
|
|
258
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
259
|
+
) -> CompletionGetResponse:
|
|
260
|
+
"""
|
|
261
|
+
Retrieve the response for a given asynchronous chat completion request.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
extra_headers: Send extra headers
|
|
265
|
+
|
|
266
|
+
extra_query: Add additional query parameters to the request
|
|
267
|
+
|
|
268
|
+
extra_body: Add additional JSON properties to the request
|
|
269
|
+
|
|
270
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
271
|
+
"""
|
|
272
|
+
if not api_request:
|
|
273
|
+
raise ValueError(f"Expected a non-empty value for `api_request` but received {api_request!r}")
|
|
274
|
+
extra_headers = {
|
|
275
|
+
**strip_not_given(
|
|
276
|
+
{
|
|
277
|
+
"x-client-env": x_client_env,
|
|
278
|
+
"x-client-name": x_client_name,
|
|
279
|
+
"x-created-at-epoch-seconds": x_created_at_epoch_seconds,
|
|
280
|
+
"x-request-time": x_request_time,
|
|
281
|
+
"x-usage-tier": x_usage_tier,
|
|
282
|
+
"x-user-id": x_user_id,
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
**(extra_headers or {}),
|
|
286
|
+
}
|
|
287
|
+
return await self._get(
|
|
288
|
+
f"/async/chat/completions/{api_request}",
|
|
289
|
+
options=make_request_options(
|
|
290
|
+
extra_headers=extra_headers,
|
|
291
|
+
extra_query=extra_query,
|
|
292
|
+
extra_body=extra_body,
|
|
293
|
+
timeout=timeout,
|
|
294
|
+
query=await async_maybe_transform(
|
|
295
|
+
{"local_mode": local_mode}, completion_get_params.CompletionGetParams
|
|
296
|
+
),
|
|
297
|
+
),
|
|
298
|
+
cast_to=CompletionGetResponse,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class CompletionsResourceWithRawResponse:
|
|
303
|
+
def __init__(self, completions: CompletionsResource) -> None:
|
|
304
|
+
self._completions = completions
|
|
305
|
+
|
|
306
|
+
self.create = to_raw_response_wrapper(
|
|
307
|
+
completions.create,
|
|
308
|
+
)
|
|
309
|
+
self.list = to_raw_response_wrapper(
|
|
310
|
+
completions.list,
|
|
311
|
+
)
|
|
312
|
+
self.get = to_raw_response_wrapper(
|
|
313
|
+
completions.get,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class AsyncCompletionsResourceWithRawResponse:
|
|
318
|
+
def __init__(self, completions: AsyncCompletionsResource) -> None:
|
|
319
|
+
self._completions = completions
|
|
320
|
+
|
|
321
|
+
self.create = async_to_raw_response_wrapper(
|
|
322
|
+
completions.create,
|
|
323
|
+
)
|
|
324
|
+
self.list = async_to_raw_response_wrapper(
|
|
325
|
+
completions.list,
|
|
326
|
+
)
|
|
327
|
+
self.get = async_to_raw_response_wrapper(
|
|
328
|
+
completions.get,
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
class CompletionsResourceWithStreamingResponse:
|
|
333
|
+
def __init__(self, completions: CompletionsResource) -> None:
|
|
334
|
+
self._completions = completions
|
|
335
|
+
|
|
336
|
+
self.create = to_streamed_response_wrapper(
|
|
337
|
+
completions.create,
|
|
338
|
+
)
|
|
339
|
+
self.list = to_streamed_response_wrapper(
|
|
340
|
+
completions.list,
|
|
341
|
+
)
|
|
342
|
+
self.get = to_streamed_response_wrapper(
|
|
343
|
+
completions.get,
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
class AsyncCompletionsResourceWithStreamingResponse:
|
|
348
|
+
def __init__(self, completions: AsyncCompletionsResource) -> None:
|
|
349
|
+
self._completions = completions
|
|
350
|
+
|
|
351
|
+
self.create = async_to_streamed_response_wrapper(
|
|
352
|
+
completions.create,
|
|
353
|
+
)
|
|
354
|
+
self.list = async_to_streamed_response_wrapper(
|
|
355
|
+
completions.list,
|
|
356
|
+
)
|
|
357
|
+
self.get = async_to_streamed_response_wrapper(
|
|
358
|
+
completions.get,
|
|
359
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from .chat import (
|
|
4
|
+
ChatResource,
|
|
5
|
+
AsyncChatResource,
|
|
6
|
+
ChatResourceWithRawResponse,
|
|
7
|
+
AsyncChatResourceWithRawResponse,
|
|
8
|
+
ChatResourceWithStreamingResponse,
|
|
9
|
+
AsyncChatResourceWithStreamingResponse,
|
|
10
|
+
)
|
|
11
|
+
from .completions import (
|
|
12
|
+
CompletionsResource,
|
|
13
|
+
AsyncCompletionsResource,
|
|
14
|
+
CompletionsResourceWithRawResponse,
|
|
15
|
+
AsyncCompletionsResourceWithRawResponse,
|
|
16
|
+
CompletionsResourceWithStreamingResponse,
|
|
17
|
+
AsyncCompletionsResourceWithStreamingResponse,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"CompletionsResource",
|
|
22
|
+
"AsyncCompletionsResource",
|
|
23
|
+
"CompletionsResourceWithRawResponse",
|
|
24
|
+
"AsyncCompletionsResourceWithRawResponse",
|
|
25
|
+
"CompletionsResourceWithStreamingResponse",
|
|
26
|
+
"AsyncCompletionsResourceWithStreamingResponse",
|
|
27
|
+
"ChatResource",
|
|
28
|
+
"AsyncChatResource",
|
|
29
|
+
"ChatResourceWithRawResponse",
|
|
30
|
+
"AsyncChatResourceWithRawResponse",
|
|
31
|
+
"ChatResourceWithStreamingResponse",
|
|
32
|
+
"AsyncChatResourceWithStreamingResponse",
|
|
33
|
+
]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from ..._compat import cached_property
|
|
6
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
7
|
+
from .completions import (
|
|
8
|
+
CompletionsResource,
|
|
9
|
+
AsyncCompletionsResource,
|
|
10
|
+
CompletionsResourceWithRawResponse,
|
|
11
|
+
AsyncCompletionsResourceWithRawResponse,
|
|
12
|
+
CompletionsResourceWithStreamingResponse,
|
|
13
|
+
AsyncCompletionsResourceWithStreamingResponse,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = ["ChatResource", "AsyncChatResource"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ChatResource(SyncAPIResource):
|
|
20
|
+
@cached_property
|
|
21
|
+
def completions(self) -> CompletionsResource:
|
|
22
|
+
return CompletionsResource(self._client)
|
|
23
|
+
|
|
24
|
+
@cached_property
|
|
25
|
+
def with_raw_response(self) -> ChatResourceWithRawResponse:
|
|
26
|
+
"""
|
|
27
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
28
|
+
the raw response object instead of the parsed content.
|
|
29
|
+
|
|
30
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
31
|
+
"""
|
|
32
|
+
return ChatResourceWithRawResponse(self)
|
|
33
|
+
|
|
34
|
+
@cached_property
|
|
35
|
+
def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
|
|
36
|
+
"""
|
|
37
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
38
|
+
|
|
39
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
40
|
+
"""
|
|
41
|
+
return ChatResourceWithStreamingResponse(self)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class AsyncChatResource(AsyncAPIResource):
|
|
45
|
+
@cached_property
|
|
46
|
+
def completions(self) -> AsyncCompletionsResource:
|
|
47
|
+
return AsyncCompletionsResource(self._client)
|
|
48
|
+
|
|
49
|
+
@cached_property
|
|
50
|
+
def with_raw_response(self) -> AsyncChatResourceWithRawResponse:
|
|
51
|
+
"""
|
|
52
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
53
|
+
the raw response object instead of the parsed content.
|
|
54
|
+
|
|
55
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
|
|
56
|
+
"""
|
|
57
|
+
return AsyncChatResourceWithRawResponse(self)
|
|
58
|
+
|
|
59
|
+
@cached_property
|
|
60
|
+
def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
|
|
61
|
+
"""
|
|
62
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
63
|
+
|
|
64
|
+
For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
|
|
65
|
+
"""
|
|
66
|
+
return AsyncChatResourceWithStreamingResponse(self)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ChatResourceWithRawResponse:
|
|
70
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
71
|
+
self._chat = chat
|
|
72
|
+
|
|
73
|
+
@cached_property
|
|
74
|
+
def completions(self) -> CompletionsResourceWithRawResponse:
|
|
75
|
+
return CompletionsResourceWithRawResponse(self._chat.completions)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class AsyncChatResourceWithRawResponse:
|
|
79
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
80
|
+
self._chat = chat
|
|
81
|
+
|
|
82
|
+
@cached_property
|
|
83
|
+
def completions(self) -> AsyncCompletionsResourceWithRawResponse:
|
|
84
|
+
return AsyncCompletionsResourceWithRawResponse(self._chat.completions)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ChatResourceWithStreamingResponse:
|
|
88
|
+
def __init__(self, chat: ChatResource) -> None:
|
|
89
|
+
self._chat = chat
|
|
90
|
+
|
|
91
|
+
@cached_property
|
|
92
|
+
def completions(self) -> CompletionsResourceWithStreamingResponse:
|
|
93
|
+
return CompletionsResourceWithStreamingResponse(self._chat.completions)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AsyncChatResourceWithStreamingResponse:
|
|
97
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
|
98
|
+
self._chat = chat
|
|
99
|
+
|
|
100
|
+
@cached_property
|
|
101
|
+
def completions(self) -> AsyncCompletionsResourceWithStreamingResponse:
|
|
102
|
+
return AsyncCompletionsResourceWithStreamingResponse(self._chat.completions)
|