Skip to content

Commit d67371f

Browse files
feat(api): share chat completion chunk model between chat and agent.chat
1 parent c2b96ce commit d67371f

File tree

10 files changed

+22
-111
lines changed

10 files changed

+22
-111
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 76
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fgradientai-e8b3cbc80e18e4f7f277010349f25e1319156704f359911dc464cc21a0d077a6.yml
33
openapi_spec_hash: c773d792724f5647ae25a5ae4ccec208
4-
config_hash: 9c2e548d86a376bc5f6c458de6944504
4+
config_hash: 6ed9ee8d3f0d6392816bfaf9dc4894a6

api.md

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

33
```python
4-
from gradientai.types import APILinks, APIMeta, ChatCompletionTokenLogprob
4+
from gradientai.types import APILinks, APIMeta, ChatCompletionChunk, ChatCompletionTokenLogprob
55
```
66

77
# Agents
@@ -65,7 +65,7 @@ Methods:
6565
Types:
6666

6767
```python
68-
from gradientai.types.agents.chat import AgentChatCompletionChunk, CompletionCreateResponse
68+
from gradientai.types.agents.chat import CompletionCreateResponse
6969
```
7070

7171
Methods:
@@ -260,7 +260,7 @@ Methods:
260260
Types:
261261

262262
```python
263-
from gradientai.types.chat import ChatCompletionChunk, CompletionCreateResponse
263+
from gradientai.types.chat import CompletionCreateResponse
264264
```
265265

266266
Methods:

src/gradientai/resources/agents/chat/completions.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
from ...._streaming import Stream, AsyncStream
2121
from ...._base_client import make_request_options
2222
from ....types.agents.chat import completion_create_params
23+
from ....types.shared.chat_completion_chunk import ChatCompletionChunk
2324
from ....types.agents.chat.completion_create_response import CompletionCreateResponse
24-
from ....types.agents.chat.agent_chat_completion_chunk import AgentChatCompletionChunk
2525

2626
__all__ = ["CompletionsResource", "AsyncCompletionsResource"]
2727

@@ -186,7 +186,7 @@ def create(
186186
extra_query: Query | None = None,
187187
extra_body: Body | None = None,
188188
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
189-
) -> Stream[AgentChatCompletionChunk]:
189+
) -> Stream[ChatCompletionChunk]:
190190
"""
191191
Creates a model response for the given chat conversation.
192192
@@ -299,7 +299,7 @@ def create(
299299
extra_query: Query | None = None,
300300
extra_body: Body | None = None,
301301
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
302-
) -> CompletionCreateResponse | Stream[AgentChatCompletionChunk]:
302+
) -> CompletionCreateResponse | Stream[ChatCompletionChunk]:
303303
"""
304304
Creates a model response for the given chat conversation.
305305
@@ -412,7 +412,7 @@ def create(
412412
extra_query: Query | None = None,
413413
extra_body: Body | None = None,
414414
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
415-
) -> CompletionCreateResponse | Stream[AgentChatCompletionChunk]:
415+
) -> CompletionCreateResponse | Stream[ChatCompletionChunk]:
416416
return self._post(
417417
"/chat/completions"
418418
if self._client._base_url_overridden
@@ -446,7 +446,7 @@ def create(
446446
),
447447
cast_to=CompletionCreateResponse,
448448
stream=stream or False,
449-
stream_cls=Stream[AgentChatCompletionChunk],
449+
stream_cls=Stream[ChatCompletionChunk],
450450
)
451451

452452

@@ -610,7 +610,7 @@ async def create(
610610
extra_query: Query | None = None,
611611
extra_body: Body | None = None,
612612
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
613-
) -> AsyncStream[AgentChatCompletionChunk]:
613+
) -> AsyncStream[ChatCompletionChunk]:
614614
"""
615615
Creates a model response for the given chat conversation.
616616
@@ -723,7 +723,7 @@ async def create(
723723
extra_query: Query | None = None,
724724
extra_body: Body | None = None,
725725
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
726-
) -> CompletionCreateResponse | AsyncStream[AgentChatCompletionChunk]:
726+
) -> CompletionCreateResponse | AsyncStream[ChatCompletionChunk]:
727727
"""
728728
Creates a model response for the given chat conversation.
729729
@@ -836,7 +836,7 @@ async def create(
836836
extra_query: Query | None = None,
837837
extra_body: Body | None = None,
838838
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
839-
) -> CompletionCreateResponse | AsyncStream[AgentChatCompletionChunk]:
839+
) -> CompletionCreateResponse | AsyncStream[ChatCompletionChunk]:
840840
return await self._post(
841841
"/chat/completions"
842842
if self._client._base_url_overridden
@@ -870,7 +870,7 @@ async def create(
870870
),
871871
cast_to=CompletionCreateResponse,
872872
stream=stream or False,
873-
stream_cls=AsyncStream[AgentChatCompletionChunk],
873+
stream_cls=AsyncStream[ChatCompletionChunk],
874874
)
875875

876876

src/gradientai/resources/chat/completions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..._streaming import Stream, AsyncStream
2121
from ...types.chat import completion_create_params
2222
from ..._base_client import make_request_options
23-
from ...types.chat.chat_completion_chunk import ChatCompletionChunk
23+
from ...types.shared.chat_completion_chunk import ChatCompletionChunk
2424
from ...types.chat.completion_create_response import CompletionCreateResponse
2525

2626
__all__ = ["CompletionsResource", "AsyncCompletionsResource"]

src/gradientai/types/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
from __future__ import annotations
44

5-
from .shared import APIMeta as APIMeta, APILinks as APILinks, ChatCompletionTokenLogprob as ChatCompletionTokenLogprob
5+
from .shared import (
6+
APIMeta as APIMeta,
7+
APILinks as APILinks,
8+
ChatCompletionChunk as ChatCompletionChunk,
9+
ChatCompletionTokenLogprob as ChatCompletionTokenLogprob,
10+
)
611
from .api_agent import APIAgent as APIAgent
712
from .api_model import APIModel as APIModel
813
from .api_agreement import APIAgreement as APIAgreement

src/gradientai/types/agents/chat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44

55
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
66
from .completion_create_response import CompletionCreateResponse as CompletionCreateResponse
7-
from .agent_chat_completion_chunk import AgentChatCompletionChunk as AgentChatCompletionChunk

src/gradientai/types/agents/chat/agent_chat_completion_chunk.py

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/gradientai/types/chat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
from __future__ import annotations
44

5-
from .chat_completion_chunk import ChatCompletionChunk as ChatCompletionChunk
65
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
76
from .completion_create_response import CompletionCreateResponse as CompletionCreateResponse

src/gradientai/types/shared/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
from .api_meta import APIMeta as APIMeta
44
from .api_links import APILinks as APILinks
5+
from .chat_completion_chunk import ChatCompletionChunk as ChatCompletionChunk
56
from .chat_completion_token_logprob import ChatCompletionTokenLogprob as ChatCompletionTokenLogprob

src/gradientai/types/chat/chat_completion_chunk.py renamed to src/gradientai/types/shared/chat_completion_chunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
7-
from ..shared.chat_completion_token_logprob import ChatCompletionTokenLogprob
7+
from .chat_completion_token_logprob import ChatCompletionTokenLogprob
88

99
__all__ = ["ChatCompletionChunk", "Choice", "ChoiceDelta", "ChoiceLogprobs", "Usage"]
1010

0 commit comments

Comments
 (0)