Skip to content

Commit 38c637a

Browse files
fix(api): default auth server
1 parent c72dfca commit 38c637a

22 files changed

Lines changed: 512 additions & 89 deletions

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 10
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs%2Fdedalus-sdk-9543ba4968eb09fe1d5ccf3bcbc0acdc614a53401893cfb15f530d51d7fe952d.yml
3-
openapi_spec_hash: eebaaecfa11e98efa3c44d709c08cbd6
4-
config_hash: 1890670c4485d0ade7c70a0c8bd20423
1+
configured_endpoints: 11
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs%2Fdedalus-sdk-2158e2dd12dc5bc533e872e1fa4a9bd1627c2f15b0e417aa4645554e045d7054.yml
3+
openapi_spec_hash: 30d4d077bf498b7634b3e14deb9d0a1d
4+
config_hash: 5324d9c636d34ebbadb48aca070564b8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Error codes are as follows:
299299

300300
### Retries
301301

302-
Certain errors are automatically retried 0 times by default, with a short exponential backoff.
302+
Certain errors are automatically retried 2 times by default, with a short exponential backoff.
303303
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
304304
429 Rate Limit, and >=500 Internal errors are all retried by default.
305305

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ Methods:
9292
- <code title="post /v1/images/edits">client.images.<a href="./src/dedalus_labs/resources/images.py">edit</a>(\*\*<a href="src/dedalus_labs/types/image_edit_params.py">params</a>) -> <a href="./src/dedalus_labs/types/images_response.py">ImagesResponse</a></code>
9393
- <code title="post /v1/images/generations">client.images.<a href="./src/dedalus_labs/resources/images.py">generate</a>(\*\*<a href="src/dedalus_labs/types/image_generate_params.py">params</a>) -> <a href="./src/dedalus_labs/types/images_response.py">ImagesResponse</a></code>
9494

95+
# Ocr
96+
97+
Types:
98+
99+
```python
100+
from dedalus_labs.types import OcrDocument, OcrPage, OcrRequest, OcrResponse
101+
```
102+
103+
Methods:
104+
105+
- <code title="post /v1/ocr">client.ocr.<a href="./src/dedalus_labs/resources/ocr.py">process</a>(\*\*<a href="src/dedalus_labs/types/ocr_process_params.py">params</a>) -> <a href="./src/dedalus_labs/types/ocr_response.py">OcrResponse</a></code>
106+
95107
# Chat
96108

97109
## Completions

src/dedalus_labs/_client.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
from .lib.mcp import prepare_mcp_request, prepare_mcp_request_sync
3535

3636
if TYPE_CHECKING:
37-
from .resources import chat, audio, images, models, embeddings
37+
from .resources import ocr, chat, audio, images, models, embeddings
38+
from .resources.ocr import OcrResource, AsyncOcrResource
3839
from .resources.images import ImagesResource, AsyncImagesResource
3940
from .resources.models import ModelsResource, AsyncModelsResource
4041
from .resources.chat.chat import ChatResource, AsyncChatResource
@@ -121,7 +122,7 @@ def __init__(
121122
self.x_api_key = x_api_key
122123

123124
if as_base_url is None:
124-
as_base_url = os.environ.get("DEDALUS_AS_URL")
125+
as_base_url = os.environ.get("DEDALUS_AS_URL") or "https://as.dedaluslabs.ai"
125126
self.as_base_url = as_base_url
126127

127128
if dedalus_org_id is None:
@@ -211,6 +212,12 @@ def images(self) -> ImagesResource:
211212

212213
return ImagesResource(self)
213214

215+
@cached_property
216+
def ocr(self) -> OcrResource:
217+
from .resources.ocr import OcrResource
218+
219+
return OcrResource(self)
220+
214221
@cached_property
215222
def chat(self) -> ChatResource:
216223
from .resources.chat import ChatResource
@@ -435,7 +442,7 @@ def __init__(
435442
self.x_api_key = x_api_key
436443

437444
if as_base_url is None:
438-
as_base_url = os.environ.get("DEDALUS_AS_URL")
445+
as_base_url = os.environ.get("DEDALUS_AS_URL") or "https://as.dedaluslabs.ai"
439446
self.as_base_url = as_base_url
440447

441448
if dedalus_org_id is None:
@@ -525,6 +532,12 @@ def images(self) -> AsyncImagesResource:
525532

526533
return AsyncImagesResource(self)
527534

535+
@cached_property
536+
def ocr(self) -> AsyncOcrResource:
537+
from .resources.ocr import AsyncOcrResource
538+
539+
return AsyncOcrResource(self)
540+
528541
@cached_property
529542
def chat(self) -> AsyncChatResource:
530543
from .resources.chat import AsyncChatResource
@@ -717,6 +730,12 @@ def images(self) -> images.ImagesResourceWithRawResponse:
717730

718731
return ImagesResourceWithRawResponse(self._client.images)
719732

733+
@cached_property
734+
def ocr(self) -> ocr.OcrResourceWithRawResponse:
735+
from .resources.ocr import OcrResourceWithRawResponse
736+
737+
return OcrResourceWithRawResponse(self._client.ocr)
738+
720739
@cached_property
721740
def chat(self) -> chat.ChatResourceWithRawResponse:
722741
from .resources.chat import ChatResourceWithRawResponse
@@ -754,6 +773,12 @@ def images(self) -> images.AsyncImagesResourceWithRawResponse:
754773

755774
return AsyncImagesResourceWithRawResponse(self._client.images)
756775

776+
@cached_property
777+
def ocr(self) -> ocr.AsyncOcrResourceWithRawResponse:
778+
from .resources.ocr import AsyncOcrResourceWithRawResponse
779+
780+
return AsyncOcrResourceWithRawResponse(self._client.ocr)
781+
757782
@cached_property
758783
def chat(self) -> chat.AsyncChatResourceWithRawResponse:
759784
from .resources.chat import AsyncChatResourceWithRawResponse
@@ -791,6 +816,12 @@ def images(self) -> images.ImagesResourceWithStreamingResponse:
791816

792817
return ImagesResourceWithStreamingResponse(self._client.images)
793818

819+
@cached_property
820+
def ocr(self) -> ocr.OcrResourceWithStreamingResponse:
821+
from .resources.ocr import OcrResourceWithStreamingResponse
822+
823+
return OcrResourceWithStreamingResponse(self._client.ocr)
824+
794825
@cached_property
795826
def chat(self) -> chat.ChatResourceWithStreamingResponse:
796827
from .resources.chat import ChatResourceWithStreamingResponse
@@ -828,6 +859,12 @@ def images(self) -> images.AsyncImagesResourceWithStreamingResponse:
828859

829860
return AsyncImagesResourceWithStreamingResponse(self._client.images)
830861

862+
@cached_property
863+
def ocr(self) -> ocr.AsyncOcrResourceWithStreamingResponse:
864+
from .resources.ocr import AsyncOcrResourceWithStreamingResponse
865+
866+
return AsyncOcrResourceWithStreamingResponse(self._client.ocr)
867+
831868
@cached_property
832869
def chat(self) -> chat.AsyncChatResourceWithStreamingResponse:
833870
from .resources.chat import AsyncChatResourceWithStreamingResponse

src/dedalus_labs/_constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
# default timeout is 1 minute
99
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60, connect=5.0)
10-
DEFAULT_MAX_RETRIES = 0
10+
DEFAULT_MAX_RETRIES = 2
1111
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
1212

13-
INITIAL_RETRY_DELAY = 0.1
14-
MAX_RETRY_DELAY = 3.0
13+
INITIAL_RETRY_DELAY = 0.5
14+
MAX_RETRY_DELAY = 8.0

src/dedalus_labs/resources/__init__.py

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

3+
from .ocr import (
4+
OcrResource,
5+
AsyncOcrResource,
6+
OcrResourceWithRawResponse,
7+
AsyncOcrResourceWithRawResponse,
8+
OcrResourceWithStreamingResponse,
9+
AsyncOcrResourceWithStreamingResponse,
10+
)
311
from .chat import (
412
ChatResource,
513
AsyncChatResource,
@@ -66,6 +74,12 @@
6674
"AsyncImagesResourceWithRawResponse",
6775
"ImagesResourceWithStreamingResponse",
6876
"AsyncImagesResourceWithStreamingResponse",
77+
"OcrResource",
78+
"AsyncOcrResource",
79+
"OcrResourceWithRawResponse",
80+
"AsyncOcrResourceWithRawResponse",
81+
"OcrResourceWithStreamingResponse",
82+
"AsyncOcrResourceWithStreamingResponse",
6983
"ChatResource",
7084
"AsyncChatResource",
7185
"ChatResourceWithRawResponse",

src/dedalus_labs/resources/ocr.py

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import httpx
6+
7+
from ..types import ocr_process_params
8+
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9+
from .._utils import maybe_transform, async_maybe_transform
10+
from .._compat import cached_property
11+
from .._resource import SyncAPIResource, AsyncAPIResource
12+
from .._response import (
13+
to_raw_response_wrapper,
14+
to_streamed_response_wrapper,
15+
async_to_raw_response_wrapper,
16+
async_to_streamed_response_wrapper,
17+
)
18+
from .._base_client import make_request_options
19+
from ..types.ocr_response import OcrResponse
20+
from ..types.ocr_document_param import OcrDocumentParam
21+
22+
__all__ = ["OcrResource", "AsyncOcrResource"]
23+
24+
25+
class OcrResource(SyncAPIResource):
26+
@cached_property
27+
def with_raw_response(self) -> OcrResourceWithRawResponse:
28+
"""
29+
This property can be used as a prefix for any HTTP method call to return
30+
the raw response object instead of the parsed content.
31+
32+
For more information, see https://www.github.com/dedalus-labs/dedalus-sdk-python#accessing-raw-response-data-eg-headers
33+
"""
34+
return OcrResourceWithRawResponse(self)
35+
36+
@cached_property
37+
def with_streaming_response(self) -> OcrResourceWithStreamingResponse:
38+
"""
39+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
40+
41+
For more information, see https://www.github.com/dedalus-labs/dedalus-sdk-python#with_streaming_response
42+
"""
43+
return OcrResourceWithStreamingResponse(self)
44+
45+
def process(
46+
self,
47+
*,
48+
document: OcrDocumentParam,
49+
model: str | Omit = omit,
50+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
51+
# The extra values given here take precedence over values defined on the client or passed to this method.
52+
extra_headers: Headers | None = None,
53+
extra_query: Query | None = None,
54+
extra_body: Body | None = None,
55+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
56+
idempotency_key: str | None = None,
57+
) -> OcrResponse:
58+
"""
59+
Process a document through Mistral OCR.
60+
61+
Extracts text from PDFs and images, returning markdown-formatted content.
62+
63+
Args:
64+
document: Document input for OCR.
65+
66+
extra_headers: Send extra headers
67+
68+
extra_query: Add additional query parameters to the request
69+
70+
extra_body: Add additional JSON properties to the request
71+
72+
timeout: Override the client-level default timeout for this request, in seconds
73+
74+
idempotency_key: Specify a custom idempotency key for this request
75+
"""
76+
return self._post(
77+
"/v1/ocr",
78+
body=maybe_transform(
79+
{
80+
"document": document,
81+
"model": model,
82+
},
83+
ocr_process_params.OcrProcessParams,
84+
),
85+
options=make_request_options(
86+
extra_headers=extra_headers,
87+
extra_query=extra_query,
88+
extra_body=extra_body,
89+
timeout=timeout,
90+
idempotency_key=idempotency_key,
91+
),
92+
cast_to=OcrResponse,
93+
)
94+
95+
96+
class AsyncOcrResource(AsyncAPIResource):
97+
@cached_property
98+
def with_raw_response(self) -> AsyncOcrResourceWithRawResponse:
99+
"""
100+
This property can be used as a prefix for any HTTP method call to return
101+
the raw response object instead of the parsed content.
102+
103+
For more information, see https://www.github.com/dedalus-labs/dedalus-sdk-python#accessing-raw-response-data-eg-headers
104+
"""
105+
return AsyncOcrResourceWithRawResponse(self)
106+
107+
@cached_property
108+
def with_streaming_response(self) -> AsyncOcrResourceWithStreamingResponse:
109+
"""
110+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
111+
112+
For more information, see https://www.github.com/dedalus-labs/dedalus-sdk-python#with_streaming_response
113+
"""
114+
return AsyncOcrResourceWithStreamingResponse(self)
115+
116+
async def process(
117+
self,
118+
*,
119+
document: OcrDocumentParam,
120+
model: str | Omit = omit,
121+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
122+
# The extra values given here take precedence over values defined on the client or passed to this method.
123+
extra_headers: Headers | None = None,
124+
extra_query: Query | None = None,
125+
extra_body: Body | None = None,
126+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
127+
idempotency_key: str | None = None,
128+
) -> OcrResponse:
129+
"""
130+
Process a document through Mistral OCR.
131+
132+
Extracts text from PDFs and images, returning markdown-formatted content.
133+
134+
Args:
135+
document: Document input for OCR.
136+
137+
extra_headers: Send extra headers
138+
139+
extra_query: Add additional query parameters to the request
140+
141+
extra_body: Add additional JSON properties to the request
142+
143+
timeout: Override the client-level default timeout for this request, in seconds
144+
145+
idempotency_key: Specify a custom idempotency key for this request
146+
"""
147+
return await self._post(
148+
"/v1/ocr",
149+
body=await async_maybe_transform(
150+
{
151+
"document": document,
152+
"model": model,
153+
},
154+
ocr_process_params.OcrProcessParams,
155+
),
156+
options=make_request_options(
157+
extra_headers=extra_headers,
158+
extra_query=extra_query,
159+
extra_body=extra_body,
160+
timeout=timeout,
161+
idempotency_key=idempotency_key,
162+
),
163+
cast_to=OcrResponse,
164+
)
165+
166+
167+
class OcrResourceWithRawResponse:
168+
def __init__(self, ocr: OcrResource) -> None:
169+
self._ocr = ocr
170+
171+
self.process = to_raw_response_wrapper(
172+
ocr.process,
173+
)
174+
175+
176+
class AsyncOcrResourceWithRawResponse:
177+
def __init__(self, ocr: AsyncOcrResource) -> None:
178+
self._ocr = ocr
179+
180+
self.process = async_to_raw_response_wrapper(
181+
ocr.process,
182+
)
183+
184+
185+
class OcrResourceWithStreamingResponse:
186+
def __init__(self, ocr: OcrResource) -> None:
187+
self._ocr = ocr
188+
189+
self.process = to_streamed_response_wrapper(
190+
ocr.process,
191+
)
192+
193+
194+
class AsyncOcrResourceWithStreamingResponse:
195+
def __init__(self, ocr: AsyncOcrResource) -> None:
196+
self._ocr = ocr
197+
198+
self.process = async_to_streamed_response_wrapper(
199+
ocr.process,
200+
)

0 commit comments

Comments
 (0)