Skip to content

Commit ae6716d

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): manual updates (#127)
1 parent 0cb5189 commit ae6716d

41 files changed

Lines changed: 664 additions & 691 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-6b363dd34169cab18f5ec3bcf6586aecd4799f79a80c90bf54e5a12f91d9e7c2.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-82683f2fd5f8778a27960ebabda40d6dc4640bdfb77ac4ec7f173b8bf8076d3c.yml

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ client = Writer(
3232
api_key=os.environ.get("WRITER_API_KEY"), # This is the default and can be omitted
3333
)
3434

35-
chat_completion = client.chat.chat(
35+
chat = client.chat.chat(
3636
messages=[{"role": "user"}],
3737
model="palmyra-x-004",
3838
)
39-
print(chat_completion.id)
39+
print(chat.id)
4040
```
4141

4242
While you can provide an `api_key` keyword argument,
@@ -59,11 +59,11 @@ client = AsyncWriter(
5959

6060

6161
async def main() -> None:
62-
chat_completion = await client.chat.chat(
62+
chat = await client.chat.chat(
6363
messages=[{"role": "user"}],
6464
model="palmyra-x-004",
6565
)
66-
print(chat_completion.id)
66+
print(chat.id)
6767

6868

6969
asyncio.run(main())

api.md

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# Shared Types
2-
3-
```python
4-
from writerai.types import (
5-
ErrorMessage,
6-
ErrorObject,
7-
FunctionDefinition,
8-
FunctionParams,
9-
GraphData,
10-
Logprobs,
11-
LogprobsToken,
12-
Source,
13-
ToolCall,
14-
ToolCallStreaming,
15-
ToolChoiceJsonObject,
16-
ToolChoiceString,
17-
ToolParam,
18-
)
19-
```
20-
211
# Applications
222

233
Types:
@@ -35,26 +15,19 @@ Methods:
3515
Types:
3616

3717
```python
38-
from writerai.types import (
39-
ChatCompletion,
40-
ChatCompletionChoice,
41-
ChatCompletionChunk,
42-
ChatCompletionMessage,
43-
ChatCompletionParams,
44-
ChatCompletionUsage,
45-
)
18+
from writerai.types import Chat, ChatCompletionChunk
4619
```
4720

4821
Methods:
4922

50-
- <code title="post /v1/chat">client.chat.<a href="./src/writerai/resources/chat.py">chat</a>(\*\*<a href="src/writerai/types/chat_chat_params.py">params</a>) -> <a href="./src/writerai/types/chat_completion.py">ChatCompletion</a></code>
23+
- <code title="post /v1/chat">client.chat.<a href="./src/writerai/resources/chat.py">chat</a>(\*\*<a href="src/writerai/types/chat_chat_params.py">params</a>) -> <a href="./src/writerai/types/chat.py">Chat</a></code>
5124

5225
# Completions
5326

5427
Types:
5528

5629
```python
57-
from writerai.types import Completion, CompletionChunk, CompletionParams
30+
from writerai.types import Completion, StreamingData
5831
```
5932

6033
Methods:

src/writerai/_streaming.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def __stream__(self) -> Iterator[_T]:
5555
iterator = self._iter_events()
5656

5757
for sse in iterator:
58-
if sse.data.startswith("[DONE]"):
59-
break
60-
6158
if sse.event is None:
6259
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
6360

@@ -138,9 +135,6 @@ async def __stream__(self) -> AsyncIterator[_T]:
138135
iterator = self._iter_events()
139136

140137
async for sse in iterator:
141-
if sse.data.startswith("[DONE]"):
142-
break
143-
144138
if sse.event is None:
145139
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
146140

src/writerai/resources/chat.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
async_to_streamed_response_wrapper,
2424
)
2525
from .._streaming import Stream, AsyncStream
26+
from ..types.chat import Chat
2627
from .._base_client import make_request_options
27-
from ..types.chat_completion import ChatCompletion
2828
from ..types.chat_completion_chunk import ChatCompletionChunk
29-
from ..types.shared_params.tool_param import ToolParam
3029

3130
__all__ = ["ChatResource", "AsyncChatResource"]
3231

@@ -65,15 +64,15 @@ def chat(
6564
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
6665
temperature: float | NotGiven = NOT_GIVEN,
6766
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
68-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
67+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
6968
top_p: float | NotGiven = NOT_GIVEN,
7069
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7170
# The extra values given here take precedence over values defined on the client or passed to this method.
7271
extra_headers: Headers | None = None,
7372
extra_query: Query | None = None,
7473
extra_body: Body | None = None,
7574
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
76-
) -> ChatCompletion:
75+
) -> Chat:
7776
"""Generate a chat completion based on the provided messages.
7877
7978
The response shown
@@ -148,7 +147,7 @@ def chat(
148147
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
149148
temperature: float | NotGiven = NOT_GIVEN,
150149
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
151-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
150+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
152151
top_p: float | NotGiven = NOT_GIVEN,
153152
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
154153
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -231,15 +230,15 @@ def chat(
231230
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
232231
temperature: float | NotGiven = NOT_GIVEN,
233232
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
234-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
233+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
235234
top_p: float | NotGiven = NOT_GIVEN,
236235
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
237236
# The extra values given here take precedence over values defined on the client or passed to this method.
238237
extra_headers: Headers | None = None,
239238
extra_query: Query | None = None,
240239
extra_body: Body | None = None,
241240
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
242-
) -> ChatCompletion | Stream[ChatCompletionChunk]:
241+
) -> Chat | Stream[ChatCompletionChunk]:
243242
"""Generate a chat completion based on the provided messages.
244243
245244
The response shown
@@ -314,15 +313,15 @@ def chat(
314313
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
315314
temperature: float | NotGiven = NOT_GIVEN,
316315
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
317-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
316+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
318317
top_p: float | NotGiven = NOT_GIVEN,
319318
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
320319
# The extra values given here take precedence over values defined on the client or passed to this method.
321320
extra_headers: Headers | None = None,
322321
extra_query: Query | None = None,
323322
extra_body: Body | None = None,
324323
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
325-
) -> ChatCompletion | Stream[ChatCompletionChunk]:
324+
) -> Chat | Stream[ChatCompletionChunk]:
326325
return self._post(
327326
"/v1/chat",
328327
body=maybe_transform(
@@ -345,7 +344,7 @@ def chat(
345344
options=make_request_options(
346345
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
347346
),
348-
cast_to=ChatCompletion,
347+
cast_to=Chat,
349348
stream=stream or False,
350349
stream_cls=Stream[ChatCompletionChunk],
351350
)
@@ -385,15 +384,15 @@ async def chat(
385384
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
386385
temperature: float | NotGiven = NOT_GIVEN,
387386
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
388-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
387+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
389388
top_p: float | NotGiven = NOT_GIVEN,
390389
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
391390
# The extra values given here take precedence over values defined on the client or passed to this method.
392391
extra_headers: Headers | None = None,
393392
extra_query: Query | None = None,
394393
extra_body: Body | None = None,
395394
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
396-
) -> ChatCompletion:
395+
) -> Chat:
397396
"""Generate a chat completion based on the provided messages.
398397
399398
The response shown
@@ -468,7 +467,7 @@ async def chat(
468467
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
469468
temperature: float | NotGiven = NOT_GIVEN,
470469
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
471-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
470+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
472471
top_p: float | NotGiven = NOT_GIVEN,
473472
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
474473
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -551,15 +550,15 @@ async def chat(
551550
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
552551
temperature: float | NotGiven = NOT_GIVEN,
553552
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
554-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
553+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
555554
top_p: float | NotGiven = NOT_GIVEN,
556555
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
557556
# The extra values given here take precedence over values defined on the client or passed to this method.
558557
extra_headers: Headers | None = None,
559558
extra_query: Query | None = None,
560559
extra_body: Body | None = None,
561560
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
562-
) -> ChatCompletion | AsyncStream[ChatCompletionChunk]:
561+
) -> Chat | AsyncStream[ChatCompletionChunk]:
563562
"""Generate a chat completion based on the provided messages.
564563
565564
The response shown
@@ -634,15 +633,15 @@ async def chat(
634633
stream_options: chat_chat_params.StreamOptions | NotGiven = NOT_GIVEN,
635634
temperature: float | NotGiven = NOT_GIVEN,
636635
tool_choice: chat_chat_params.ToolChoice | NotGiven = NOT_GIVEN,
637-
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
636+
tools: Iterable[chat_chat_params.Tool] | NotGiven = NOT_GIVEN,
638637
top_p: float | NotGiven = NOT_GIVEN,
639638
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
640639
# The extra values given here take precedence over values defined on the client or passed to this method.
641640
extra_headers: Headers | None = None,
642641
extra_query: Query | None = None,
643642
extra_body: Body | None = None,
644643
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
645-
) -> ChatCompletion | AsyncStream[ChatCompletionChunk]:
644+
) -> Chat | AsyncStream[ChatCompletionChunk]:
646645
return await self._post(
647646
"/v1/chat",
648647
body=await async_maybe_transform(
@@ -665,7 +664,7 @@ async def chat(
665664
options=make_request_options(
666665
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
667666
),
668-
cast_to=ChatCompletion,
667+
cast_to=Chat,
669668
stream=stream or False,
670669
stream_cls=AsyncStream[ChatCompletionChunk],
671670
)

src/writerai/resources/completions.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .._streaming import Stream, AsyncStream
2626
from .._base_client import make_request_options
2727
from ..types.completion import Completion
28-
from ..types.completion_chunk import CompletionChunk
28+
from ..types.streaming_data import StreamingData
2929

3030
__all__ = ["CompletionsResource", "AsyncCompletionsResource"]
3131

@@ -130,7 +130,7 @@ def create(
130130
extra_query: Query | None = None,
131131
extra_body: Body | None = None,
132132
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
133-
) -> Stream[CompletionChunk]:
133+
) -> Stream[StreamingData]:
134134
"""
135135
Text generation
136136
@@ -191,7 +191,7 @@ def create(
191191
extra_query: Query | None = None,
192192
extra_body: Body | None = None,
193193
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
194-
) -> Completion | Stream[CompletionChunk]:
194+
) -> Completion | Stream[StreamingData]:
195195
"""
196196
Text generation
197197
@@ -252,7 +252,7 @@ def create(
252252
extra_query: Query | None = None,
253253
extra_body: Body | None = None,
254254
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
255-
) -> Completion | Stream[CompletionChunk]:
255+
) -> Completion | Stream[StreamingData]:
256256
return self._post(
257257
"/v1/completions",
258258
body=maybe_transform(
@@ -274,7 +274,7 @@ def create(
274274
),
275275
cast_to=Completion,
276276
stream=stream or False,
277-
stream_cls=Stream[CompletionChunk],
277+
stream_cls=Stream[StreamingData],
278278
)
279279

280280

@@ -378,7 +378,7 @@ async def create(
378378
extra_query: Query | None = None,
379379
extra_body: Body | None = None,
380380
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
381-
) -> AsyncStream[CompletionChunk]:
381+
) -> AsyncStream[StreamingData]:
382382
"""
383383
Text generation
384384
@@ -439,7 +439,7 @@ async def create(
439439
extra_query: Query | None = None,
440440
extra_body: Body | None = None,
441441
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
442-
) -> Completion | AsyncStream[CompletionChunk]:
442+
) -> Completion | AsyncStream[StreamingData]:
443443
"""
444444
Text generation
445445
@@ -500,7 +500,7 @@ async def create(
500500
extra_query: Query | None = None,
501501
extra_body: Body | None = None,
502502
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
503-
) -> Completion | AsyncStream[CompletionChunk]:
503+
) -> Completion | AsyncStream[StreamingData]:
504504
return await self._post(
505505
"/v1/completions",
506506
body=await async_maybe_transform(
@@ -522,7 +522,7 @@ async def create(
522522
),
523523
cast_to=Completion,
524524
stream=stream or False,
525-
stream_cls=AsyncStream[CompletionChunk],
525+
stream_cls=AsyncStream[StreamingData],
526526
)
527527

528528

src/writerai/types/__init__.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,13 @@
22

33
from __future__ import annotations
44

5+
from .chat import Chat as Chat
56
from .file import File as File
67
from .graph import Graph as Graph
7-
from .shared import (
8-
Source as Source,
9-
Logprobs as Logprobs,
10-
ToolCall as ToolCall,
11-
GraphData as GraphData,
12-
ToolParam as ToolParam,
13-
ErrorObject as ErrorObject,
14-
ErrorMessage as ErrorMessage,
15-
LogprobsToken as LogprobsToken,
16-
FunctionParams as FunctionParams,
17-
ToolChoiceString as ToolChoiceString,
18-
ToolCallStreaming as ToolCallStreaming,
19-
FunctionDefinition as FunctionDefinition,
20-
ToolChoiceJsonObject as ToolChoiceJsonObject,
21-
)
228
from .question import Question as Question
239
from .completion import Completion as Completion
24-
from .chat_completion import ChatCompletion as ChatCompletion
10+
from .streaming_data import StreamingData as StreamingData
2511
from .chat_chat_params import ChatChatParams as ChatChatParams
26-
from .completion_chunk import CompletionChunk as CompletionChunk
2712
from .file_list_params import FileListParams as FileListParams
2813
from .file_retry_params import FileRetryParams as FileRetryParams
2914
from .graph_list_params import GraphListParams as GraphListParams
@@ -34,14 +19,11 @@
3419
from .model_list_response import ModelListResponse as ModelListResponse
3520
from .file_delete_response import FileDeleteResponse as FileDeleteResponse
3621
from .chat_completion_chunk import ChatCompletionChunk as ChatCompletionChunk
37-
from .chat_completion_usage import ChatCompletionUsage as ChatCompletionUsage
3822
from .graph_create_response import GraphCreateResponse as GraphCreateResponse
3923
from .graph_delete_response import GraphDeleteResponse as GraphDeleteResponse
4024
from .graph_question_params import GraphQuestionParams as GraphQuestionParams
4125
from .graph_update_response import GraphUpdateResponse as GraphUpdateResponse
4226
from .tool_parse_pdf_params import ToolParsePdfParams as ToolParsePdfParams
43-
from .chat_completion_choice import ChatCompletionChoice as ChatCompletionChoice
44-
from .chat_completion_message import ChatCompletionMessage as ChatCompletionMessage
4527
from .question_response_chunk import QuestionResponseChunk as QuestionResponseChunk
4628
from .tool_parse_pdf_response import ToolParsePdfResponse as ToolParsePdfResponse
4729
from .completion_create_params import CompletionCreateParams as CompletionCreateParams

0 commit comments

Comments
 (0)