Skip to content

Commit 7e9de5d

Browse files
feat(api): updates from question grouping (#93)
1 parent 2ebabc0 commit 7e9de5d

19 files changed

+771
-682
lines changed

.stats.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
configured_endpoints: 37
2-
openapi_spec_hash: 6993cffe14e021af26bf142f5b557263
3-
config_hash: 0529917e0e61d8cd6366481b77eff77e
1+
configured_endpoints: 36
2+
openapi_spec_hash: 4e7cb2cd6132c29f60a87a958f617a41
3+
config_hash: adbedb6317fca6f566f54564cc341846

api.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Methods:
1010

1111
- <code title="get /api/health/">client.health.<a href="./src/codex/resources/health.py">check</a>() -> <a href="./src/codex/types/health_check_response.py">HealthCheckResponse</a></code>
1212
- <code title="get /api/health/db">client.health.<a href="./src/codex/resources/health.py">db</a>() -> <a href="./src/codex/types/health_check_response.py">HealthCheckResponse</a></code>
13-
- <code title="get /api/health/weaviate">client.health.<a href="./src/codex/resources/health.py">weaviate</a>() -> <a href="./src/codex/types/health_check_response.py">HealthCheckResponse</a></code>
1413

1514
# Organizations
1615

@@ -175,18 +174,29 @@ Methods:
175174
Types:
176175

177176
```python
178-
from codex.types.projects import Entry
177+
from codex.types.projects import Entry, EntryQueryResponse
179178
```
180179

181180
Methods:
182181

183182
- <code title="post /api/projects/{project_id}/entries/">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">create</a>(project_id, \*\*<a href="src/codex/types/projects/entry_create_params.py">params</a>) -> <a href="./src/codex/types/projects/entry.py">Entry</a></code>
184183
- <code title="get /api/projects/{project_id}/entries/{entry_id}">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">retrieve</a>(entry_id, \*, project_id) -> <a href="./src/codex/types/projects/entry.py">Entry</a></code>
185184
- <code title="put /api/projects/{project_id}/entries/{entry_id}">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">update</a>(entry_id, \*, project_id, \*\*<a href="src/codex/types/projects/entry_update_params.py">params</a>) -> <a href="./src/codex/types/projects/entry.py">Entry</a></code>
186-
- <code title="get /api/projects/{project_id}/entries/">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">list</a>(project_id, \*\*<a href="src/codex/types/projects/entry_list_params.py">params</a>) -> <a href="./src/codex/types/projects/entry.py">SyncOffsetPageEntries[Entry]</a></code>
187185
- <code title="delete /api/projects/{project_id}/entries/{entry_id}">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">delete</a>(entry_id, \*, project_id) -> None</code>
188-
- <code title="post /api/projects/{project_id}/entries/add_question">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">add_question</a>(project_id, \*\*<a href="src/codex/types/projects/entry_add_question_params.py">params</a>) -> <a href="./src/codex/types/projects/entry.py">Entry</a></code>
189-
- <code title="post /api/projects/{project_id}/entries/query">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">query</a>(project_id, \*\*<a href="src/codex/types/projects/entry_query_params.py">params</a>) -> <a href="./src/codex/types/projects/entry.py">Optional[Entry]</a></code>
186+
- <code title="post /api/projects/{project_id}/entries/query">client.projects.entries.<a href="./src/codex/resources/projects/entries.py">query</a>(project_id, \*\*<a href="src/codex/types/projects/entry_query_params.py">params</a>) -> <a href="./src/codex/types/projects/entry_query_response.py">EntryQueryResponse</a></code>
187+
188+
## Clusters
189+
190+
Types:
191+
192+
```python
193+
from codex.types.projects import ClusterListResponse, ClusterListVariantsResponse
194+
```
195+
196+
Methods:
197+
198+
- <code title="get /api/projects/{project_id}/entries/clusters">client.projects.clusters.<a href="./src/codex/resources/projects/clusters.py">list</a>(project_id, \*\*<a href="src/codex/types/projects/cluster_list_params.py">params</a>) -> <a href="./src/codex/types/projects/cluster_list_response.py">SyncOffsetPageClusters[ClusterListResponse]</a></code>
199+
- <code title="get /api/projects/{project_id}/entries/clusters/{representative_entry_id}">client.projects.clusters.<a href="./src/codex/resources/projects/clusters.py">list_variants</a>(representative_entry_id, \*, project_id) -> <a href="./src/codex/types/projects/cluster_list_variants_response.py">ClusterListVariantsResponse</a></code>
190200

191201
# Tlm
192202

src/codex/pagination.py

+62
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
__all__ = [
1313
"SyncMyOffsetPageTopLevelArray",
1414
"AsyncMyOffsetPageTopLevelArray",
15+
"SyncOffsetPageClusters",
16+
"AsyncOffsetPageClusters",
1517
"SyncOffsetPageEntries",
1618
"AsyncOffsetPageEntries",
1719
]
@@ -83,6 +85,66 @@ def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseM
8385
)
8486

8587

88+
class SyncOffsetPageClusters(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
89+
clusters: List[_T]
90+
total_count: Optional[int] = None
91+
92+
@override
93+
def _get_page_items(self) -> List[_T]:
94+
clusters = self.clusters
95+
if not clusters:
96+
return []
97+
return clusters
98+
99+
@override
100+
def next_page_info(self) -> Optional[PageInfo]:
101+
offset = self._options.params.get("offset") or 0
102+
if not isinstance(offset, int):
103+
raise ValueError(f'Expected "offset" param to be an integer but got {offset}')
104+
105+
length = len(self._get_page_items())
106+
current_count = offset + length
107+
108+
total_count = self.total_count
109+
if total_count is None:
110+
return None
111+
112+
if current_count < total_count:
113+
return PageInfo(params={"offset": current_count})
114+
115+
return None
116+
117+
118+
class AsyncOffsetPageClusters(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
119+
clusters: List[_T]
120+
total_count: Optional[int] = None
121+
122+
@override
123+
def _get_page_items(self) -> List[_T]:
124+
clusters = self.clusters
125+
if not clusters:
126+
return []
127+
return clusters
128+
129+
@override
130+
def next_page_info(self) -> Optional[PageInfo]:
131+
offset = self._options.params.get("offset") or 0
132+
if not isinstance(offset, int):
133+
raise ValueError(f'Expected "offset" param to be an integer but got {offset}')
134+
135+
length = len(self._get_page_items())
136+
current_count = offset + length
137+
138+
total_count = self.total_count
139+
if total_count is None:
140+
return None
141+
142+
if current_count < total_count:
143+
return PageInfo(params={"offset": current_count})
144+
145+
return None
146+
147+
86148
class SyncOffsetPageEntries(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
87149
entries: List[_T]
88150
total_count: Optional[int] = None

src/codex/resources/health.py

-50
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,6 @@ def db(
7777
cast_to=HealthCheckResponse,
7878
)
7979

80-
def weaviate(
81-
self,
82-
*,
83-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
84-
# The extra values given here take precedence over values defined on the client or passed to this method.
85-
extra_headers: Headers | None = None,
86-
extra_query: Query | None = None,
87-
extra_body: Body | None = None,
88-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
89-
) -> HealthCheckResponse:
90-
"""Check the weaviate connection."""
91-
return self._get(
92-
"/api/health/weaviate",
93-
options=make_request_options(
94-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
95-
),
96-
cast_to=HealthCheckResponse,
97-
)
98-
9980

10081
class AsyncHealthResource(AsyncAPIResource):
10182
@cached_property
@@ -155,25 +136,6 @@ async def db(
155136
cast_to=HealthCheckResponse,
156137
)
157138

158-
async def weaviate(
159-
self,
160-
*,
161-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
162-
# The extra values given here take precedence over values defined on the client or passed to this method.
163-
extra_headers: Headers | None = None,
164-
extra_query: Query | None = None,
165-
extra_body: Body | None = None,
166-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
167-
) -> HealthCheckResponse:
168-
"""Check the weaviate connection."""
169-
return await self._get(
170-
"/api/health/weaviate",
171-
options=make_request_options(
172-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
173-
),
174-
cast_to=HealthCheckResponse,
175-
)
176-
177139

178140
class HealthResourceWithRawResponse:
179141
def __init__(self, health: HealthResource) -> None:
@@ -185,9 +147,6 @@ def __init__(self, health: HealthResource) -> None:
185147
self.db = to_raw_response_wrapper(
186148
health.db,
187149
)
188-
self.weaviate = to_raw_response_wrapper(
189-
health.weaviate,
190-
)
191150

192151

193152
class AsyncHealthResourceWithRawResponse:
@@ -200,9 +159,6 @@ def __init__(self, health: AsyncHealthResource) -> None:
200159
self.db = async_to_raw_response_wrapper(
201160
health.db,
202161
)
203-
self.weaviate = async_to_raw_response_wrapper(
204-
health.weaviate,
205-
)
206162

207163

208164
class HealthResourceWithStreamingResponse:
@@ -215,9 +171,6 @@ def __init__(self, health: HealthResource) -> None:
215171
self.db = to_streamed_response_wrapper(
216172
health.db,
217173
)
218-
self.weaviate = to_streamed_response_wrapper(
219-
health.weaviate,
220-
)
221174

222175

223176
class AsyncHealthResourceWithStreamingResponse:
@@ -230,6 +183,3 @@ def __init__(self, health: AsyncHealthResource) -> None:
230183
self.db = async_to_streamed_response_wrapper(
231184
health.db,
232185
)
233-
self.weaviate = async_to_streamed_response_wrapper(
234-
health.weaviate,
235-
)

src/codex/resources/projects/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
EntriesResourceWithStreamingResponse,
99
AsyncEntriesResourceWithStreamingResponse,
1010
)
11+
from .clusters import (
12+
ClustersResource,
13+
AsyncClustersResource,
14+
ClustersResourceWithRawResponse,
15+
AsyncClustersResourceWithRawResponse,
16+
ClustersResourceWithStreamingResponse,
17+
AsyncClustersResourceWithStreamingResponse,
18+
)
1119
from .projects import (
1220
ProjectsResource,
1321
AsyncProjectsResource,
@@ -38,6 +46,12 @@
3846
"AsyncEntriesResourceWithRawResponse",
3947
"EntriesResourceWithStreamingResponse",
4048
"AsyncEntriesResourceWithStreamingResponse",
49+
"ClustersResource",
50+
"AsyncClustersResource",
51+
"ClustersResourceWithRawResponse",
52+
"AsyncClustersResourceWithRawResponse",
53+
"ClustersResourceWithStreamingResponse",
54+
"AsyncClustersResourceWithStreamingResponse",
4155
"ProjectsResource",
4256
"AsyncProjectsResource",
4357
"ProjectsResourceWithRawResponse",

0 commit comments

Comments
 (0)