Skip to content

Commit 7a990d7

Browse files
docs(api): updates to API spec (#224)
1 parent 5128ea8 commit 7a990d7

File tree

5 files changed

+58
-30
lines changed

5 files changed

+58
-30
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-50d65469557b50b46f15db6f5da3b81ed5c1f551e5eab64ded93e46eafaa3696.yml
3-
openapi_spec_hash: 5e65cdf348fa909363010cd2fb5866c5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-d15316b8a3a086ae9ec8eea0d436b0885262df9bcf23b9587ad059e50357c220.yml
3+
openapi_spec_hash: 4f81a4f4840438f80eff345e76ead962
44
config_hash: b3310cd2944d74a3599e847847226a42

src/writerai/resources/graphs.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ def question(
358358
*,
359359
graph_ids: List[str],
360360
question: str,
361-
stream: Literal[False],
362-
subqueries: bool,
361+
stream: Literal[False] | NotGiven = NOT_GIVEN,
362+
subqueries: bool | NotGiven = NOT_GIVEN,
363363
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
364364
# The extra values given here take precedence over values defined on the client or passed to this method.
365365
extra_headers: Headers | None = None,
@@ -398,7 +398,7 @@ def question(
398398
graph_ids: List[str],
399399
question: str,
400400
stream: Literal[True],
401-
subqueries: bool,
401+
subqueries: bool | NotGiven = NOT_GIVEN,
402402
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
403403
# The extra values given here take precedence over values defined on the client or passed to this method.
404404
extra_headers: Headers | None = None,
@@ -437,7 +437,7 @@ def question(
437437
graph_ids: List[str],
438438
question: str,
439439
stream: bool,
440-
subqueries: bool,
440+
subqueries: bool | NotGiven = NOT_GIVEN,
441441
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
442442
# The extra values given here take precedence over values defined on the client or passed to this method.
443443
extra_headers: Headers | None = None,
@@ -469,14 +469,14 @@ def question(
469469
"""
470470
...
471471

472-
@required_args(["graph_ids", "question", "stream", "subqueries"])
472+
@required_args(["graph_ids", "question"], ["graph_ids", "question", "stream"])
473473
def question(
474474
self,
475475
*,
476476
graph_ids: List[str],
477477
question: str,
478-
stream: Literal[False] | Literal[True],
479-
subqueries: bool,
478+
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
479+
subqueries: bool | NotGiven = NOT_GIVEN,
480480
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
481481
# The extra values given here take precedence over values defined on the client or passed to this method.
482482
extra_headers: Headers | None = None,
@@ -857,8 +857,8 @@ async def question(
857857
*,
858858
graph_ids: List[str],
859859
question: str,
860-
stream: Literal[False],
861-
subqueries: bool,
860+
stream: Literal[False] | NotGiven = NOT_GIVEN,
861+
subqueries: bool | NotGiven = NOT_GIVEN,
862862
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
863863
# The extra values given here take precedence over values defined on the client or passed to this method.
864864
extra_headers: Headers | None = None,
@@ -897,7 +897,7 @@ async def question(
897897
graph_ids: List[str],
898898
question: str,
899899
stream: Literal[True],
900-
subqueries: bool,
900+
subqueries: bool | NotGiven = NOT_GIVEN,
901901
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
902902
# The extra values given here take precedence over values defined on the client or passed to this method.
903903
extra_headers: Headers | None = None,
@@ -936,7 +936,7 @@ async def question(
936936
graph_ids: List[str],
937937
question: str,
938938
stream: bool,
939-
subqueries: bool,
939+
subqueries: bool | NotGiven = NOT_GIVEN,
940940
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
941941
# The extra values given here take precedence over values defined on the client or passed to this method.
942942
extra_headers: Headers | None = None,
@@ -968,14 +968,14 @@ async def question(
968968
"""
969969
...
970970

971-
@required_args(["graph_ids", "question", "stream", "subqueries"])
971+
@required_args(["graph_ids", "question"], ["graph_ids", "question", "stream"])
972972
async def question(
973973
self,
974974
*,
975975
graph_ids: List[str],
976976
question: str,
977-
stream: Literal[False] | Literal[True],
978-
subqueries: bool,
977+
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
978+
subqueries: bool | NotGiven = NOT_GIVEN,
979979
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
980980
# The extra values given here take precedence over values defined on the client or passed to this method.
981981
extra_headers: Headers | None = None,

src/writerai/types/chat_chat_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class ChatChatParamsBase(TypedDict, total=False):
9595

9696
class Message(TypedDict, total=False):
9797
role: Required[Literal["user", "assistant", "system", "tool"]]
98+
"""The role of the chat message.
99+
100+
You can provide a system prompt by setting the role to `system`, or specify that
101+
a message is the result of a [tool call](/api-guides/tool-calling) by setting
102+
the role to `tool`.
103+
"""
98104

99105
content: Optional[str]
100106

src/writerai/types/graph_question_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class GraphQuestionParamsBase(TypedDict, total=False):
1515
question: Required[str]
1616
"""The question to be answered using the Knowledge Graph."""
1717

18-
subqueries: Required[bool]
18+
subqueries: bool
1919
"""Specify whether to include subqueries."""
2020

2121

2222
class GraphQuestionParamsNonStreaming(GraphQuestionParamsBase, total=False):
23-
stream: Required[Literal[False]]
23+
stream: Literal[False]
2424
"""Determines whether the model's output should be streamed.
2525
2626
If true, the output is generated and sent incrementally, which can be useful for

tests/api_resources/test_graphs.py

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ def test_path_params_add_file_to_graph(self, client: Writer) -> None:
261261

262262
@parametrize
263263
def test_method_question_overload_1(self, client: Writer) -> None:
264+
graph = client.graphs.question(
265+
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
266+
question="question",
267+
)
268+
assert_matches_type(Question, graph, path=["response"])
269+
270+
@parametrize
271+
def test_method_question_with_all_params_overload_1(self, client: Writer) -> None:
264272
graph = client.graphs.question(
265273
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
266274
question="question",
@@ -274,8 +282,6 @@ def test_raw_response_question_overload_1(self, client: Writer) -> None:
274282
response = client.graphs.with_raw_response.question(
275283
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
276284
question="question",
277-
stream=False,
278-
subqueries=True,
279285
)
280286

281287
assert response.is_closed is True
@@ -288,8 +294,6 @@ def test_streaming_response_question_overload_1(self, client: Writer) -> None:
288294
with client.graphs.with_streaming_response.question(
289295
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
290296
question="question",
291-
stream=False,
292-
subqueries=True,
293297
) as response:
294298
assert not response.is_closed
295299
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -301,6 +305,15 @@ def test_streaming_response_question_overload_1(self, client: Writer) -> None:
301305

302306
@parametrize
303307
def test_method_question_overload_2(self, client: Writer) -> None:
308+
graph_stream = client.graphs.question(
309+
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
310+
question="question",
311+
stream=True,
312+
)
313+
graph_stream.response.close()
314+
315+
@parametrize
316+
def test_method_question_with_all_params_overload_2(self, client: Writer) -> None:
304317
graph_stream = client.graphs.question(
305318
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
306319
question="question",
@@ -315,7 +328,6 @@ def test_raw_response_question_overload_2(self, client: Writer) -> None:
315328
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
316329
question="question",
317330
stream=True,
318-
subqueries=True,
319331
)
320332

321333
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -328,7 +340,6 @@ def test_streaming_response_question_overload_2(self, client: Writer) -> None:
328340
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
329341
question="question",
330342
stream=True,
331-
subqueries=True,
332343
) as response:
333344
assert not response.is_closed
334345
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -625,6 +636,14 @@ async def test_path_params_add_file_to_graph(self, async_client: AsyncWriter) ->
625636

626637
@parametrize
627638
async def test_method_question_overload_1(self, async_client: AsyncWriter) -> None:
639+
graph = await async_client.graphs.question(
640+
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
641+
question="question",
642+
)
643+
assert_matches_type(Question, graph, path=["response"])
644+
645+
@parametrize
646+
async def test_method_question_with_all_params_overload_1(self, async_client: AsyncWriter) -> None:
628647
graph = await async_client.graphs.question(
629648
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
630649
question="question",
@@ -638,8 +657,6 @@ async def test_raw_response_question_overload_1(self, async_client: AsyncWriter)
638657
response = await async_client.graphs.with_raw_response.question(
639658
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
640659
question="question",
641-
stream=False,
642-
subqueries=True,
643660
)
644661

645662
assert response.is_closed is True
@@ -652,8 +669,6 @@ async def test_streaming_response_question_overload_1(self, async_client: AsyncW
652669
async with async_client.graphs.with_streaming_response.question(
653670
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
654671
question="question",
655-
stream=False,
656-
subqueries=True,
657672
) as response:
658673
assert not response.is_closed
659674
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -665,6 +680,15 @@ async def test_streaming_response_question_overload_1(self, async_client: AsyncW
665680

666681
@parametrize
667682
async def test_method_question_overload_2(self, async_client: AsyncWriter) -> None:
683+
graph_stream = await async_client.graphs.question(
684+
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
685+
question="question",
686+
stream=True,
687+
)
688+
await graph_stream.response.aclose()
689+
690+
@parametrize
691+
async def test_method_question_with_all_params_overload_2(self, async_client: AsyncWriter) -> None:
668692
graph_stream = await async_client.graphs.question(
669693
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
670694
question="question",
@@ -679,7 +703,6 @@ async def test_raw_response_question_overload_2(self, async_client: AsyncWriter)
679703
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
680704
question="question",
681705
stream=True,
682-
subqueries=True,
683706
)
684707

685708
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -692,7 +715,6 @@ async def test_streaming_response_question_overload_2(self, async_client: AsyncW
692715
graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
693716
question="question",
694717
stream=True,
695-
subqueries=True,
696718
) as response:
697719
assert not response.is_closed
698720
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)