Skip to content

Commit 362234a

Browse files
update internal repo to use stainless python sdk with latest deployment
1 parent da13f51 commit 362234a

36 files changed

+1796
-29
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 36
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cleanlab%2Fagility-36e7c2cdfead9cc1628d9e75a9be97a5580130287e8610c5bceac14770743512.yml
1+
configured_endpoints: 42
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cleanlab%2Fagility-4abd340ba528b5912ad6672a203de3c6904577d27b3397533d51d3ddc265339f.yml

api.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,43 @@ Methods:
143143
- <code title="get /api/threads/{thread_id}/runs/{run_id}">client.threads.runs.<a href="./src/agility/resources/threads/runs.py">retrieve</a>(run_id, \*, thread_id) -> <a href="./src/agility/types/threads/run.py">Run</a></code>
144144
- <code title="delete /api/threads/{thread_id}/runs/{run_id}">client.threads.runs.<a href="./src/agility/resources/threads/runs.py">delete</a>(run_id, \*, thread_id) -> None</code>
145145
- <code title="post /api/threads/{thread_id}/runs/stream">client.threads.runs.<a href="./src/agility/resources/threads/runs.py">stream</a>(thread_id, \*\*<a href="src/agility/types/threads/run_stream_params.py">params</a>) -> <a href="./src/agility/types/threads/run_stream_response.py">object</a></code>
146+
147+
# Integrations
148+
149+
Types:
150+
151+
```python
152+
from agility.types import (
153+
GcSv0Integration,
154+
Integration,
155+
S3V0Integration,
156+
IntegrationCreateResponse,
157+
IntegrationRetrieveResponse,
158+
IntegrationListResponse,
159+
)
160+
```
161+
162+
Methods:
163+
164+
- <code title="post /api/integrations/">client.integrations.<a href="./src/agility/resources/integrations/integrations.py">create</a>(\*\*<a href="src/agility/types/integration_create_params.py">params</a>) -> <a href="./src/agility/types/integration_create_response.py">IntegrationCreateResponse</a></code>
165+
- <code title="get /api/integrations/{integration_id}">client.integrations.<a href="./src/agility/resources/integrations/integrations.py">retrieve</a>(integration_id) -> <a href="./src/agility/types/integration_retrieve_response.py">IntegrationRetrieveResponse</a></code>
166+
- <code title="get /api/integrations/">client.integrations.<a href="./src/agility/resources/integrations/integrations.py">list</a>(\*\*<a href="src/agility/types/integration_list_params.py">params</a>) -> <a href="./src/agility/types/integration_list_response.py">SyncMyOffsetPage[IntegrationListResponse]</a></code>
167+
- <code title="delete /api/integrations/{integration_id}">client.integrations.<a href="./src/agility/resources/integrations/integrations.py">delete</a>(integration_id) -> None</code>
168+
169+
## Available
170+
171+
Types:
172+
173+
```python
174+
from agility.types.integrations import IntegrationTypeDef, AvailableListResponse
175+
```
176+
177+
Methods:
178+
179+
- <code title="get /api/integrations/available">client.integrations.available.<a href="./src/agility/resources/integrations/available.py">list</a>() -> <a href="./src/agility/types/integrations/available_list_response.py">AvailableListResponse</a></code>
180+
181+
## Rbac
182+
183+
Methods:
184+
185+
- <code title="post /api/integrations/rbac/{integration_id}/verify">client.integrations.rbac.<a href="./src/agility/resources/integrations/rbac.py">verify</a>(integration_id) -> <a href="./src/agility/types/integration.py">Integration</a></code>

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ dependencies = [
1616
"sniffio",
1717
"cached-property; python_version < '3.8'",
1818
]
19-
requires-python = ">= 3.7"
19+
requires-python = ">= 3.8"
2020
classifiers = [
2121
"Typing :: Typed",
2222
"Intended Audience :: Developers",
23-
"Programming Language :: Python :: 3.7",
2423
"Programming Language :: Python :: 3.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
@@ -139,7 +138,7 @@ filterwarnings = [
139138
# there are a couple of flags that are still disabled by
140139
# default in strict mode as they are experimental and niche.
141140
typeCheckingMode = "strict"
142-
pythonVersion = "3.7"
141+
pythonVersion = "3.8"
143142

144143
exclude = [
145144
"_dev",

src/agility/_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Agility(SyncAPIClient):
5858
knowledge_bases: resources.KnowledgeBasesResource
5959
users: resources.UsersResource
6060
threads: resources.ThreadsResource
61+
integrations: resources.IntegrationsResource
6162
with_raw_response: AgilityWithRawResponse
6263
with_streaming_response: AgilityWithStreamedResponse
6364

@@ -158,6 +159,7 @@ def __init__(
158159
self.knowledge_bases = resources.KnowledgeBasesResource(self)
159160
self.users = resources.UsersResource(self)
160161
self.threads = resources.ThreadsResource(self)
162+
self.integrations = resources.IntegrationsResource(self)
161163
self.with_raw_response = AgilityWithRawResponse(self)
162164
self.with_streaming_response = AgilityWithStreamedResponse(self)
163165

@@ -301,6 +303,7 @@ class AsyncAgility(AsyncAPIClient):
301303
knowledge_bases: resources.AsyncKnowledgeBasesResource
302304
users: resources.AsyncUsersResource
303305
threads: resources.AsyncThreadsResource
306+
integrations: resources.AsyncIntegrationsResource
304307
with_raw_response: AsyncAgilityWithRawResponse
305308
with_streaming_response: AsyncAgilityWithStreamedResponse
306309

@@ -401,6 +404,7 @@ def __init__(
401404
self.knowledge_bases = resources.AsyncKnowledgeBasesResource(self)
402405
self.users = resources.AsyncUsersResource(self)
403406
self.threads = resources.AsyncThreadsResource(self)
407+
self.integrations = resources.AsyncIntegrationsResource(self)
404408
self.with_raw_response = AsyncAgilityWithRawResponse(self)
405409
self.with_streaming_response = AsyncAgilityWithStreamedResponse(self)
406410

@@ -545,6 +549,7 @@ def __init__(self, client: Agility) -> None:
545549
self.knowledge_bases = resources.KnowledgeBasesResourceWithRawResponse(client.knowledge_bases)
546550
self.users = resources.UsersResourceWithRawResponse(client.users)
547551
self.threads = resources.ThreadsResourceWithRawResponse(client.threads)
552+
self.integrations = resources.IntegrationsResourceWithRawResponse(client.integrations)
548553

549554

550555
class AsyncAgilityWithRawResponse:
@@ -553,6 +558,7 @@ def __init__(self, client: AsyncAgility) -> None:
553558
self.knowledge_bases = resources.AsyncKnowledgeBasesResourceWithRawResponse(client.knowledge_bases)
554559
self.users = resources.AsyncUsersResourceWithRawResponse(client.users)
555560
self.threads = resources.AsyncThreadsResourceWithRawResponse(client.threads)
561+
self.integrations = resources.AsyncIntegrationsResourceWithRawResponse(client.integrations)
556562

557563

558564
class AgilityWithStreamedResponse:
@@ -561,6 +567,7 @@ def __init__(self, client: Agility) -> None:
561567
self.knowledge_bases = resources.KnowledgeBasesResourceWithStreamingResponse(client.knowledge_bases)
562568
self.users = resources.UsersResourceWithStreamingResponse(client.users)
563569
self.threads = resources.ThreadsResourceWithStreamingResponse(client.threads)
570+
self.integrations = resources.IntegrationsResourceWithStreamingResponse(client.integrations)
564571

565572

566573
class AsyncAgilityWithStreamedResponse:
@@ -569,6 +576,7 @@ def __init__(self, client: AsyncAgility) -> None:
569576
self.knowledge_bases = resources.AsyncKnowledgeBasesResourceWithStreamingResponse(client.knowledge_bases)
570577
self.users = resources.AsyncUsersResourceWithStreamingResponse(client.users)
571578
self.threads = resources.AsyncThreadsResourceWithStreamingResponse(client.threads)
579+
self.integrations = resources.AsyncIntegrationsResourceWithStreamingResponse(client.integrations)
572580

573581

574582
Client = Agility

src/agility/_compat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
44
from datetime import date, datetime
5-
from typing_extensions import Self
5+
from typing_extensions import Self, Literal
66

77
import pydantic
88
from pydantic.fields import FieldInfo
@@ -137,9 +137,11 @@ def model_dump(
137137
exclude_unset: bool = False,
138138
exclude_defaults: bool = False,
139139
warnings: bool = True,
140+
mode: Literal["json", "python"] = "python",
140141
) -> dict[str, Any]:
141-
if PYDANTIC_V2:
142+
if PYDANTIC_V2 or hasattr(model, "model_dump"):
142143
return model.model_dump(
144+
mode=mode,
143145
exclude=exclude,
144146
exclude_unset=exclude_unset,
145147
exclude_defaults=exclude_defaults,

src/agility/_models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
PropertyInfo,
3838
is_list,
3939
is_given,
40+
json_safe,
4041
lru_cache,
4142
is_mapping,
4243
parse_date,
@@ -279,8 +280,8 @@ def model_dump(
279280
Returns:
280281
A dictionary representation of the model.
281282
"""
282-
if mode != "python":
283-
raise ValueError("mode is only supported in Pydantic v2")
283+
if mode not in {"json", "python"}:
284+
raise ValueError("mode must be either 'json' or 'python'")
284285
if round_trip != False:
285286
raise ValueError("round_trip is only supported in Pydantic v2")
286287
if warnings != True:
@@ -289,7 +290,7 @@ def model_dump(
289290
raise ValueError("context is only supported in Pydantic v2")
290291
if serialize_as_any != False:
291292
raise ValueError("serialize_as_any is only supported in Pydantic v2")
292-
return super().dict( # pyright: ignore[reportDeprecated]
293+
dumped = super().dict( # pyright: ignore[reportDeprecated]
293294
include=include,
294295
exclude=exclude,
295296
by_alias=by_alias,
@@ -298,6 +299,8 @@ def model_dump(
298299
exclude_none=exclude_none,
299300
)
300301

302+
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
303+
301304
@override
302305
def model_dump_json(
303306
self,

src/agility/_utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
is_list as is_list,
77
is_given as is_given,
88
is_tuple as is_tuple,
9+
json_safe as json_safe,
910
lru_cache as lru_cache,
1011
is_mapping as is_mapping,
1112
is_tuple_t as is_tuple_t,

src/agility/_utils/_transform.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def _transform_recursive(
173173
# Iterable[T]
174174
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
175175
):
176+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
177+
# intended as an iterable, so we don't transform it.
178+
if isinstance(data, dict):
179+
return cast(object, data)
180+
176181
inner_type = extract_type_arg(stripped_type, 0)
177182
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
178183

@@ -186,7 +191,7 @@ def _transform_recursive(
186191
return data
187192

188193
if isinstance(data, pydantic.BaseModel):
189-
return model_dump(data, exclude_unset=True)
194+
return model_dump(data, exclude_unset=True, mode="json")
190195

191196
annotated_type = _get_annotated_type(annotation)
192197
if annotated_type is None:
@@ -324,7 +329,7 @@ async def _async_transform_recursive(
324329
return data
325330

326331
if isinstance(data, pydantic.BaseModel):
327-
return model_dump(data, exclude_unset=True)
332+
return model_dump(data, exclude_unset=True, mode="json")
328333

329334
annotated_type = _get_annotated_type(annotation)
330335
if annotated_type is None:

src/agility/_utils/_utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
overload,
1717
)
1818
from pathlib import Path
19+
from datetime import date, datetime
1920
from typing_extensions import TypeGuard
2021

2122
import sniffio
@@ -395,3 +396,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
395396
maxsize=maxsize,
396397
)
397398
return cast(Any, wrapper) # type: ignore[no-any-return]
399+
400+
401+
def json_safe(data: object) -> object:
402+
"""Translates a mapping / sequence recursively in the same fashion
403+
as `pydantic` v2's `model_dump(mode="json")`.
404+
"""
405+
if is_mapping(data):
406+
return {json_safe(key): json_safe(value) for key, value in data.items()}
407+
408+
if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
409+
return [json_safe(item) for item in data]
410+
411+
if isinstance(data, (datetime, date)):
412+
return data.isoformat()
413+
414+
return data

src/agility/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
AssistantsResourceWithStreamingResponse,
2525
AsyncAssistantsResourceWithStreamingResponse,
2626
)
27+
from .integrations import (
28+
IntegrationsResource,
29+
AsyncIntegrationsResource,
30+
IntegrationsResourceWithRawResponse,
31+
AsyncIntegrationsResourceWithRawResponse,
32+
IntegrationsResourceWithStreamingResponse,
33+
AsyncIntegrationsResourceWithStreamingResponse,
34+
)
2735
from .knowledge_bases import (
2836
KnowledgeBasesResource,
2937
AsyncKnowledgeBasesResource,
@@ -58,4 +66,10 @@
5866
"AsyncThreadsResourceWithRawResponse",
5967
"ThreadsResourceWithStreamingResponse",
6068
"AsyncThreadsResourceWithStreamingResponse",
69+
"IntegrationsResource",
70+
"AsyncIntegrationsResource",
71+
"IntegrationsResourceWithRawResponse",
72+
"AsyncIntegrationsResourceWithRawResponse",
73+
"IntegrationsResourceWithStreamingResponse",
74+
"AsyncIntegrationsResourceWithStreamingResponse",
6175
]

0 commit comments

Comments
 (0)