22
33from __future__ import annotations
44
5+ from typing import List
6+
7+ import httpx
8+
9+ from ...types import agent_list_params , agent_create_params
10+ from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
11+ from ..._utils import maybe_transform , async_maybe_transform
512from .versions import (
613 VersionsResource ,
714 AsyncVersionsResource ,
1219)
1320from ..._compat import cached_property
1421from ..._resource import SyncAPIResource , AsyncAPIResource
22+ from ..._response import (
23+ to_raw_response_wrapper ,
24+ to_streamed_response_wrapper ,
25+ async_to_raw_response_wrapper ,
26+ async_to_streamed_response_wrapper ,
27+ )
28+ from ..._base_client import make_request_options
29+ from ...types .agent_list_response import AgentListResponse
30+ from ...types .agent_create_response import AgentCreateResponse
1531
1632__all__ = ["AgentsResource" , "AsyncAgentsResource" ]
1733
@@ -40,6 +56,120 @@ def with_streaming_response(self) -> AgentsResourceWithStreamingResponse:
4056 """
4157 return AgentsResourceWithStreamingResponse (self )
4258
59+ def create (
60+ self ,
61+ * ,
62+ anthropic_key_uuid : str | NotGiven = NOT_GIVEN ,
63+ description : str | NotGiven = NOT_GIVEN ,
64+ instruction : str | NotGiven = NOT_GIVEN ,
65+ knowledge_base_uuid : List [str ] | NotGiven = NOT_GIVEN ,
66+ model_uuid : str | NotGiven = NOT_GIVEN ,
67+ name : str | NotGiven = NOT_GIVEN ,
68+ openai_key_uuid : str | NotGiven = NOT_GIVEN ,
69+ project_id : str | NotGiven = NOT_GIVEN ,
70+ region : str | NotGiven = NOT_GIVEN ,
71+ tags : List [str ] | NotGiven = NOT_GIVEN ,
72+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
73+ # The extra values given here take precedence over values defined on the client or passed to this method.
74+ extra_headers : Headers | None = None ,
75+ extra_query : Query | None = None ,
76+ extra_body : Body | None = None ,
77+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
78+ ) -> AgentCreateResponse :
79+ """To create a new agent, send a POST request to `/v2/gen-ai/agents`.
80+
81+ The response
82+ body contains a JSON object with the newly created agent object.
83+
84+ Args:
85+ instruction: Agent instruction. Instructions help your agent to perform its job effectively.
86+ See
87+ [Write Effective Agent Instructions](https://docs.digitalocean.com/products/genai-platform/concepts/best-practices/#agent-instructions)
88+ for best practices.
89+
90+ model_uuid: Identifier for the foundation model.
91+
92+ extra_headers: Send extra headers
93+
94+ extra_query: Add additional query parameters to the request
95+
96+ extra_body: Add additional JSON properties to the request
97+
98+ timeout: Override the client-level default timeout for this request, in seconds
99+ """
100+ return self ._post (
101+ "/v2/gen-ai/agents" ,
102+ body = maybe_transform (
103+ {
104+ "anthropic_key_uuid" : anthropic_key_uuid ,
105+ "description" : description ,
106+ "instruction" : instruction ,
107+ "knowledge_base_uuid" : knowledge_base_uuid ,
108+ "model_uuid" : model_uuid ,
109+ "name" : name ,
110+ "openai_key_uuid" : openai_key_uuid ,
111+ "project_id" : project_id ,
112+ "region" : region ,
113+ "tags" : tags ,
114+ },
115+ agent_create_params .AgentCreateParams ,
116+ ),
117+ options = make_request_options (
118+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
119+ ),
120+ cast_to = AgentCreateResponse ,
121+ )
122+
123+ def list (
124+ self ,
125+ * ,
126+ only_deployed : bool | NotGiven = NOT_GIVEN ,
127+ page : int | NotGiven = NOT_GIVEN ,
128+ per_page : int | NotGiven = NOT_GIVEN ,
129+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
130+ # The extra values given here take precedence over values defined on the client or passed to this method.
131+ extra_headers : Headers | None = None ,
132+ extra_query : Query | None = None ,
133+ extra_body : Body | None = None ,
134+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
135+ ) -> AgentListResponse :
136+ """
137+ To list all agents, send a GET request to `/v2/gen-ai/agents`.
138+
139+ Args:
140+ only_deployed: only list agents that are deployed.
141+
142+ page: page number.
143+
144+ per_page: items per page.
145+
146+ extra_headers: Send extra headers
147+
148+ extra_query: Add additional query parameters to the request
149+
150+ extra_body: Add additional JSON properties to the request
151+
152+ timeout: Override the client-level default timeout for this request, in seconds
153+ """
154+ return self ._get (
155+ "/v2/gen-ai/agents" ,
156+ options = make_request_options (
157+ extra_headers = extra_headers ,
158+ extra_query = extra_query ,
159+ extra_body = extra_body ,
160+ timeout = timeout ,
161+ query = maybe_transform (
162+ {
163+ "only_deployed" : only_deployed ,
164+ "page" : page ,
165+ "per_page" : per_page ,
166+ },
167+ agent_list_params .AgentListParams ,
168+ ),
169+ ),
170+ cast_to = AgentListResponse ,
171+ )
172+
43173
44174class AsyncAgentsResource (AsyncAPIResource ):
45175 @cached_property
@@ -65,11 +195,132 @@ def with_streaming_response(self) -> AsyncAgentsResourceWithStreamingResponse:
65195 """
66196 return AsyncAgentsResourceWithStreamingResponse (self )
67197
198+ async def create (
199+ self ,
200+ * ,
201+ anthropic_key_uuid : str | NotGiven = NOT_GIVEN ,
202+ description : str | NotGiven = NOT_GIVEN ,
203+ instruction : str | NotGiven = NOT_GIVEN ,
204+ knowledge_base_uuid : List [str ] | NotGiven = NOT_GIVEN ,
205+ model_uuid : str | NotGiven = NOT_GIVEN ,
206+ name : str | NotGiven = NOT_GIVEN ,
207+ openai_key_uuid : str | NotGiven = NOT_GIVEN ,
208+ project_id : str | NotGiven = NOT_GIVEN ,
209+ region : str | NotGiven = NOT_GIVEN ,
210+ tags : List [str ] | NotGiven = NOT_GIVEN ,
211+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
212+ # The extra values given here take precedence over values defined on the client or passed to this method.
213+ extra_headers : Headers | None = None ,
214+ extra_query : Query | None = None ,
215+ extra_body : Body | None = None ,
216+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
217+ ) -> AgentCreateResponse :
218+ """To create a new agent, send a POST request to `/v2/gen-ai/agents`.
219+
220+ The response
221+ body contains a JSON object with the newly created agent object.
222+
223+ Args:
224+ instruction: Agent instruction. Instructions help your agent to perform its job effectively.
225+ See
226+ [Write Effective Agent Instructions](https://docs.digitalocean.com/products/genai-platform/concepts/best-practices/#agent-instructions)
227+ for best practices.
228+
229+ model_uuid: Identifier for the foundation model.
230+
231+ extra_headers: Send extra headers
232+
233+ extra_query: Add additional query parameters to the request
234+
235+ extra_body: Add additional JSON properties to the request
236+
237+ timeout: Override the client-level default timeout for this request, in seconds
238+ """
239+ return await self ._post (
240+ "/v2/gen-ai/agents" ,
241+ body = await async_maybe_transform (
242+ {
243+ "anthropic_key_uuid" : anthropic_key_uuid ,
244+ "description" : description ,
245+ "instruction" : instruction ,
246+ "knowledge_base_uuid" : knowledge_base_uuid ,
247+ "model_uuid" : model_uuid ,
248+ "name" : name ,
249+ "openai_key_uuid" : openai_key_uuid ,
250+ "project_id" : project_id ,
251+ "region" : region ,
252+ "tags" : tags ,
253+ },
254+ agent_create_params .AgentCreateParams ,
255+ ),
256+ options = make_request_options (
257+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
258+ ),
259+ cast_to = AgentCreateResponse ,
260+ )
261+
262+ async def list (
263+ self ,
264+ * ,
265+ only_deployed : bool | NotGiven = NOT_GIVEN ,
266+ page : int | NotGiven = NOT_GIVEN ,
267+ per_page : int | NotGiven = NOT_GIVEN ,
268+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
269+ # The extra values given here take precedence over values defined on the client or passed to this method.
270+ extra_headers : Headers | None = None ,
271+ extra_query : Query | None = None ,
272+ extra_body : Body | None = None ,
273+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
274+ ) -> AgentListResponse :
275+ """
276+ To list all agents, send a GET request to `/v2/gen-ai/agents`.
277+
278+ Args:
279+ only_deployed: only list agents that are deployed.
280+
281+ page: page number.
282+
283+ per_page: items per page.
284+
285+ extra_headers: Send extra headers
286+
287+ extra_query: Add additional query parameters to the request
288+
289+ extra_body: Add additional JSON properties to the request
290+
291+ timeout: Override the client-level default timeout for this request, in seconds
292+ """
293+ return await self ._get (
294+ "/v2/gen-ai/agents" ,
295+ options = make_request_options (
296+ extra_headers = extra_headers ,
297+ extra_query = extra_query ,
298+ extra_body = extra_body ,
299+ timeout = timeout ,
300+ query = await async_maybe_transform (
301+ {
302+ "only_deployed" : only_deployed ,
303+ "page" : page ,
304+ "per_page" : per_page ,
305+ },
306+ agent_list_params .AgentListParams ,
307+ ),
308+ ),
309+ cast_to = AgentListResponse ,
310+ )
311+
68312
69313class AgentsResourceWithRawResponse :
70314 def __init__ (self , agents : AgentsResource ) -> None :
71315 self ._agents = agents
72316
317+ self .create = to_raw_response_wrapper (
318+ agents .create ,
319+ )
320+ self .list = to_raw_response_wrapper (
321+ agents .list ,
322+ )
323+
73324 @cached_property
74325 def versions (self ) -> VersionsResourceWithRawResponse :
75326 return VersionsResourceWithRawResponse (self ._agents .versions )
@@ -79,6 +330,13 @@ class AsyncAgentsResourceWithRawResponse:
79330 def __init__ (self , agents : AsyncAgentsResource ) -> None :
80331 self ._agents = agents
81332
333+ self .create = async_to_raw_response_wrapper (
334+ agents .create ,
335+ )
336+ self .list = async_to_raw_response_wrapper (
337+ agents .list ,
338+ )
339+
82340 @cached_property
83341 def versions (self ) -> AsyncVersionsResourceWithRawResponse :
84342 return AsyncVersionsResourceWithRawResponse (self ._agents .versions )
@@ -88,6 +346,13 @@ class AgentsResourceWithStreamingResponse:
88346 def __init__ (self , agents : AgentsResource ) -> None :
89347 self ._agents = agents
90348
349+ self .create = to_streamed_response_wrapper (
350+ agents .create ,
351+ )
352+ self .list = to_streamed_response_wrapper (
353+ agents .list ,
354+ )
355+
91356 @cached_property
92357 def versions (self ) -> VersionsResourceWithStreamingResponse :
93358 return VersionsResourceWithStreamingResponse (self ._agents .versions )
@@ -97,6 +362,13 @@ class AsyncAgentsResourceWithStreamingResponse:
97362 def __init__ (self , agents : AsyncAgentsResource ) -> None :
98363 self ._agents = agents
99364
365+ self .create = async_to_streamed_response_wrapper (
366+ agents .create ,
367+ )
368+ self .list = async_to_streamed_response_wrapper (
369+ agents .list ,
370+ )
371+
100372 @cached_property
101373 def versions (self ) -> AsyncVersionsResourceWithStreamingResponse :
102374 return AsyncVersionsResourceWithStreamingResponse (self ._agents .versions )
0 commit comments