Skip to content

Commit aa9e2c7

Browse files
feat(api): manual updates
Added agent chat completions
1 parent b4b6260 commit aa9e2c7

File tree

13 files changed

+1044
-5
lines changed

13 files changed

+1044
-5
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: 77
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fgradientai-e8b3cbc80e18e4f7f277010349f25e1319156704f359911dc464cc21a0d077a6.yml
33
openapi_spec_hash: c773d792724f5647ae25a5ae4ccec208
4-
config_hash: 80395df07aec0cf06a5aa7caa2e3f4bc
4+
config_hash: 7cc5a33eb381780e5290d4871c3b30df

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ client = GradientAI(
3131
api_key=os.environ.get("GRADIENTAI_API_KEY"), # This is the default and can be omitted
3232
)
3333

34-
completion = client.chat.completions.create(
34+
completion = client.agents.chat.completions.create(
3535
messages=[
3636
{
3737
"content": "string",
@@ -63,7 +63,7 @@ client = AsyncGradientAI(
6363

6464

6565
async def main() -> None:
66-
completion = await client.chat.completions.create(
66+
completion = await client.agents.chat.completions.create(
6767
messages=[
6868
{
6969
"content": "string",
@@ -105,7 +105,7 @@ async def main() -> None:
105105
api_key=os.environ.get("GRADIENTAI_API_KEY"), # This is the default and can be omitted
106106
http_client=DefaultAioHttpClient(),
107107
) as client:
108-
completion = await client.chat.completions.create(
108+
completion = await client.agents.chat.completions.create(
109109
messages=[
110110
{
111111
"content": "string",
@@ -138,7 +138,7 @@ from gradientai import GradientAI
138138

139139
client = GradientAI()
140140

141-
completion = client.chat.completions.create(
141+
completion = client.agents.chat.completions.create(
142142
messages=[
143143
{
144144
"content": "string",

api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ Methods:
5858
- <code title="delete /v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}">client.agents.api_keys.<a href="./src/gradientai/resources/agents/api_keys.py">delete</a>(api_key_uuid, \*, agent_uuid) -> <a href="./src/gradientai/types/agents/api_key_delete_response.py">APIKeyDeleteResponse</a></code>
5959
- <code title="put /v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}/regenerate">client.agents.api_keys.<a href="./src/gradientai/resources/agents/api_keys.py">regenerate</a>(api_key_uuid, \*, agent_uuid) -> <a href="./src/gradientai/types/agents/api_key_regenerate_response.py">APIKeyRegenerateResponse</a></code>
6060

61+
## Chat
62+
63+
### Completions
64+
65+
Types:
66+
67+
```python
68+
from gradientai.types.agents.chat import ChatCompletionTokenLogprob, CompletionCreateResponse
69+
```
70+
71+
Methods:
72+
73+
- <code title="post /chat/completions">client.agents.chat.completions.<a href="./src/gradientai/resources/agents/chat/completions.py">create</a>(\*\*<a href="src/gradientai/types/agents/chat/completion_create_params.py">params</a>) -> <a href="./src/gradientai/types/agents/chat/completion_create_response.py">CompletionCreateResponse</a></code>
74+
6175
## EvaluationMetrics
6276

6377
Types:

src/gradientai/resources/agents/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from .chat import (
4+
ChatResource,
5+
AsyncChatResource,
6+
ChatResourceWithRawResponse,
7+
AsyncChatResourceWithRawResponse,
8+
ChatResourceWithStreamingResponse,
9+
AsyncChatResourceWithStreamingResponse,
10+
)
311
from .agents import (
412
AgentsResource,
513
AsyncAgentsResource,
@@ -88,6 +96,12 @@
8896
"AsyncAPIKeysResourceWithRawResponse",
8997
"APIKeysResourceWithStreamingResponse",
9098
"AsyncAPIKeysResourceWithStreamingResponse",
99+
"ChatResource",
100+
"AsyncChatResource",
101+
"ChatResourceWithRawResponse",
102+
"AsyncChatResourceWithRawResponse",
103+
"ChatResourceWithStreamingResponse",
104+
"AsyncChatResourceWithStreamingResponse",
91105
"EvaluationMetricsResource",
92106
"AsyncEvaluationMetricsResource",
93107
"EvaluationMetricsResourceWithRawResponse",

src/gradientai/resources/agents/agents.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
AsyncVersionsResourceWithStreamingResponse,
4242
)
4343
from ..._compat import cached_property
44+
from .chat.chat import (
45+
ChatResource,
46+
AsyncChatResource,
47+
ChatResourceWithRawResponse,
48+
AsyncChatResourceWithRawResponse,
49+
ChatResourceWithStreamingResponse,
50+
AsyncChatResourceWithStreamingResponse,
51+
)
4452
from .functions import (
4553
FunctionsResource,
4654
AsyncFunctionsResource,
@@ -114,6 +122,10 @@ class AgentsResource(SyncAPIResource):
114122
def api_keys(self) -> APIKeysResource:
115123
return APIKeysResource(self._client)
116124

125+
@cached_property
126+
def chat(self) -> ChatResource:
127+
return ChatResource(self._client)
128+
117129
@cached_property
118130
def evaluation_metrics(self) -> EvaluationMetricsResource:
119131
return EvaluationMetricsResource(self._client)
@@ -498,6 +510,10 @@ class AsyncAgentsResource(AsyncAPIResource):
498510
def api_keys(self) -> AsyncAPIKeysResource:
499511
return AsyncAPIKeysResource(self._client)
500512

513+
@cached_property
514+
def chat(self) -> AsyncChatResource:
515+
return AsyncChatResource(self._client)
516+
501517
@cached_property
502518
def evaluation_metrics(self) -> AsyncEvaluationMetricsResource:
503519
return AsyncEvaluationMetricsResource(self._client)
@@ -904,6 +920,10 @@ def __init__(self, agents: AgentsResource) -> None:
904920
def api_keys(self) -> APIKeysResourceWithRawResponse:
905921
return APIKeysResourceWithRawResponse(self._agents.api_keys)
906922

923+
@cached_property
924+
def chat(self) -> ChatResourceWithRawResponse:
925+
return ChatResourceWithRawResponse(self._agents.chat)
926+
907927
@cached_property
908928
def evaluation_metrics(self) -> EvaluationMetricsResourceWithRawResponse:
909929
return EvaluationMetricsResourceWithRawResponse(self._agents.evaluation_metrics)
@@ -964,6 +984,10 @@ def __init__(self, agents: AsyncAgentsResource) -> None:
964984
def api_keys(self) -> AsyncAPIKeysResourceWithRawResponse:
965985
return AsyncAPIKeysResourceWithRawResponse(self._agents.api_keys)
966986

987+
@cached_property
988+
def chat(self) -> AsyncChatResourceWithRawResponse:
989+
return AsyncChatResourceWithRawResponse(self._agents.chat)
990+
967991
@cached_property
968992
def evaluation_metrics(self) -> AsyncEvaluationMetricsResourceWithRawResponse:
969993
return AsyncEvaluationMetricsResourceWithRawResponse(self._agents.evaluation_metrics)
@@ -1024,6 +1048,10 @@ def __init__(self, agents: AgentsResource) -> None:
10241048
def api_keys(self) -> APIKeysResourceWithStreamingResponse:
10251049
return APIKeysResourceWithStreamingResponse(self._agents.api_keys)
10261050

1051+
@cached_property
1052+
def chat(self) -> ChatResourceWithStreamingResponse:
1053+
return ChatResourceWithStreamingResponse(self._agents.chat)
1054+
10271055
@cached_property
10281056
def evaluation_metrics(self) -> EvaluationMetricsResourceWithStreamingResponse:
10291057
return EvaluationMetricsResourceWithStreamingResponse(self._agents.evaluation_metrics)
@@ -1084,6 +1112,10 @@ def __init__(self, agents: AsyncAgentsResource) -> None:
10841112
def api_keys(self) -> AsyncAPIKeysResourceWithStreamingResponse:
10851113
return AsyncAPIKeysResourceWithStreamingResponse(self._agents.api_keys)
10861114

1115+
@cached_property
1116+
def chat(self) -> AsyncChatResourceWithStreamingResponse:
1117+
return AsyncChatResourceWithStreamingResponse(self._agents.chat)
1118+
10871119
@cached_property
10881120
def evaluation_metrics(self) -> AsyncEvaluationMetricsResourceWithStreamingResponse:
10891121
return AsyncEvaluationMetricsResourceWithStreamingResponse(self._agents.evaluation_metrics)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/digitalocean/gradientai-python#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/digitalocean/gradientai-python#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/digitalocean/gradientai-python#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/digitalocean/gradientai-python#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 commit comments

Comments
 (0)