Skip to content

Commit 7e349a9

Browse files
docs(api): updates to API spec
1 parent 7912ae2 commit 7e349a9

4 files changed

Lines changed: 204 additions & 5 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 33
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-3f87c8deb39e443022f2e04252994a6c9d25473872503edf9eec00d874576b2d.yml
3-
openapi_spec_hash: 5de52bf1d78e00b13a04f6e9ce2f2fb5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-4ec783072dd7f57c6e021a746df7650fb8d7a164d8ec25c7d5cab06c33bc114f.yml
3+
openapi_spec_hash: ceab065d515f3681b0c33137da308968
44
config_hash: 7a38bab086b53b43d2a719cb4d883264

src/writerai/types/shared/graph_data.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,66 @@
33
from typing import List, Optional
44
from typing_extensions import Literal
55

6+
from pydantic import Field as FieldInfo
7+
68
from .source import Source
79
from ..._models import BaseModel
810

9-
__all__ = ["GraphData", "Subquery"]
11+
__all__ = ["GraphData", "References", "ReferencesFile", "ReferencesWeb", "Subquery"]
12+
13+
14+
class ReferencesFile(BaseModel):
15+
file_id: str = FieldInfo(alias="fileId")
16+
"""The unique identifier of the file in your Writer account."""
17+
18+
score: float
19+
"""
20+
Internal score used during the retrieval process for ranking and selecting
21+
relevant snippets.
22+
"""
23+
24+
text: str
25+
"""
26+
The exact text snippet from the source document that was used to support the
27+
response.
28+
"""
29+
30+
cite: Optional[str] = None
31+
"""
32+
Unique citation ID that appears in inline citations within the response text
33+
(null if not cited).
34+
"""
35+
36+
page: Optional[int] = None
37+
"""Page number where this snippet was found in the source document."""
38+
39+
40+
class ReferencesWeb(BaseModel):
41+
score: float
42+
"""
43+
Internal score used during the retrieval process for ranking and selecting
44+
relevant snippets.
45+
"""
46+
47+
text: str
48+
"""
49+
The exact text snippet from the web source that was used to support the
50+
response.
51+
"""
52+
53+
title: str
54+
"""The title of the web page where this content was found."""
55+
56+
url: str
57+
"""The URL of the web page where this content was found."""
58+
59+
60+
class References(BaseModel):
61+
files: Optional[List[ReferencesFile]] = None
62+
"""Array of file-based references from uploaded documents in the Knowledge Graph."""
63+
64+
web: Optional[List[ReferencesWeb]] = None
65+
"""Array of web-based references from online sources accessed during the query."""
1066

1167

1268
class Subquery(BaseModel):
@@ -21,6 +77,12 @@ class Subquery(BaseModel):
2177

2278

2379
class GraphData(BaseModel):
80+
references: Optional[References] = None
81+
"""
82+
Detailed source information organized by reference type, providing comprehensive
83+
metadata about the sources used to generate the response.
84+
"""
85+
2486
sources: Optional[List[Optional[Source]]] = None
2587

2688
status: Optional[Literal["processing", "finished"]] = None

src/writerai/types/shared_params/graph_data.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,66 @@
33
from __future__ import annotations
44

55
from typing import Iterable, Optional
6-
from typing_extensions import Literal, Required, TypedDict
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
77

88
from .source import Source
9+
from ..._utils import PropertyInfo
910

10-
__all__ = ["GraphData", "Subquery"]
11+
__all__ = ["GraphData", "References", "ReferencesFile", "ReferencesWeb", "Subquery"]
12+
13+
14+
class ReferencesFile(TypedDict, total=False):
15+
file_id: Required[Annotated[str, PropertyInfo(alias="fileId")]]
16+
"""The unique identifier of the file in your Writer account."""
17+
18+
score: Required[float]
19+
"""
20+
Internal score used during the retrieval process for ranking and selecting
21+
relevant snippets.
22+
"""
23+
24+
text: Required[str]
25+
"""
26+
The exact text snippet from the source document that was used to support the
27+
response.
28+
"""
29+
30+
cite: str
31+
"""
32+
Unique citation ID that appears in inline citations within the response text
33+
(null if not cited).
34+
"""
35+
36+
page: int
37+
"""Page number where this snippet was found in the source document."""
38+
39+
40+
class ReferencesWeb(TypedDict, total=False):
41+
score: Required[float]
42+
"""
43+
Internal score used during the retrieval process for ranking and selecting
44+
relevant snippets.
45+
"""
46+
47+
text: Required[str]
48+
"""
49+
The exact text snippet from the web source that was used to support the
50+
response.
51+
"""
52+
53+
title: Required[str]
54+
"""The title of the web page where this content was found."""
55+
56+
url: Required[str]
57+
"""The URL of the web page where this content was found."""
58+
59+
60+
class References(TypedDict, total=False):
61+
files: Iterable[ReferencesFile]
62+
"""Array of file-based references from uploaded documents in the Knowledge Graph."""
63+
64+
web: Iterable[ReferencesWeb]
65+
"""Array of web-based references from online sources accessed during the query."""
1166

1267

1368
class Subquery(TypedDict, total=False):
@@ -22,6 +77,12 @@ class Subquery(TypedDict, total=False):
2277

2378

2479
class GraphData(TypedDict, total=False):
80+
references: References
81+
"""
82+
Detailed source information organized by reference type, providing comprehensive
83+
metadata about the sources used to generate the response.
84+
"""
85+
2586
sources: Iterable[Optional[Source]]
2687

2788
status: Optional[Literal["processing", "finished"]]

tests/api_resources/test_chat.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ def test_method_chat_with_all_params_overload_1(self, client: Writer) -> None:
3333
"role": "user",
3434
"content": "string",
3535
"graph_data": {
36+
"references": {
37+
"files": [
38+
{
39+
"file_id": "fileId",
40+
"score": 0,
41+
"text": "text",
42+
"cite": "cite",
43+
"page": 0,
44+
}
45+
],
46+
"web": [
47+
{
48+
"score": 0,
49+
"text": "text",
50+
"title": "title",
51+
"url": "https://example.com",
52+
}
53+
],
54+
},
3655
"sources": [
3756
{
3857
"file_id": "file_id",
@@ -139,6 +158,25 @@ def test_method_chat_with_all_params_overload_2(self, client: Writer) -> None:
139158
"role": "user",
140159
"content": "string",
141160
"graph_data": {
161+
"references": {
162+
"files": [
163+
{
164+
"file_id": "fileId",
165+
"score": 0,
166+
"text": "text",
167+
"cite": "cite",
168+
"page": 0,
169+
}
170+
],
171+
"web": [
172+
{
173+
"score": 0,
174+
"text": "text",
175+
"title": "title",
176+
"url": "https://example.com",
177+
}
178+
],
179+
},
142180
"sources": [
143181
{
144182
"file_id": "file_id",
@@ -251,6 +289,25 @@ async def test_method_chat_with_all_params_overload_1(self, async_client: AsyncW
251289
"role": "user",
252290
"content": "string",
253291
"graph_data": {
292+
"references": {
293+
"files": [
294+
{
295+
"file_id": "fileId",
296+
"score": 0,
297+
"text": "text",
298+
"cite": "cite",
299+
"page": 0,
300+
}
301+
],
302+
"web": [
303+
{
304+
"score": 0,
305+
"text": "text",
306+
"title": "title",
307+
"url": "https://example.com",
308+
}
309+
],
310+
},
254311
"sources": [
255312
{
256313
"file_id": "file_id",
@@ -357,6 +414,25 @@ async def test_method_chat_with_all_params_overload_2(self, async_client: AsyncW
357414
"role": "user",
358415
"content": "string",
359416
"graph_data": {
417+
"references": {
418+
"files": [
419+
{
420+
"file_id": "fileId",
421+
"score": 0,
422+
"text": "text",
423+
"cite": "cite",
424+
"page": 0,
425+
}
426+
],
427+
"web": [
428+
{
429+
"score": 0,
430+
"text": "text",
431+
"title": "title",
432+
"url": "https://example.com",
433+
}
434+
],
435+
},
360436
"sources": [
361437
{
362438
"file_id": "file_id",

0 commit comments

Comments
 (0)