Skip to content

Commit 5a26918

Browse files
feat(api): update via SDK Studio
1 parent dad945d commit 5a26918

35 files changed

+1947
-540
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 6
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-0a20b2c1a864613083f602f3589f85caa0e39b04c29c0a37db76f6398dfd2f50.yml
3-
openapi_spec_hash: 5c8d07ba17d180b472679f2b85def126
4-
config_hash: d3612805022ba4461f6399145be920d5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-0a0c41e4a1d04f467b380f19330aad7cccfdf3550c269995b6921dfd68615c51.yml
3+
openapi_spec_hash: 030643101899103819c1004f32cafbbc
4+
config_hash: 17c338b2ef0119791bd9f178936b252f

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ completion = client.chat.completions.create(
184184
"role": "system",
185185
}
186186
],
187-
model="sonar",
188-
web_search_options={},
187+
model="model",
188+
debug_params={},
189189
)
190-
print(completion.web_search_options)
190+
print(completion.debug_params)
191191
```
192192

193193
## Handling errors

api.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Shared Types
22

33
```python
4-
from perplexity.types import ChatChoice, ChatMessage, SearchResult, UsageInfo
4+
from perplexity.types import (
5+
APIPublicSearchResult,
6+
ChatMessageInput,
7+
ChatMessageOutput,
8+
Choice,
9+
UsageInfo,
10+
)
511
```
612

713
# Chat
@@ -37,8 +43,8 @@ from perplexity.types.async_.chat import (
3743
Methods:
3844

3945
- <code title="post /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">create</a>(\*\*<a href="src/perplexity/types/async_/chat/completion_create_params.py">params</a>) -> <a href="./src/perplexity/types/async_/chat/completion_create_response.py">CompletionCreateResponse</a></code>
40-
- <code title="get /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">list</a>(\*\*<a href="src/perplexity/types/async_/chat/completion_list_params.py">params</a>) -> <a href="./src/perplexity/types/async_/chat/completion_list_response.py">CompletionListResponse</a></code>
41-
- <code title="get /async/chat/completions/{request_id}">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">get</a>(request*id) -> <a href="./src/perplexity/types/async*/chat/completion_get_response.py">CompletionGetResponse</a></code>
46+
- <code title="get /async/chat/completions">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">list</a>() -> <a href="./src/perplexity/types/async_/chat/completion_list_response.py">CompletionListResponse</a></code>
47+
- <code title="get /async/chat/completions/{api_request}">client.async*.chat.completions.<a href="./src/perplexity/resources/async*/chat/completions.py">get</a>(api*request, \*\*<a href="src/perplexity/types/async*/chat/completion*get_params.py">params</a>) -> <a href="./src/perplexity/types/async*/chat/completion_get_response.py">CompletionGetResponse</a></code>
4248

4349
# Search
4450

src/perplexity/resources/async_/chat/completions.py

Lines changed: 90 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
6+
57
import httpx
68

79
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
911
from ...._compat import cached_property
1012
from ...._resource import SyncAPIResource, AsyncAPIResource
1113
from ...._response import (
@@ -15,7 +17,7 @@
1517
async_to_streamed_response_wrapper,
1618
)
1719
from ...._base_client import make_request_options
18-
from ....types.async_.chat import completion_list_params, completion_create_params
20+
from ....types.async_.chat import completion_get_params, completion_create_params
1921
from ....types.async_.chat.completion_get_response import CompletionGetResponse
2022
from ....types.async_.chat.completion_list_response import CompletionListResponse
2123
from ....types.async_.chat.completion_create_response import CompletionCreateResponse
@@ -47,6 +49,7 @@ def create(
4749
self,
4850
*,
4951
request: completion_create_params.Request,
52+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
5053
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5154
# The extra values given here take precedence over values defined on the client or passed to this method.
5255
extra_headers: Headers | None = None,
@@ -55,7 +58,10 @@ def create(
5558
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
5659
) -> CompletionCreateResponse:
5760
"""
58-
Creates an asynchronous chat completion job
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.
5965
6066
Args:
6167
extra_headers: Send extra headers
@@ -68,7 +74,13 @@ def create(
6874
"""
6975
return self._post(
7076
"/async/chat/completions",
71-
body=maybe_transform({"request": request}, completion_create_params.CompletionCreateParams),
77+
body=maybe_transform(
78+
{
79+
"request": request,
80+
"idempotency_key": idempotency_key,
81+
},
82+
completion_create_params.CompletionCreateParams,
83+
),
7284
options=make_request_options(
7385
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
7486
),
@@ -78,53 +90,32 @@ def create(
7890
def list(
7991
self,
8092
*,
81-
limit: int | NotGiven = NOT_GIVEN,
82-
next_token: str | NotGiven = NOT_GIVEN,
8393
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8494
# The extra values given here take precedence over values defined on the client or passed to this method.
8595
extra_headers: Headers | None = None,
8696
extra_query: Query | None = None,
8797
extra_body: Body | None = None,
8898
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
8999
) -> 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."""
106101
return self._get(
107102
"/async/chat/completions",
108103
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
120105
),
121106
cast_to=CompletionListResponse,
122107
)
123108

124109
def get(
125110
self,
126-
request_id: str,
111+
api_request: str,
127112
*,
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,
128119
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
129120
# The extra values given here take precedence over values defined on the client or passed to this method.
130121
extra_headers: Headers | None = None,
@@ -133,7 +124,7 @@ def get(
133124
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
134125
) -> CompletionGetResponse:
135126
"""
136-
Retrieves the status and result of a specific asynchronous chat completion job
127+
get the response for a given async chat completion request.
137128
138129
Args:
139130
extra_headers: Send extra headers
@@ -144,12 +135,28 @@ def get(
144135
145136
timeout: Override the client-level default timeout for this request, in seconds
146137
"""
147-
if not request_id:
148-
raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}")
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+
}
149152
return self._get(
150-
f"/async/chat/completions/{request_id}",
153+
f"/async/chat/completions/{api_request}",
151154
options=make_request_options(
152-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
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),
153160
),
154161
cast_to=CompletionGetResponse,
155162
)
@@ -179,6 +186,7 @@ async def create(
179186
self,
180187
*,
181188
request: completion_create_params.Request,
189+
idempotency_key: Optional[str] | NotGiven = NOT_GIVEN,
182190
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
183191
# The extra values given here take precedence over values defined on the client or passed to this method.
184192
extra_headers: Headers | None = None,
@@ -187,7 +195,10 @@ async def create(
187195
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
188196
) -> CompletionCreateResponse:
189197
"""
190-
Creates an asynchronous chat completion job
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.
191202
192203
Args:
193204
extra_headers: Send extra headers
@@ -200,7 +211,13 @@ async def create(
200211
"""
201212
return await self._post(
202213
"/async/chat/completions",
203-
body=await async_maybe_transform({"request": request}, completion_create_params.CompletionCreateParams),
214+
body=await async_maybe_transform(
215+
{
216+
"request": request,
217+
"idempotency_key": idempotency_key,
218+
},
219+
completion_create_params.CompletionCreateParams,
220+
),
204221
options=make_request_options(
205222
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
206223
),
@@ -210,53 +227,32 @@ async def create(
210227
async def list(
211228
self,
212229
*,
213-
limit: int | NotGiven = NOT_GIVEN,
214-
next_token: str | NotGiven = NOT_GIVEN,
215230
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
216231
# The extra values given here take precedence over values defined on the client or passed to this method.
217232
extra_headers: Headers | None = None,
218233
extra_query: Query | None = None,
219234
extra_body: Body | None = None,
220235
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
221236
) -> 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."""
238238
return await self._get(
239239
"/async/chat/completions",
240240
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
252242
),
253243
cast_to=CompletionListResponse,
254244
)
255245

256246
async def get(
257247
self,
258-
request_id: str,
248+
api_request: str,
259249
*,
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,
260256
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261257
# The extra values given here take precedence over values defined on the client or passed to this method.
262258
extra_headers: Headers | None = None,
@@ -265,7 +261,7 @@ async def get(
265261
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
266262
) -> CompletionGetResponse:
267263
"""
268-
Retrieves the status and result of a specific asynchronous chat completion job
264+
get the response for a given async chat completion request.
269265
270266
Args:
271267
extra_headers: Send extra headers
@@ -276,12 +272,30 @@ async def get(
276272
277273
timeout: Override the client-level default timeout for this request, in seconds
278274
"""
279-
if not request_id:
280-
raise ValueError(f"Expected a non-empty value for `request_id` but received {request_id!r}")
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+
}
281289
return await self._get(
282-
f"/async/chat/completions/{request_id}",
290+
f"/async/chat/completions/{api_request}",
283291
options=make_request_options(
284-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
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+
),
285299
),
286300
cast_to=CompletionGetResponse,
287301
)

0 commit comments

Comments
 (0)