Skip to content

Commit 005b72f

Browse files
feat(api): api update (#129)
1 parent 550fa9d commit 005b72f

File tree

5 files changed

+79
-50
lines changed

5 files changed

+79
-50
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 91
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-b2fe5c35562a5dafc33b2b5441a9e199668a03c7497b6d6350a2d25332dfecb0.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f081d80ec1b3a4951cccc2a085d46405da9aea9da7295cc264e834ada84127eb.yml
Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44
from datetime import datetime
55

66
from .._models import BaseModel
77

8-
__all__ = ["AnswerResponse"]
8+
__all__ = ["AnswerResponse", "Answer", "AnswerAttachment", "Request"]
99

1010

11-
class AnswerResponse(BaseModel):
12-
id: str
11+
class AnswerAttachment(BaseModel):
12+
info: object
1313

14-
answer: Optional[object] = None
14+
type: str
15+
"""The type of the attachment"""
1516

16-
created_at: datetime
1717

18-
datasource_id: str
19-
"""数据源 ID"""
18+
class Answer(BaseModel):
19+
text: str
2020

21-
duration: int
21+
attachments: Optional[List[AnswerAttachment]] = None
2222

23-
modified_at: datetime
2423

25-
project_id: str
24+
class Request(BaseModel):
25+
datasource_id: str
26+
"""数据源 ID"""
2627

2728
question: str
28-
29-
status: str
30-
31-
err_msg: Optional[str] = None
32-
"""错误信息"""
29+
"""查询语句"""
3330

3431
max_rows: Optional[int] = None
3532
"""最大返回行数,默认为 0,即不限制返回行数"""
@@ -45,3 +42,25 @@ class AnswerResponse(BaseModel):
4542

4643
with_json: Optional[bool] = None
4744
"""是否同时将数据,作为 json 格式的附件一起返回"""
45+
46+
47+
class AnswerResponse(BaseModel):
48+
id: str
49+
50+
answer: Optional[Answer] = None
51+
52+
created_at: datetime
53+
54+
duration: int
55+
56+
modified_at: datetime
57+
58+
project_id: str
59+
60+
request: Request
61+
62+
status: str
63+
64+
err_msg: Optional[str] = None
65+
66+
trace_id: Optional[str] = None

src/asktable/types/query_response.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,21 @@
55

66
from .._models import BaseModel
77

8-
__all__ = ["QueryResponse"]
8+
__all__ = ["QueryResponse", "Query", "Request"]
99

1010

11-
class QueryResponse(BaseModel):
12-
id: str
11+
class Query(BaseModel):
12+
sql: str
13+
"""SQL 语句"""
1314

14-
created_at: datetime
1515

16+
class Request(BaseModel):
1617
datasource_id: str
1718
"""数据源 ID"""
1819

19-
duration: Optional[int] = None
20-
21-
modified_at: datetime
22-
23-
project_id: str
24-
25-
query: Optional[object] = None
26-
2720
question: str
2821
"""查询语句"""
2922

30-
status: str
31-
32-
err_msg: Optional[str] = None
33-
"""错误信息"""
34-
3523
role_id: Optional[str] = None
3624
"""
3725
角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
@@ -40,3 +28,25 @@ class QueryResponse(BaseModel):
4028

4129
role_variables: Optional[object] = None
4230
"""在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
31+
32+
33+
class QueryResponse(BaseModel):
34+
id: str
35+
36+
created_at: datetime
37+
38+
duration: int
39+
40+
modified_at: datetime
41+
42+
project_id: str
43+
44+
query: Optional[Query] = None
45+
46+
request: Request
47+
48+
status: str
49+
50+
err_msg: Optional[str] = None
51+
52+
trace_id: Optional[str] = None

tests/api_resources/test_answers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class TestAnswers:
2222
def test_method_create(self, client: Asktable) -> None:
2323
answer = client.answers.create(
2424
datasource_id="datasource_id",
25-
question="xxx",
25+
question="question",
2626
)
2727
assert_matches_type(AnswerResponse, answer, path=["response"])
2828

2929
@parametrize
3030
def test_method_create_with_all_params(self, client: Asktable) -> None:
3131
answer = client.answers.create(
3232
datasource_id="datasource_id",
33-
question="xxx",
33+
question="question",
3434
max_rows=0,
3535
role_id="role_id",
3636
role_variables={},
@@ -42,7 +42,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
4242
def test_raw_response_create(self, client: Asktable) -> None:
4343
response = client.answers.with_raw_response.create(
4444
datasource_id="datasource_id",
45-
question="xxx",
45+
question="question",
4646
)
4747

4848
assert response.is_closed is True
@@ -54,7 +54,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
5454
def test_streaming_response_create(self, client: Asktable) -> None:
5555
with client.answers.with_streaming_response.create(
5656
datasource_id="datasource_id",
57-
question="xxx",
57+
question="question",
5858
) as response:
5959
assert not response.is_closed
6060
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -106,15 +106,15 @@ class TestAsyncAnswers:
106106
async def test_method_create(self, async_client: AsyncAsktable) -> None:
107107
answer = await async_client.answers.create(
108108
datasource_id="datasource_id",
109-
question="xxx",
109+
question="question",
110110
)
111111
assert_matches_type(AnswerResponse, answer, path=["response"])
112112

113113
@parametrize
114114
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
115115
answer = await async_client.answers.create(
116116
datasource_id="datasource_id",
117-
question="xxx",
117+
question="question",
118118
max_rows=0,
119119
role_id="role_id",
120120
role_variables={},
@@ -126,7 +126,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
126126
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
127127
response = await async_client.answers.with_raw_response.create(
128128
datasource_id="datasource_id",
129-
question="xxx",
129+
question="question",
130130
)
131131

132132
assert response.is_closed is True
@@ -138,7 +138,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
138138
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
139139
async with async_client.answers.with_streaming_response.create(
140140
datasource_id="datasource_id",
141-
question="xxx",
141+
question="question",
142142
) as response:
143143
assert not response.is_closed
144144
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

tests/api_resources/test_sqls.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class TestSqls:
2222
def test_method_create(self, client: Asktable) -> None:
2323
sql = client.sqls.create(
2424
datasource_id="datasource_id",
25-
question="xxx",
25+
question="question",
2626
)
2727
assert_matches_type(QueryResponse, sql, path=["response"])
2828

2929
@parametrize
3030
def test_method_create_with_all_params(self, client: Asktable) -> None:
3131
sql = client.sqls.create(
3232
datasource_id="datasource_id",
33-
question="xxx",
33+
question="question",
3434
role_id="role_id",
3535
role_variables={},
3636
)
@@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
4040
def test_raw_response_create(self, client: Asktable) -> None:
4141
response = client.sqls.with_raw_response.create(
4242
datasource_id="datasource_id",
43-
question="xxx",
43+
question="question",
4444
)
4545

4646
assert response.is_closed is True
@@ -52,7 +52,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
5252
def test_streaming_response_create(self, client: Asktable) -> None:
5353
with client.sqls.with_streaming_response.create(
5454
datasource_id="datasource_id",
55-
question="xxx",
55+
question="question",
5656
) as response:
5757
assert not response.is_closed
5858
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -104,15 +104,15 @@ class TestAsyncSqls:
104104
async def test_method_create(self, async_client: AsyncAsktable) -> None:
105105
sql = await async_client.sqls.create(
106106
datasource_id="datasource_id",
107-
question="xxx",
107+
question="question",
108108
)
109109
assert_matches_type(QueryResponse, sql, path=["response"])
110110

111111
@parametrize
112112
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
113113
sql = await async_client.sqls.create(
114114
datasource_id="datasource_id",
115-
question="xxx",
115+
question="question",
116116
role_id="role_id",
117117
role_variables={},
118118
)
@@ -122,7 +122,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
122122
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
123123
response = await async_client.sqls.with_raw_response.create(
124124
datasource_id="datasource_id",
125-
question="xxx",
125+
question="question",
126126
)
127127

128128
assert response.is_closed is True
@@ -134,7 +134,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
134134
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
135135
async with async_client.sqls.with_streaming_response.create(
136136
datasource_id="datasource_id",
137-
question="xxx",
137+
question="question",
138138
) as response:
139139
assert not response.is_closed
140140
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)