Skip to content

Commit eef8a87

Browse files
feat(api): update via SDK Studio (#16)
1 parent d496425 commit eef8a87

38 files changed

+363
-2098
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 39
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-478f305e228bf07625e8d1166c8a8d2a38c532d27012ce7ed906d0a3728f26f9.yml
1+
configured_endpoints: 33
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-4ed32c3243ce7a772e55bb1ba204736fc3fb1d712d8ca0eb91bac0c7ac626938.yml

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ first_page = await client.agents.list()
121121
if first_page.has_next_page():
122122
print(f"will fetch next page using these details: {first_page.next_page_info()}")
123123
next_page = await first_page.get_next_page()
124-
print(f"number of items we just fetched: {len(next_page.data)}")
124+
print(f"number of items we just fetched: {len(next_page.agents)}")
125125

126126
# Remove `await` for non-async usage.
127127
```
@@ -132,7 +132,7 @@ Or just work directly with the returned data:
132132
first_page = await client.agents.list()
133133

134134
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
135-
for agent in first_page.data:
135+
for agent in first_page.agents:
136136
print(agent.id)
137137

138138
# Remove `await` for non-async usage.

api.md

+1-18
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Methods:
5858

5959
- <code title="post /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">create</a>(\*\*<a href="src/contextual/types/agent_create_params.py">params</a>) -> <a href="./src/contextual/types/create_agent_output.py">CreateAgentOutput</a></code>
6060
- <code title="put /agents/{agent_id}">client.agents.<a href="./src/contextual/resources/agents/agents.py">update</a>(agent_id, \*\*<a href="src/contextual/types/agent_update_params.py">params</a>) -> <a href="./src/contextual/types/agent_update_response.py">object</a></code>
61-
- <code title="get /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">list</a>(\*\*<a href="src/contextual/types/agent_list_params.py">params</a>) -> <a href="./src/contextual/types/agent.py">SyncPage[Agent]</a></code>
61+
- <code title="get /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">list</a>(\*\*<a href="src/contextual/types/agent_list_params.py">params</a>) -> <a href="./src/contextual/types/agent.py">SyncAgentsPage[Agent]</a></code>
6262
- <code title="delete /agents/{agent_id}">client.agents.<a href="./src/contextual/resources/agents/agents.py">delete</a>(agent_id) -> <a href="./src/contextual/types/agent_delete_response.py">object</a></code>
6363
- <code title="get /agents/{agent_id}/metadata">client.agents.<a href="./src/contextual/resources/agents/agents.py">metadata</a>(agent_id) -> <a href="./src/contextual/types/agent_metadata.py">AgentMetadata</a></code>
6464

@@ -120,23 +120,6 @@ Types:
120120
from contextual.types.agents import CreateDatasetResponse, DatasetMetadata, ListDatasetsResponse
121121
```
122122

123-
### Tune
124-
125-
Types:
126-
127-
```python
128-
from contextual.types.agents.datasets import TuneDeleteResponse
129-
```
130-
131-
Methods:
132-
133-
- <code title="post /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">create</a>(agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_create_params.py">params</a>) -> <a href="./src/contextual/types/agents/create_dataset_response.py">CreateDatasetResponse</a></code>
134-
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">retrieve</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_retrieve_params.py">params</a>) -> BinaryAPIResponse</code>
135-
- <code title="put /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">update</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_update_params.py">params</a>) -> <a href="./src/contextual/types/agents/create_dataset_response.py">CreateDatasetResponse</a></code>
136-
- <code title="get /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">list</a>(agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_list_params.py">params</a>) -> <a href="./src/contextual/types/agents/list_datasets_response.py">ListDatasetsResponse</a></code>
137-
- <code title="delete /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">delete</a>(dataset_name, \*, agent_id) -> <a href="./src/contextual/types/agents/datasets/tune_delete_response.py">object</a></code>
138-
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}/metadata">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">metadata</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_metadata_params.py">params</a>) -> <a href="./src/contextual/types/agents/dataset_metadata.py">DatasetMetadata</a></code>
139-
140123
### Evaluate
141124

142125
Types:

src/contextual/pagination.py

+42
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"AsyncDatastoresPage",
1111
"SyncDocumentsPage",
1212
"AsyncDocumentsPage",
13+
"SyncAgentsPage",
14+
"AsyncAgentsPage",
1315
"SyncPage",
1416
"AsyncPage",
1517
]
@@ -97,6 +99,46 @@ def next_page_info(self) -> Optional[PageInfo]:
9799
return PageInfo(params={"cursor": next_cursor})
98100

99101

102+
class SyncAgentsPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
103+
agents: List[_T]
104+
next_cursor: Optional[str] = None
105+
106+
@override
107+
def _get_page_items(self) -> List[_T]:
108+
agents = self.agents
109+
if not agents:
110+
return []
111+
return agents
112+
113+
@override
114+
def next_page_info(self) -> Optional[PageInfo]:
115+
next_cursor = self.next_cursor
116+
if not next_cursor:
117+
return None
118+
119+
return PageInfo(params={"cursor": next_cursor})
120+
121+
122+
class AsyncAgentsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
123+
agents: List[_T]
124+
next_cursor: Optional[str] = None
125+
126+
@override
127+
def _get_page_items(self) -> List[_T]:
128+
agents = self.agents
129+
if not agents:
130+
return []
131+
return agents
132+
133+
@override
134+
def next_page_info(self) -> Optional[PageInfo]:
135+
next_cursor = self.next_cursor
136+
if not next_cursor:
137+
return None
138+
139+
return PageInfo(params={"cursor": next_cursor})
140+
141+
100142
class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
101143
data: List[_T]
102144
next_cursor: Optional[str] = None

src/contextual/resources/agents/agents.py

+21-23
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
async_to_raw_response_wrapper,
3737
async_to_streamed_response_wrapper,
3838
)
39-
from ...pagination import SyncPage, AsyncPage
39+
from ...pagination import SyncAgentsPage, AsyncAgentsPage
4040
from ...types.agent import Agent
4141
from ..._base_client import AsyncPaginator, make_request_options
4242
from .datasets.datasets import (
@@ -115,8 +115,8 @@ def create(
115115
"""
116116
Create a new `Agent` with a specific configuration.
117117
118-
This creates a specialized RAG `Agent` which queries over a `Datastore` to
119-
retrieve relevant data on which its generations are grounded.
118+
This creates a specialized RAG `Agent` which queries over one or multiple
119+
`Datastores` to retrieve relevant data on which its generations are grounded.
120120
121121
Retrieval and generation parameters are defined in the provided `Agent`
122122
configuration.
@@ -188,14 +188,13 @@ def update(
188188
Fields not included in the request body will not be modified.
189189
190190
Args:
191-
agent_id: Agent ID of the agent to edit
191+
agent_id: ID of the agent to edit
192192
193193
datastore_ids: IDs of the datastore to associate with the agent.
194194
195-
llm_model_id: Optional model ID of a tuned model to use for generation. Model must have been
196-
tuned on this agent; tuned models cannot be used across agents. Uses default
197-
model if none is specified. Set to `default` to deactivate the tuned model and
198-
use the default model.
195+
llm_model_id: The model ID to use for generation. Tuned models can only be used for the agents
196+
on which they were tuned. If no model is specified, the default model is used.
197+
Set to `default` to switch from a tuned model to the default model.
199198
200199
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
201200
the agent. We recommend including common queries that users will ask, as well as
@@ -243,7 +242,7 @@ def list(
243242
extra_query: Query | None = None,
244243
extra_body: Body | None = None,
245244
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
246-
) -> SyncPage[Agent]:
245+
) -> SyncAgentsPage[Agent]:
247246
"""
248247
Retrieve a list of all `Agents`.
249248
@@ -263,7 +262,7 @@ def list(
263262
"""
264263
return self._get_api_list(
265264
"/agents",
266-
page=SyncPage[Agent],
265+
page=SyncAgentsPage[Agent],
267266
options=make_request_options(
268267
extra_headers=extra_headers,
269268
extra_query=extra_query,
@@ -300,7 +299,7 @@ def delete(
300299
`DELETE /datastores/{datastore_id}` API.
301300
302301
Args:
303-
agent_id: Agent ID of the agent to delete
302+
agent_id: ID of the agent to delete
304303
305304
extra_headers: Send extra headers
306305
@@ -335,7 +334,7 @@ def metadata(
335334
Get metadata and configuration of a given `Agent`.
336335
337336
Args:
338-
agent_id: Agent ID of the agent to retrieve details for
337+
agent_id: ID of the agent for which to retrieve details
339338
340339
extra_headers: Send extra headers
341340
@@ -410,8 +409,8 @@ async def create(
410409
"""
411410
Create a new `Agent` with a specific configuration.
412411
413-
This creates a specialized RAG `Agent` which queries over a `Datastore` to
414-
retrieve relevant data on which its generations are grounded.
412+
This creates a specialized RAG `Agent` which queries over one or multiple
413+
`Datastores` to retrieve relevant data on which its generations are grounded.
415414
416415
Retrieval and generation parameters are defined in the provided `Agent`
417416
configuration.
@@ -483,14 +482,13 @@ async def update(
483482
Fields not included in the request body will not be modified.
484483
485484
Args:
486-
agent_id: Agent ID of the agent to edit
485+
agent_id: ID of the agent to edit
487486
488487
datastore_ids: IDs of the datastore to associate with the agent.
489488
490-
llm_model_id: Optional model ID of a tuned model to use for generation. Model must have been
491-
tuned on this agent; tuned models cannot be used across agents. Uses default
492-
model if none is specified. Set to `default` to deactivate the tuned model and
493-
use the default model.
489+
llm_model_id: The model ID to use for generation. Tuned models can only be used for the agents
490+
on which they were tuned. If no model is specified, the default model is used.
491+
Set to `default` to switch from a tuned model to the default model.
494492
495493
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
496494
the agent. We recommend including common queries that users will ask, as well as
@@ -538,7 +536,7 @@ def list(
538536
extra_query: Query | None = None,
539537
extra_body: Body | None = None,
540538
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
541-
) -> AsyncPaginator[Agent, AsyncPage[Agent]]:
539+
) -> AsyncPaginator[Agent, AsyncAgentsPage[Agent]]:
542540
"""
543541
Retrieve a list of all `Agents`.
544542
@@ -558,7 +556,7 @@ def list(
558556
"""
559557
return self._get_api_list(
560558
"/agents",
561-
page=AsyncPage[Agent],
559+
page=AsyncAgentsPage[Agent],
562560
options=make_request_options(
563561
extra_headers=extra_headers,
564562
extra_query=extra_query,
@@ -595,7 +593,7 @@ async def delete(
595593
`DELETE /datastores/{datastore_id}` API.
596594
597595
Args:
598-
agent_id: Agent ID of the agent to delete
596+
agent_id: ID of the agent to delete
599597
600598
extra_headers: Send extra headers
601599
@@ -630,7 +628,7 @@ async def metadata(
630628
Get metadata and configuration of a given `Agent`.
631629
632630
Args:
633-
agent_id: Agent ID of the agent to retrieve details for
631+
agent_id: ID of the agent for which to retrieve details
634632
635633
extra_headers: Send extra headers
636634

src/contextual/resources/agents/datasets/__init__.py

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

3-
from .tune import (
4-
TuneResource,
5-
AsyncTuneResource,
6-
TuneResourceWithRawResponse,
7-
AsyncTuneResourceWithRawResponse,
8-
TuneResourceWithStreamingResponse,
9-
AsyncTuneResourceWithStreamingResponse,
10-
)
113
from .datasets import (
124
DatasetsResource,
135
AsyncDatasetsResource,
@@ -26,12 +18,6 @@
2618
)
2719

2820
__all__ = [
29-
"TuneResource",
30-
"AsyncTuneResource",
31-
"TuneResourceWithRawResponse",
32-
"AsyncTuneResourceWithRawResponse",
33-
"TuneResourceWithStreamingResponse",
34-
"AsyncTuneResourceWithStreamingResponse",
3521
"EvaluateResource",
3622
"AsyncEvaluateResource",
3723
"EvaluateResourceWithRawResponse",

src/contextual/resources/agents/datasets/datasets.py

-32
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .tune import (
6-
TuneResource,
7-
AsyncTuneResource,
8-
TuneResourceWithRawResponse,
9-
AsyncTuneResourceWithRawResponse,
10-
TuneResourceWithStreamingResponse,
11-
AsyncTuneResourceWithStreamingResponse,
12-
)
135
from .evaluate import (
146
EvaluateResource,
157
AsyncEvaluateResource,
@@ -25,10 +17,6 @@
2517

2618

2719
class DatasetsResource(SyncAPIResource):
28-
@cached_property
29-
def tune(self) -> TuneResource:
30-
return TuneResource(self._client)
31-
3220
@cached_property
3321
def evaluate(self) -> EvaluateResource:
3422
return EvaluateResource(self._client)
@@ -54,10 +42,6 @@ def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse:
5442

5543

5644
class AsyncDatasetsResource(AsyncAPIResource):
57-
@cached_property
58-
def tune(self) -> AsyncTuneResource:
59-
return AsyncTuneResource(self._client)
60-
6145
@cached_property
6246
def evaluate(self) -> AsyncEvaluateResource:
6347
return AsyncEvaluateResource(self._client)
@@ -86,10 +70,6 @@ class DatasetsResourceWithRawResponse:
8670
def __init__(self, datasets: DatasetsResource) -> None:
8771
self._datasets = datasets
8872

89-
@cached_property
90-
def tune(self) -> TuneResourceWithRawResponse:
91-
return TuneResourceWithRawResponse(self._datasets.tune)
92-
9373
@cached_property
9474
def evaluate(self) -> EvaluateResourceWithRawResponse:
9575
return EvaluateResourceWithRawResponse(self._datasets.evaluate)
@@ -99,10 +79,6 @@ class AsyncDatasetsResourceWithRawResponse:
9979
def __init__(self, datasets: AsyncDatasetsResource) -> None:
10080
self._datasets = datasets
10181

102-
@cached_property
103-
def tune(self) -> AsyncTuneResourceWithRawResponse:
104-
return AsyncTuneResourceWithRawResponse(self._datasets.tune)
105-
10682
@cached_property
10783
def evaluate(self) -> AsyncEvaluateResourceWithRawResponse:
10884
return AsyncEvaluateResourceWithRawResponse(self._datasets.evaluate)
@@ -112,10 +88,6 @@ class DatasetsResourceWithStreamingResponse:
11288
def __init__(self, datasets: DatasetsResource) -> None:
11389
self._datasets = datasets
11490

115-
@cached_property
116-
def tune(self) -> TuneResourceWithStreamingResponse:
117-
return TuneResourceWithStreamingResponse(self._datasets.tune)
118-
11991
@cached_property
12092
def evaluate(self) -> EvaluateResourceWithStreamingResponse:
12193
return EvaluateResourceWithStreamingResponse(self._datasets.evaluate)
@@ -125,10 +97,6 @@ class AsyncDatasetsResourceWithStreamingResponse:
12597
def __init__(self, datasets: AsyncDatasetsResource) -> None:
12698
self._datasets = datasets
12799

128-
@cached_property
129-
def tune(self) -> AsyncTuneResourceWithStreamingResponse:
130-
return AsyncTuneResourceWithStreamingResponse(self._datasets.tune)
131-
132100
@cached_property
133101
def evaluate(self) -> AsyncEvaluateResourceWithStreamingResponse:
134102
return AsyncEvaluateResourceWithStreamingResponse(self._datasets.evaluate)

0 commit comments

Comments
 (0)