Skip to content

Commit 9cfaf51

Browse files
feat(api): api update
1 parent 9da26d4 commit 9cfaf51

37 files changed

+72
-2707
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 9
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nanonets%2Fdocstrange-d1e63191b34778603117f266822b2f6f73acbc657307949f2ed9bdb546ab1d88.yml
3-
openapi_spec_hash: 06568800f2585c2fe3c6069cc9139d16
1+
configured_endpoints: 2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nanonets%2Fdocstrange-3843cc83cc328a1c86126018a4309fbcd13aac4df5fd9afefd652e21e59530ab.yml
3+
openapi_spec_hash: b4046d95714426b15edb8ac003f904c6
44
config_hash: aed0d6cc8b4cffa1f02021baec0a6da3

README.md

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -115,67 +115,6 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
115115

116116
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
117117

118-
## Pagination
119-
120-
List methods in the Docstrange API are paginated.
121-
122-
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
123-
124-
```python
125-
from docstrange import Docstrange
126-
127-
client = Docstrange()
128-
129-
all_results = []
130-
# Automatically fetches more pages as needed.
131-
for result in client.extract.results.list():
132-
# Do something with result here
133-
all_results.append(result)
134-
print(all_results)
135-
```
136-
137-
Or, asynchronously:
138-
139-
```python
140-
import asyncio
141-
from docstrange import AsyncDocstrange
142-
143-
client = AsyncDocstrange()
144-
145-
146-
async def main() -> None:
147-
all_results = []
148-
# Iterate through items across all pages, issuing requests as needed.
149-
async for result in client.extract.results.list():
150-
all_results.append(result)
151-
print(all_results)
152-
153-
154-
asyncio.run(main())
155-
```
156-
157-
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
158-
159-
```python
160-
first_page = await client.extract.results.list()
161-
if first_page.has_next_page():
162-
print(f"will fetch next page using these details: {first_page.next_page_info()}")
163-
next_page = await first_page.get_next_page()
164-
print(f"number of items we just fetched: {len(next_page.results)}")
165-
166-
# Remove `await` for non-async usage.
167-
```
168-
169-
Or just work directly with the returned data:
170-
171-
```python
172-
first_page = await client.extract.results.list()
173-
for result in first_page.results:
174-
print(result.record_id)
175-
176-
# Remove `await` for non-async usage.
177-
```
178-
179118
## File uploads
180119

181120
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.

api.md

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,21 @@
33
Types:
44

55
```python
6-
from docstrange.types import (
7-
BatchExtractRequestBody,
8-
BatchExtractResponse,
9-
ExtractRequestBody,
10-
ExtractResponse,
11-
ExtractionFormatResult,
12-
ExtractionMetadata,
13-
ExtractionResult,
14-
StreamExtractRequestBody,
15-
ExtractStreamResponse,
16-
)
6+
from docstrange.types import ExtractResponse
177
```
188

199
Methods:
2010

21-
- <code title="post /api/v1/extract/async">client.extract.<a href="./src/docstrange/resources/extract/extract.py">async\_</a>(\*\*<a href="src/docstrange/types/extract_async_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">ExtractResponse</a></code>
22-
- <code title="post /api/v1/extract/batch">client.extract.<a href="./src/docstrange/resources/extract/extract.py">batch</a>(\*\*<a href="src/docstrange/types/extract_batch_params.py">params</a>) -> <a href="./src/docstrange/types/batch_extract_response.py">BatchExtractResponse</a></code>
23-
- <code title="post /api/v1/extract/stream">client.extract.<a href="./src/docstrange/resources/extract/extract.py">stream</a>(\*\*<a href="src/docstrange/types/extract_stream_params.py">params</a>) -> str</code>
2411
- <code title="post /api/v1/extract/sync">client.extract.<a href="./src/docstrange/resources/extract/extract.py">sync</a>(\*\*<a href="src/docstrange/types/extract_sync_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">ExtractResponse</a></code>
2512

26-
## Results
27-
28-
Types:
29-
30-
```python
31-
from docstrange.types.extract import ExtractionListResponse, PaginationInfo
32-
```
33-
34-
Methods:
35-
36-
- <code title="get /api/v1/extract/results/{record_id}">client.extract.results.<a href="./src/docstrange/resources/extract/results.py">retrieve</a>(record_id, \*\*<a href="src/docstrange/types/extract/result_retrieve_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">ExtractResponse</a></code>
37-
- <code title="get /api/v1/extract/results">client.extract.results.<a href="./src/docstrange/resources/extract/results.py">list</a>(\*\*<a href="src/docstrange/types/extract/result_list_params.py">params</a>) -> <a href="./src/docstrange/types/extract_response.py">SyncPageNumberPagination[ExtractResponse]</a></code>
38-
3913
# Classify
4014

4115
Types:
4216

4317
```python
44-
from docstrange.types import (
45-
BatchClassifyRequestBody,
46-
BatchClassifyResponse,
47-
ClassifyRequestBody,
48-
ClassifyResponse,
49-
FileClassificationResult,
50-
PageClassification,
51-
)
18+
from docstrange.types import ClassifyResponse
5219
```
5320

5421
Methods:
5522

56-
- <code title="post /api/v1/classify/batch">client.classify.<a href="./src/docstrange/resources/classify.py">batch</a>(\*\*<a href="src/docstrange/types/classify_batch_params.py">params</a>) -> <a href="./src/docstrange/types/batch_classify_response.py">BatchClassifyResponse</a></code>
5723
- <code title="post /api/v1/classify/sync">client.classify.<a href="./src/docstrange/resources/classify.py">sync</a>(\*\*<a href="src/docstrange/types/classify_sync_params.py">params</a>) -> <a href="./src/docstrange/types/classify_response.py">ClassifyResponse</a></code>
58-
59-
# Chat
60-
61-
Types:
62-
63-
```python
64-
from docstrange.types import ChatCompletionsRequest
65-
```
66-
67-
Methods:
68-
69-
- <code title="post /v1/chat/completions">client.chat.<a href="./src/docstrange/resources/chat.py">create_completion</a>(\*\*<a href="src/docstrange/types/chat_create_completion_params.py">params</a>) -> object</code>

src/docstrange/_client.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
)
3232

3333
if TYPE_CHECKING:
34-
from .resources import chat, extract, classify
35-
from .resources.chat import ChatResource, AsyncChatResource
34+
from .resources import extract, classify
3635
from .resources.classify import ClassifyResource, AsyncClassifyResource
3736
from .resources.extract.extract import ExtractResource, AsyncExtractResource
3837

@@ -115,12 +114,6 @@ def classify(self) -> ClassifyResource:
115114

116115
return ClassifyResource(self)
117116

118-
@cached_property
119-
def chat(self) -> ChatResource:
120-
from .resources.chat import ChatResource
121-
122-
return ChatResource(self)
123-
124117
@cached_property
125118
def with_raw_response(self) -> DocstrangeWithRawResponse:
126119
return DocstrangeWithRawResponse(self)
@@ -301,12 +294,6 @@ def classify(self) -> AsyncClassifyResource:
301294

302295
return AsyncClassifyResource(self)
303296

304-
@cached_property
305-
def chat(self) -> AsyncChatResource:
306-
from .resources.chat import AsyncChatResource
307-
308-
return AsyncChatResource(self)
309-
310297
@cached_property
311298
def with_raw_response(self) -> AsyncDocstrangeWithRawResponse:
312299
return AsyncDocstrangeWithRawResponse(self)
@@ -438,12 +425,6 @@ def classify(self) -> classify.ClassifyResourceWithRawResponse:
438425

439426
return ClassifyResourceWithRawResponse(self._client.classify)
440427

441-
@cached_property
442-
def chat(self) -> chat.ChatResourceWithRawResponse:
443-
from .resources.chat import ChatResourceWithRawResponse
444-
445-
return ChatResourceWithRawResponse(self._client.chat)
446-
447428

448429
class AsyncDocstrangeWithRawResponse:
449430
_client: AsyncDocstrange
@@ -463,12 +444,6 @@ def classify(self) -> classify.AsyncClassifyResourceWithRawResponse:
463444

464445
return AsyncClassifyResourceWithRawResponse(self._client.classify)
465446

466-
@cached_property
467-
def chat(self) -> chat.AsyncChatResourceWithRawResponse:
468-
from .resources.chat import AsyncChatResourceWithRawResponse
469-
470-
return AsyncChatResourceWithRawResponse(self._client.chat)
471-
472447

473448
class DocstrangeWithStreamedResponse:
474449
_client: Docstrange
@@ -488,12 +463,6 @@ def classify(self) -> classify.ClassifyResourceWithStreamingResponse:
488463

489464
return ClassifyResourceWithStreamingResponse(self._client.classify)
490465

491-
@cached_property
492-
def chat(self) -> chat.ChatResourceWithStreamingResponse:
493-
from .resources.chat import ChatResourceWithStreamingResponse
494-
495-
return ChatResourceWithStreamingResponse(self._client.chat)
496-
497466

498467
class AsyncDocstrangeWithStreamedResponse:
499468
_client: AsyncDocstrange
@@ -513,12 +482,6 @@ def classify(self) -> classify.AsyncClassifyResourceWithStreamingResponse:
513482

514483
return AsyncClassifyResourceWithStreamingResponse(self._client.classify)
515484

516-
@cached_property
517-
def chat(self) -> chat.AsyncChatResourceWithStreamingResponse:
518-
from .resources.chat import AsyncChatResourceWithStreamingResponse
519-
520-
return AsyncChatResourceWithStreamingResponse(self._client.chat)
521-
522485

523486
Client = Docstrange
524487

src/docstrange/resources/__init__.py

Lines changed: 0 additions & 14 deletions
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 .chat import (
4-
ChatResource,
5-
AsyncChatResource,
6-
ChatResourceWithRawResponse,
7-
AsyncChatResourceWithRawResponse,
8-
ChatResourceWithStreamingResponse,
9-
AsyncChatResourceWithStreamingResponse,
10-
)
113
from .extract import (
124
ExtractResource,
135
AsyncExtractResource,
@@ -38,10 +30,4 @@
3830
"AsyncClassifyResourceWithRawResponse",
3931
"ClassifyResourceWithStreamingResponse",
4032
"AsyncClassifyResourceWithStreamingResponse",
41-
"ChatResource",
42-
"AsyncChatResource",
43-
"ChatResourceWithRawResponse",
44-
"AsyncChatResourceWithRawResponse",
45-
"ChatResourceWithStreamingResponse",
46-
"AsyncChatResourceWithStreamingResponse",
4733
]

0 commit comments

Comments
 (0)