Skip to content

Commit 35884cc

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): manual updates (#29)
1 parent a75217e commit 35884cc

File tree

6 files changed

+78
-30
lines changed

6 files changed

+78
-30
lines changed

api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ Methods:
9393
Types:
9494

9595
```python
96-
from asktable.types import ChatOut, ChatListResponse
96+
from asktable.types import ChatCreateResponse, ChatRetrieveResponse, ChatListResponse
9797
```
9898

9999
Methods:
100100

101-
- <code title="post /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_out.py">ChatOut</a></code>
102-
- <code title="get /chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">retrieve</a>(chat_id) -> <a href="./src/asktable/types/chat_out.py">ChatOut</a></code>
101+
- <code title="post /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>
102+
- <code title="get /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>
103103
- <code title="get /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">ChatListResponse</a></code>
104104
- <code title="delete /chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">delete</a>(chat_id) -> None</code>
105105

src/asktable/resources/chats/chats.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
async_to_streamed_response_wrapper,
3030
)
3131
from ..._base_client import make_request_options
32-
from ...types.chat_out import ChatOut
3332
from ...types.chat_list_response import ChatListResponse
33+
from ...types.chat_create_response import ChatCreateResponse
34+
from ...types.chat_retrieve_response import ChatRetrieveResponse
3435

3536
__all__ = ["ChatsResource", "AsyncChatsResource"]
3637

@@ -73,7 +74,7 @@ def create(
7374
extra_query: Query | None = None,
7475
extra_body: Body | None = None,
7576
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
76-
) -> ChatOut:
77+
) -> ChatCreateResponse:
7778
"""
7879
创建对话
7980
@@ -113,7 +114,7 @@ def create(
113114
options=make_request_options(
114115
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
115116
),
116-
cast_to=ChatOut,
117+
cast_to=ChatCreateResponse,
117118
)
118119

119120
def retrieve(
@@ -126,7 +127,7 @@ def retrieve(
126127
extra_query: Query | None = None,
127128
extra_body: Body | None = None,
128129
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
129-
) -> ChatOut:
130+
) -> ChatRetrieveResponse:
130131
"""
131132
获取某个对话
132133
@@ -146,7 +147,7 @@ def retrieve(
146147
options=make_request_options(
147148
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
148149
),
149-
cast_to=ChatOut,
150+
cast_to=ChatRetrieveResponse,
150151
)
151152

152153
def list(
@@ -268,7 +269,7 @@ async def create(
268269
extra_query: Query | None = None,
269270
extra_body: Body | None = None,
270271
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
271-
) -> ChatOut:
272+
) -> ChatCreateResponse:
272273
"""
273274
创建对话
274275
@@ -308,7 +309,7 @@ async def create(
308309
options=make_request_options(
309310
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
310311
),
311-
cast_to=ChatOut,
312+
cast_to=ChatCreateResponse,
312313
)
313314

314315
async def retrieve(
@@ -321,7 +322,7 @@ async def retrieve(
321322
extra_query: Query | None = None,
322323
extra_body: Body | None = None,
323324
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
324-
) -> ChatOut:
325+
) -> ChatRetrieveResponse:
325326
"""
326327
获取某个对话
327328
@@ -341,7 +342,7 @@ async def retrieve(
341342
options=make_request_options(
342343
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
343344
),
344-
cast_to=ChatOut,
345+
cast_to=ChatRetrieveResponse,
345346
)
346347

347348
async def list(

src/asktable/types/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from .role import Role as Role
66
from .shared import Policy as Policy, Message as Message, AnswerModel as AnswerModel
77
from .chat_bot import ChatBot as ChatBot
8-
from .chat_out import ChatOut as ChatOut
98
from .document import Document as Document
109
from .data_source import DataSource as DataSource
1110
from .ext_api_model import ExtAPIModel as ExtAPIModel
@@ -28,13 +27,15 @@
2827
from .role_create_params import RoleCreateParams as RoleCreateParams
2928
from .role_list_response import RoleListResponse as RoleListResponse
3029
from .role_update_params import RoleUpdateParams as RoleUpdateParams
30+
from .chat_create_response import ChatCreateResponse as ChatCreateResponse
3131
from .extapi_create_params import ExtapiCreateParams as ExtapiCreateParams
3232
from .extapi_list_response import ExtapiListResponse as ExtapiListResponse
3333
from .extapi_update_params import ExtapiUpdateParams as ExtapiUpdateParams
3434
from .policy_create_params import PolicyCreateParams as PolicyCreateParams
3535
from .policy_list_response import PolicyListResponse as PolicyListResponse
3636
from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams
3737
from .answer_data_source_out import AnswerDataSourceOut as AnswerDataSourceOut
38+
from .chat_retrieve_response import ChatRetrieveResponse as ChatRetrieveResponse
3839
from .datasource_list_params import DatasourceListParams as DatasourceListParams
3940
from .datasource_create_params import DatasourceCreateParams as DatasourceCreateParams
4041
from .datasource_list_response import DatasourceListResponse as DatasourceListResponse

src/asktable/types/chat_out.py renamed to src/asktable/types/chat_create_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from .._models import BaseModel
77

8-
__all__ = ["ChatOut"]
8+
__all__ = ["ChatCreateResponse"]
99

1010

11-
class ChatOut(BaseModel):
11+
class ChatCreateResponse(BaseModel):
1212
id: str
1313
"""对话 ID"""
1414

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
6+
from .._models import BaseModel
7+
8+
__all__ = ["ChatRetrieveResponse"]
9+
10+
11+
class ChatRetrieveResponse(BaseModel):
12+
id: str
13+
"""对话 ID"""
14+
15+
created_at: datetime
16+
"""创建时间"""
17+
18+
modified_at: datetime
19+
"""修改时间"""
20+
21+
project_id: str
22+
23+
bot_id: Optional[str] = None
24+
"""
25+
机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
26+
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
27+
"""
28+
29+
name: Optional[str] = None
30+
"""New name for the chat"""
31+
32+
role_id: Optional[str] = None
33+
"""
34+
角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
35+
数据
36+
"""
37+
38+
role_variables: Optional[Dict[str, Union[str, int, bool]]] = None
39+
"""在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
40+
41+
user_profile: Optional[Dict[str, str]] = None
42+
"""用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递"""

tests/api_resources/test_chats.py

Lines changed: 19 additions & 15 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 ChatOut, ChatListResponse
12+
from asktable.types import (
13+
ChatListResponse,
14+
ChatCreateResponse,
15+
ChatRetrieveResponse,
16+
)
1317

1418
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1519

@@ -20,7 +24,7 @@ class TestChats:
2024
@parametrize
2125
def test_method_create(self, client: Asktable) -> None:
2226
chat = client.chats.create()
23-
assert_matches_type(ChatOut, chat, path=["response"])
27+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
2428

2529
@parametrize
2630
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -35,7 +39,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
3539
"name": "张三",
3640
},
3741
)
38-
assert_matches_type(ChatOut, chat, path=["response"])
42+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
3943

4044
@parametrize
4145
def test_raw_response_create(self, client: Asktable) -> None:
@@ -44,7 +48,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
4448
assert response.is_closed is True
4549
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
4650
chat = response.parse()
47-
assert_matches_type(ChatOut, chat, path=["response"])
51+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
4852

4953
@parametrize
5054
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -53,7 +57,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
5357
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
5458

5559
chat = response.parse()
56-
assert_matches_type(ChatOut, chat, path=["response"])
60+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
5761

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

@@ -62,7 +66,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
6266
chat = client.chats.retrieve(
6367
"chat_id",
6468
)
65-
assert_matches_type(ChatOut, chat, path=["response"])
69+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
6670

6771
@parametrize
6872
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -73,7 +77,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
7377
assert response.is_closed is True
7478
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
7579
chat = response.parse()
76-
assert_matches_type(ChatOut, chat, path=["response"])
80+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
7781

7882
@parametrize
7983
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -84,7 +88,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
8488
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
8589

8690
chat = response.parse()
87-
assert_matches_type(ChatOut, chat, path=["response"])
91+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
8892

8993
assert cast(Any, response.is_closed) is True
9094

@@ -173,7 +177,7 @@ class TestAsyncChats:
173177
@parametrize
174178
async def test_method_create(self, async_client: AsyncAsktable) -> None:
175179
chat = await async_client.chats.create()
176-
assert_matches_type(ChatOut, chat, path=["response"])
180+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
177181

178182
@parametrize
179183
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -188,7 +192,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
188192
"name": "张三",
189193
},
190194
)
191-
assert_matches_type(ChatOut, chat, path=["response"])
195+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
192196

193197
@parametrize
194198
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -197,7 +201,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
197201
assert response.is_closed is True
198202
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
199203
chat = await response.parse()
200-
assert_matches_type(ChatOut, chat, path=["response"])
204+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
201205

202206
@parametrize
203207
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -206,7 +210,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
206210
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
207211

208212
chat = await response.parse()
209-
assert_matches_type(ChatOut, chat, path=["response"])
213+
assert_matches_type(ChatCreateResponse, chat, path=["response"])
210214

211215
assert cast(Any, response.is_closed) is True
212216

@@ -215,7 +219,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
215219
chat = await async_client.chats.retrieve(
216220
"chat_id",
217221
)
218-
assert_matches_type(ChatOut, chat, path=["response"])
222+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
219223

220224
@parametrize
221225
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -226,7 +230,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
226230
assert response.is_closed is True
227231
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
228232
chat = await response.parse()
229-
assert_matches_type(ChatOut, chat, path=["response"])
233+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
230234

231235
@parametrize
232236
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -237,7 +241,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
237241
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
238242

239243
chat = await response.parse()
240-
assert_matches_type(ChatOut, chat, path=["response"])
244+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
241245

242246
assert cast(Any, response.is_closed) is True
243247

0 commit comments

Comments
 (0)