Skip to content

Commit 9ec8ffd

Browse files
feat(api): api update
1 parent 5dbbf4f commit 9ec8ffd

File tree

7 files changed

+96
-36
lines changed

7 files changed

+96
-36
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: 105
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f3bda395c29259f9059f182277574a0a665d6fd12a7d4002803cf35d045dedaf.yml
3-
openapi_spec_hash: 351d7b616d2d0cc2fdf8074f51187b87
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-5545d4cabf39ad53ab9333c0dbaac64f770a72ef4ea6a39341cfe93cae7641f1.yml
3+
openapi_spec_hash: 25ea98b6cf6b506fbea4011c78c6ff7f
44
config_hash: acdf4142177ed1932c2d82372693f811

api.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,21 @@ Methods:
9090
Types:
9191

9292
```python
93-
from asktable.types import AIMessage, Chat, ToolMessage, UserMessage, ChatRetrieveResponse
93+
from asktable.types import (
94+
AIMessage,
95+
ToolMessage,
96+
UserMessage,
97+
ChatCreateResponse,
98+
ChatRetrieveResponse,
99+
ChatListResponse,
100+
)
94101
```
95102

96103
Methods:
97104

98-
- <code title="post /v1/chats">client.chats.<a href="./src/asktable/resources/chats/chats.py">create</a>(\*\*<a href="src/asktable/types/chat_create_params.py">params</a>) -> <a href="./src/asktable/types/chat.py">Chat</a></code>
105+
- <code title="post /v1/chats">client.chats.<a href="./src/asktable/resources/chats/chats.py">create</a>(\*\*<a href="src/asktable/types/chat_create_params.py">params</a>) -> <a href="./src/asktable/types/chat_create_response.py">ChatCreateResponse</a></code>
99106
- <code title="get /v1/chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">retrieve</a>(chat_id) -> <a href="./src/asktable/types/chat_retrieve_response.py">ChatRetrieveResponse</a></code>
100-
- <code title="get /v1/chats">client.chats.<a href="./src/asktable/resources/chats/chats.py">list</a>(\*\*<a href="src/asktable/types/chat_list_params.py">params</a>) -> <a href="./src/asktable/types/chat.py">SyncPage[Chat]</a></code>
107+
- <code title="get /v1/chats">client.chats.<a href="./src/asktable/resources/chats/chats.py">list</a>(\*\*<a href="src/asktable/types/chat_list_params.py">params</a>) -> <a href="./src/asktable/types/chat_list_response.py">SyncPage[ChatListResponse]</a></code>
101108
- <code title="delete /v1/chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">delete</a>(chat_id) -> None</code>
102109

103110
## Messages

src/asktable/resources/chats/chats.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
async_to_streamed_response_wrapper,
2727
)
2828
from ...pagination import SyncPage, AsyncPage
29-
from ...types.chat import Chat
3029
from ..._base_client import AsyncPaginator, make_request_options
30+
from ...types.chat_list_response import ChatListResponse
31+
from ...types.chat_create_response import ChatCreateResponse
3132
from ...types.chat_retrieve_response import ChatRetrieveResponse
3233

3334
__all__ = ["ChatsResource", "AsyncChatsResource"]
@@ -71,7 +72,7 @@ def create(
7172
extra_query: Query | None = None,
7273
extra_body: Body | None = None,
7374
timeout: float | httpx.Timeout | None | NotGiven = not_given,
74-
) -> Chat:
75+
) -> ChatCreateResponse:
7576
"""
7677
创建对话
7778
@@ -111,7 +112,7 @@ def create(
111112
options=make_request_options(
112113
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
113114
),
114-
cast_to=Chat,
115+
cast_to=ChatCreateResponse,
115116
)
116117

117118
def retrieve(
@@ -158,7 +159,7 @@ def list(
158159
extra_query: Query | None = None,
159160
extra_body: Body | None = None,
160161
timeout: float | httpx.Timeout | None | NotGiven = not_given,
161-
) -> SyncPage[Chat]:
162+
) -> SyncPage[ChatListResponse]:
162163
"""
163164
查询对话列表
164165
@@ -177,7 +178,7 @@ def list(
177178
"""
178179
return self._get_api_list(
179180
"/v1/chats",
180-
page=SyncPage[Chat],
181+
page=SyncPage[ChatListResponse],
181182
options=make_request_options(
182183
extra_headers=extra_headers,
183184
extra_query=extra_query,
@@ -191,7 +192,7 @@ def list(
191192
chat_list_params.ChatListParams,
192193
),
193194
),
194-
model=Chat,
195+
model=ChatListResponse,
195196
)
196197

197198
def delete(
@@ -267,7 +268,7 @@ async def create(
267268
extra_query: Query | None = None,
268269
extra_body: Body | None = None,
269270
timeout: float | httpx.Timeout | None | NotGiven = not_given,
270-
) -> Chat:
271+
) -> ChatCreateResponse:
271272
"""
272273
创建对话
273274
@@ -307,7 +308,7 @@ async def create(
307308
options=make_request_options(
308309
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
309310
),
310-
cast_to=Chat,
311+
cast_to=ChatCreateResponse,
311312
)
312313

313314
async def retrieve(
@@ -354,7 +355,7 @@ def list(
354355
extra_query: Query | None = None,
355356
extra_body: Body | None = None,
356357
timeout: float | httpx.Timeout | None | NotGiven = not_given,
357-
) -> AsyncPaginator[Chat, AsyncPage[Chat]]:
358+
) -> AsyncPaginator[ChatListResponse, AsyncPage[ChatListResponse]]:
358359
"""
359360
查询对话列表
360361
@@ -373,7 +374,7 @@ def list(
373374
"""
374375
return self._get_api_list(
375376
"/v1/chats",
376-
page=AsyncPage[Chat],
377+
page=AsyncPage[ChatListResponse],
377378
options=make_request_options(
378379
extra_headers=extra_headers,
379380
extra_query=extra_query,
@@ -387,7 +388,7 @@ def list(
387388
chat_list_params.ChatListParams,
388389
),
389390
),
390-
model=Chat,
391+
model=ChatListResponse,
391392
)
392393

393394
async def delete(

src/asktable/types/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
from .chat import Chat as Chat
65
from .meta import Meta as Meta
76
from .role import Role as Role
87
from .entry import Entry as Entry
@@ -33,13 +32,15 @@
3332
from .sql_create_params import SqlCreateParams as SqlCreateParams
3433
from .answer_list_params import AnswerListParams as AnswerListParams
3534
from .chat_create_params import ChatCreateParams as ChatCreateParams
35+
from .chat_list_response import ChatListResponse as ChatListResponse
3636
from .policy_list_params import PolicyListParams as PolicyListParams
3737
from .role_create_params import RoleCreateParams as RoleCreateParams
3838
from .role_update_params import RoleUpdateParams as RoleUpdateParams
3939
from .ats_create_response import ATSCreateResponse as ATSCreateResponse
4040
from .ats_update_response import ATSUpdateResponse as ATSUpdateResponse
4141
from .score_create_params import ScoreCreateParams as ScoreCreateParams
4242
from .answer_create_params import AnswerCreateParams as AnswerCreateParams
43+
from .chat_create_response import ChatCreateResponse as ChatCreateResponse
4344
from .policy_create_params import PolicyCreateParams as PolicyCreateParams
4445
from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams
4546
from .polish_create_params import PolishCreateParams as PolishCreateParams
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Dict, Union, Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal
6+
7+
from .._models import BaseModel
8+
9+
__all__ = ["ChatCreateResponse"]
10+
11+
12+
class ChatCreateResponse(BaseModel):
13+
id: str
14+
"""对话 ID"""
15+
16+
created_at: datetime
17+
"""创建时间"""
18+
19+
modified_at: datetime
20+
"""修改时间"""
21+
22+
project_id: str
23+
24+
status: Literal["active", "pending", "error", "fatal"]
25+
26+
status_message: Optional[str] = None
27+
28+
bot_id: Optional[str] = None
29+
"""
30+
机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
31+
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
32+
"""
33+
34+
name: Optional[str] = None
35+
"""New name for the chat"""
36+
37+
role_id: Optional[str] = None
38+
"""
39+
角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
40+
数据
41+
"""
42+
43+
role_variables: Optional[Dict[str, Union[str, int, bool]]] = None
44+
"""在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
45+
46+
user_profile: Optional[Dict[str, Union[str, int, bool]]] = None
47+
"""用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递"""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
from .._models import BaseModel
88

9-
__all__ = ["Chat"]
9+
__all__ = ["ChatListResponse"]
1010

1111

12-
class Chat(BaseModel):
12+
class ChatListResponse(BaseModel):
1313
id: str
1414
"""对话 ID"""
1515

tests/api_resources/test_chats.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
from asktable import Asktable, AsyncAsktable
1111
from tests.utils import assert_matches_type
12-
from asktable.types import Chat, ChatRetrieveResponse
12+
from asktable.types import (
13+
ChatListResponse,
14+
ChatCreateResponse,
15+
ChatRetrieveResponse,
16+
)
1317
from asktable.pagination import SyncPage, AsyncPage
1418

1519
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -21,7 +25,7 @@ class TestChats:
2125
@parametrize
2226
def test_method_create(self, client: Asktable) -> None:
2327
chat = client.chats.create()
24-
assert_matches_type(Chat, chat, path=["response"])
28+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
2529

2630
@parametrize
2731
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -36,7 +40,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
3640
"name": "张三",
3741
},
3842
)
39-
assert_matches_type(Chat, chat, path=["response"])
43+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
4044

4145
@parametrize
4246
def test_raw_response_create(self, client: Asktable) -> None:
@@ -45,7 +49,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
4549
assert response.is_closed is True
4650
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
4751
chat = response.parse()
48-
assert_matches_type(Chat, chat, path=["response"])
52+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
4953

5054
@parametrize
5155
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -54,7 +58,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
5458
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
5559

5660
chat = response.parse()
57-
assert_matches_type(Chat, chat, path=["response"])
61+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
5862

5963
assert cast(Any, response.is_closed) is True
6064

@@ -99,15 +103,15 @@ def test_path_params_retrieve(self, client: Asktable) -> None:
99103
@parametrize
100104
def test_method_list(self, client: Asktable) -> None:
101105
chat = client.chats.list()
102-
assert_matches_type(SyncPage[Chat], chat, path=["response"])
106+
assert_matches_type(SyncPage[ChatListResponse], chat, path=["response"])
103107

104108
@parametrize
105109
def test_method_list_with_all_params(self, client: Asktable) -> None:
106110
chat = client.chats.list(
107111
page=1,
108112
size=1,
109113
)
110-
assert_matches_type(SyncPage[Chat], chat, path=["response"])
114+
assert_matches_type(SyncPage[ChatListResponse], chat, path=["response"])
111115

112116
@parametrize
113117
def test_raw_response_list(self, client: Asktable) -> None:
@@ -116,7 +120,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
116120
assert response.is_closed is True
117121
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
118122
chat = response.parse()
119-
assert_matches_type(SyncPage[Chat], chat, path=["response"])
123+
assert_matches_type(SyncPage[ChatListResponse], chat, path=["response"])
120124

121125
@parametrize
122126
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -125,7 +129,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
125129
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
126130

127131
chat = response.parse()
128-
assert_matches_type(SyncPage[Chat], chat, path=["response"])
132+
assert_matches_type(SyncPage[ChatListResponse], chat, path=["response"])
129133

130134
assert cast(Any, response.is_closed) is True
131135

@@ -176,7 +180,7 @@ class TestAsyncChats:
176180
@parametrize
177181
async def test_method_create(self, async_client: AsyncAsktable) -> None:
178182
chat = await async_client.chats.create()
179-
assert_matches_type(Chat, chat, path=["response"])
183+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
180184

181185
@parametrize
182186
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -191,7 +195,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
191195
"name": "张三",
192196
},
193197
)
194-
assert_matches_type(Chat, chat, path=["response"])
198+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
195199

196200
@parametrize
197201
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -200,7 +204,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
200204
assert response.is_closed is True
201205
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
202206
chat = await response.parse()
203-
assert_matches_type(Chat, chat, path=["response"])
207+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
204208

205209
@parametrize
206210
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -209,7 +213,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
209213
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
210214

211215
chat = await response.parse()
212-
assert_matches_type(Chat, chat, path=["response"])
216+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
213217

214218
assert cast(Any, response.is_closed) is True
215219

@@ -254,15 +258,15 @@ async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None:
254258
@parametrize
255259
async def test_method_list(self, async_client: AsyncAsktable) -> None:
256260
chat = await async_client.chats.list()
257-
assert_matches_type(AsyncPage[Chat], chat, path=["response"])
261+
assert_matches_type(AsyncPage[ChatListResponse], chat, path=["response"])
258262

259263
@parametrize
260264
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
261265
chat = await async_client.chats.list(
262266
page=1,
263267
size=1,
264268
)
265-
assert_matches_type(AsyncPage[Chat], chat, path=["response"])
269+
assert_matches_type(AsyncPage[ChatListResponse], chat, path=["response"])
266270

267271
@parametrize
268272
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -271,7 +275,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
271275
assert response.is_closed is True
272276
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
273277
chat = await response.parse()
274-
assert_matches_type(AsyncPage[Chat], chat, path=["response"])
278+
assert_matches_type(AsyncPage[ChatListResponse], chat, path=["response"])
275279

276280
@parametrize
277281
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -280,7 +284,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
280284
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
281285

282286
chat = await response.parse()
283-
assert_matches_type(AsyncPage[Chat], chat, path=["response"])
287+
assert_matches_type(AsyncPage[ChatListResponse], chat, path=["response"])
284288

285289
assert cast(Any, response.is_closed) is True
286290

0 commit comments

Comments
 (0)