Skip to content

Commit b9fc454

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): manual updates (#114)
1 parent 477b79c commit b9fc454

8 files changed

Lines changed: 8 additions & 187 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 22
1+
configured_endpoints: 21
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-82683f2fd5f8778a27960ebabda40d6dc4640bdfb77ac4ec7f173b8bf8076d3c.yml

api.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,13 @@ Methods:
9595
Types:
9696

9797
```python
98-
from writerai.types import (
99-
ToolContextAwareSplittingResponse,
100-
ToolParsePdfResponse,
101-
ToolTextToGraphResponse,
102-
)
98+
from writerai.types import ToolContextAwareSplittingResponse, ToolParsePdfResponse
10399
```
104100

105101
Methods:
106102

107103
- <code title="post /v1/tools/context-aware-splitting">client.tools.<a href="./src/writerai/resources/tools/tools.py">context_aware_splitting</a>(\*\*<a href="src/writerai/types/tool_context_aware_splitting_params.py">params</a>) -> <a href="./src/writerai/types/tool_context_aware_splitting_response.py">ToolContextAwareSplittingResponse</a></code>
108104
- <code title="post /v1/tools/pdf-parser/{file_id}">client.tools.<a href="./src/writerai/resources/tools/tools.py">parse_pdf</a>(file_id, \*\*<a href="src/writerai/types/tool_parse_pdf_params.py">params</a>) -> <a href="./src/writerai/types/tool_parse_pdf_response.py">ToolParsePdfResponse</a></code>
109-
- <code title="post /v1/tools/text-to-graph">client.tools.<a href="./src/writerai/resources/tools/tools.py">text_to_graph</a>(\*\*<a href="src/writerai/types/tool_text_to_graph_params.py">params</a>) -> <a href="./src/writerai/types/tool_text_to_graph_response.py">ToolTextToGraphResponse</a></code>
110105

111106
## Comprehend
112107

src/writerai/_utils/_transform.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ async def _async_transform_recursive(
316316
# Iterable[T]
317317
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
318318
):
319+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320+
# intended as an iterable, so we don't transform it.
321+
if isinstance(data, dict):
322+
return cast(object, data)
323+
319324
inner_type = extract_type_arg(stripped_type, 0)
320325
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
321326

src/writerai/resources/tools/tools.py

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66

77
import httpx
88

9-
from ...types import (
10-
tool_parse_pdf_params,
11-
tool_text_to_graph_params,
12-
tool_context_aware_splitting_params,
13-
)
9+
from ...types import tool_parse_pdf_params, tool_context_aware_splitting_params
1410
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1511
from ..._utils import (
1612
maybe_transform,
@@ -34,7 +30,6 @@
3430
)
3531
from ..._base_client import make_request_options
3632
from ...types.tool_parse_pdf_response import ToolParsePdfResponse
37-
from ...types.tool_text_to_graph_response import ToolTextToGraphResponse
3833
from ...types.tool_context_aware_splitting_response import ToolContextAwareSplittingResponse
3934

4035
__all__ = ["ToolsResource", "AsyncToolsResource"]
@@ -147,41 +142,6 @@ def parse_pdf(
147142
cast_to=ToolParsePdfResponse,
148143
)
149144

150-
def text_to_graph(
151-
self,
152-
*,
153-
text: str,
154-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
155-
# The extra values given here take precedence over values defined on the client or passed to this method.
156-
extra_headers: Headers | None = None,
157-
extra_query: Query | None = None,
158-
extra_body: Body | None = None,
159-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
160-
) -> ToolTextToGraphResponse:
161-
"""
162-
Performs name entity recognition on the supplied text accepting a maximum of
163-
35000 words.
164-
165-
Args:
166-
text: The text to be converted into a graph structure. Maximum of 35000 words.
167-
168-
extra_headers: Send extra headers
169-
170-
extra_query: Add additional query parameters to the request
171-
172-
extra_body: Add additional JSON properties to the request
173-
174-
timeout: Override the client-level default timeout for this request, in seconds
175-
"""
176-
return self._post(
177-
"/v1/tools/text-to-graph",
178-
body=maybe_transform({"text": text}, tool_text_to_graph_params.ToolTextToGraphParams),
179-
options=make_request_options(
180-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
181-
),
182-
cast_to=ToolTextToGraphResponse,
183-
)
184-
185145

186146
class AsyncToolsResource(AsyncAPIResource):
187147
@cached_property
@@ -290,41 +250,6 @@ async def parse_pdf(
290250
cast_to=ToolParsePdfResponse,
291251
)
292252

293-
async def text_to_graph(
294-
self,
295-
*,
296-
text: str,
297-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
298-
# The extra values given here take precedence over values defined on the client or passed to this method.
299-
extra_headers: Headers | None = None,
300-
extra_query: Query | None = None,
301-
extra_body: Body | None = None,
302-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
303-
) -> ToolTextToGraphResponse:
304-
"""
305-
Performs name entity recognition on the supplied text accepting a maximum of
306-
35000 words.
307-
308-
Args:
309-
text: The text to be converted into a graph structure. Maximum of 35000 words.
310-
311-
extra_headers: Send extra headers
312-
313-
extra_query: Add additional query parameters to the request
314-
315-
extra_body: Add additional JSON properties to the request
316-
317-
timeout: Override the client-level default timeout for this request, in seconds
318-
"""
319-
return await self._post(
320-
"/v1/tools/text-to-graph",
321-
body=await async_maybe_transform({"text": text}, tool_text_to_graph_params.ToolTextToGraphParams),
322-
options=make_request_options(
323-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
324-
),
325-
cast_to=ToolTextToGraphResponse,
326-
)
327-
328253

329254
class ToolsResourceWithRawResponse:
330255
def __init__(self, tools: ToolsResource) -> None:
@@ -336,9 +261,6 @@ def __init__(self, tools: ToolsResource) -> None:
336261
self.parse_pdf = to_raw_response_wrapper(
337262
tools.parse_pdf,
338263
)
339-
self.text_to_graph = to_raw_response_wrapper(
340-
tools.text_to_graph,
341-
)
342264

343265
@cached_property
344266
def comprehend(self) -> ComprehendResourceWithRawResponse:
@@ -355,9 +277,6 @@ def __init__(self, tools: AsyncToolsResource) -> None:
355277
self.parse_pdf = async_to_raw_response_wrapper(
356278
tools.parse_pdf,
357279
)
358-
self.text_to_graph = async_to_raw_response_wrapper(
359-
tools.text_to_graph,
360-
)
361280

362281
@cached_property
363282
def comprehend(self) -> AsyncComprehendResourceWithRawResponse:
@@ -374,9 +293,6 @@ def __init__(self, tools: ToolsResource) -> None:
374293
self.parse_pdf = to_streamed_response_wrapper(
375294
tools.parse_pdf,
376295
)
377-
self.text_to_graph = to_streamed_response_wrapper(
378-
tools.text_to_graph,
379-
)
380296

381297
@cached_property
382298
def comprehend(self) -> ComprehendResourceWithStreamingResponse:
@@ -393,9 +309,6 @@ def __init__(self, tools: AsyncToolsResource) -> None:
393309
self.parse_pdf = async_to_streamed_response_wrapper(
394310
tools.parse_pdf,
395311
)
396-
self.text_to_graph = async_to_streamed_response_wrapper(
397-
tools.text_to_graph,
398-
)
399312

400313
@cached_property
401314
def comprehend(self) -> AsyncComprehendResourceWithStreamingResponse:

src/writerai/types/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
from .question_response_chunk import QuestionResponseChunk as QuestionResponseChunk
2828
from .tool_parse_pdf_response import ToolParsePdfResponse as ToolParsePdfResponse
2929
from .completion_create_params import CompletionCreateParams as CompletionCreateParams
30-
from .tool_text_to_graph_params import ToolTextToGraphParams as ToolTextToGraphParams
31-
from .tool_text_to_graph_response import ToolTextToGraphResponse as ToolTextToGraphResponse
3230
from .graph_add_file_to_graph_params import GraphAddFileToGraphParams as GraphAddFileToGraphParams
3331
from .application_generate_content_params import ApplicationGenerateContentParams as ApplicationGenerateContentParams
3432
from .tool_context_aware_splitting_params import ToolContextAwareSplittingParams as ToolContextAwareSplittingParams

src/writerai/types/tool_text_to_graph_params.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/writerai/types/tool_text_to_graph_response.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/api_resources/test_tools.py

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from tests.utils import assert_matches_type
1212
from writerai.types import (
1313
ToolParsePdfResponse,
14-
ToolTextToGraphResponse,
1514
ToolContextAwareSplittingResponse,
1615
)
1716

@@ -97,37 +96,6 @@ def test_path_params_parse_pdf(self, client: Writer) -> None:
9796
format="text",
9897
)
9998

100-
@parametrize
101-
def test_method_text_to_graph(self, client: Writer) -> None:
102-
tool = client.tools.text_to_graph(
103-
text="text",
104-
)
105-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
106-
107-
@parametrize
108-
def test_raw_response_text_to_graph(self, client: Writer) -> None:
109-
response = client.tools.with_raw_response.text_to_graph(
110-
text="text",
111-
)
112-
113-
assert response.is_closed is True
114-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
115-
tool = response.parse()
116-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
117-
118-
@parametrize
119-
def test_streaming_response_text_to_graph(self, client: Writer) -> None:
120-
with client.tools.with_streaming_response.text_to_graph(
121-
text="text",
122-
) as response:
123-
assert not response.is_closed
124-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
125-
126-
tool = response.parse()
127-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
128-
129-
assert cast(Any, response.is_closed) is True
130-
13199

132100
class TestAsyncTools:
133101
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -207,34 +175,3 @@ async def test_path_params_parse_pdf(self, async_client: AsyncWriter) -> None:
207175
file_id="",
208176
format="text",
209177
)
210-
211-
@parametrize
212-
async def test_method_text_to_graph(self, async_client: AsyncWriter) -> None:
213-
tool = await async_client.tools.text_to_graph(
214-
text="text",
215-
)
216-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
217-
218-
@parametrize
219-
async def test_raw_response_text_to_graph(self, async_client: AsyncWriter) -> None:
220-
response = await async_client.tools.with_raw_response.text_to_graph(
221-
text="text",
222-
)
223-
224-
assert response.is_closed is True
225-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
226-
tool = await response.parse()
227-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
228-
229-
@parametrize
230-
async def test_streaming_response_text_to_graph(self, async_client: AsyncWriter) -> None:
231-
async with async_client.tools.with_streaming_response.text_to_graph(
232-
text="text",
233-
) as response:
234-
assert not response.is_closed
235-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
236-
237-
tool = await response.parse()
238-
assert_matches_type(ToolTextToGraphResponse, tool, path=["response"])
239-
240-
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)