Skip to content

Commit 07ca394

Browse files
feat(api): api update (#86)
1 parent f6b99d8 commit 07ca394

File tree

6 files changed

+71
-14
lines changed

6 files changed

+71
-14
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: 90
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-586c22698d9426ab1fe711547b39043914c00ab6a65ef836cb6f4610fb723e86.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-bb6c8be98a7d3c5109b7def15a21653d7bade60a2b6939157361c3fe9ef049d9.yml

api.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,20 @@ Methods:
103103
Types:
104104

105105
```python
106-
from asktable.types import AIMessage, Chat, ToolMessage, UserMessage, ChatSendMessageResponse
106+
from asktable.types import (
107+
AIMessage,
108+
Chat,
109+
ToolMessage,
110+
UserMessage,
111+
ChatRetrieveResponse,
112+
ChatSendMessageResponse,
113+
)
107114
```
108115

109116
Methods:
110117

111118
- <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.py">Chat</a></code>
112-
- <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.py">Chat</a></code>
119+
- <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>
113120
- <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.py">SyncPage[Chat]</a></code>
114121
- <code title="delete /chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">delete</a>(chat_id) -> None</code>
115122
- <code title="post /chats/{chat_id}">client.chats.<a href="./src/asktable/resources/chats/chats.py">send_message</a>(chat_id, \*\*<a href="src/asktable/types/chat_send_message_params.py">params</a>) -> <a href="./src/asktable/types/chat_send_message_response.py">ChatSendMessageResponse</a></code>

src/asktable/resources/chats/chats.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from ...pagination import SyncPage, AsyncPage
3232
from ...types.chat import Chat
3333
from ..._base_client import AsyncPaginator, make_request_options
34+
from ...types.chat_retrieve_response import ChatRetrieveResponse
3435
from ...types.chat_send_message_response import ChatSendMessageResponse
3536

3637
__all__ = ["ChatsResource", "AsyncChatsResource"]
@@ -127,7 +128,7 @@ def retrieve(
127128
extra_query: Query | None = None,
128129
extra_body: Body | None = None,
129130
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
130-
) -> Chat:
131+
) -> ChatRetrieveResponse:
131132
"""
132133
获取某个对话
133134
@@ -147,7 +148,7 @@ def retrieve(
147148
options=make_request_options(
148149
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
149150
),
150-
cast_to=Chat,
151+
cast_to=ChatRetrieveResponse,
151152
)
152153

153154
def list(
@@ -366,7 +367,7 @@ async def retrieve(
366367
extra_query: Query | None = None,
367368
extra_body: Body | None = None,
368369
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
369-
) -> Chat:
370+
) -> ChatRetrieveResponse:
370371
"""
371372
获取某个对话
372373
@@ -386,7 +387,7 @@ async def retrieve(
386387
options=make_request_options(
387388
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
388389
),
389-
cast_to=Chat,
390+
cast_to=ChatRetrieveResponse,
390391
)
391392

392393
def list(

src/asktable/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from .training_list_params import TrainingListParams as TrainingListParams
3636
from .entry_with_definition import EntryWithDefinition as EntryWithDefinition
3737
from .score_create_response import ScoreCreateResponse as ScoreCreateResponse
38+
from .chat_retrieve_response import ChatRetrieveResponse as ChatRetrieveResponse
3839
from .datasource_list_params import DatasourceListParams as DatasourceListParams
3940
from .training_create_params import TrainingCreateParams as TrainingCreateParams
4041
from .training_delete_params import TrainingDeleteParams as TrainingDeleteParams
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Dict, List, 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+
datasource_ids: List[str]
19+
20+
modified_at: datetime
21+
"""修改时间"""
22+
23+
project_id: str
24+
25+
bot_id: Optional[str] = None
26+
"""
27+
机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
28+
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
29+
"""
30+
31+
name: Optional[str] = None
32+
"""New name for the chat"""
33+
34+
role_id: Optional[str] = None
35+
"""
36+
角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
37+
数据
38+
"""
39+
40+
role_variables: Optional[Dict[str, Union[str, int, bool]]] = None
41+
"""在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
42+
43+
user_profile: Optional[Dict[str, str]] = None
44+
"""用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递"""

tests/api_resources/test_chats.py

Lines changed: 11 additions & 7 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, ChatSendMessageResponse
12+
from asktable.types import (
13+
Chat,
14+
ChatRetrieveResponse,
15+
ChatSendMessageResponse,
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")
@@ -63,7 +67,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
6367
chat = client.chats.retrieve(
6468
"chat_id",
6569
)
66-
assert_matches_type(Chat, chat, path=["response"])
70+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
6771

6872
@parametrize
6973
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -74,7 +78,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
7478
assert response.is_closed is True
7579
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
7680
chat = response.parse()
77-
assert_matches_type(Chat, chat, path=["response"])
81+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
7882

7983
@parametrize
8084
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -85,7 +89,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
8589
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
8690

8791
chat = response.parse()
88-
assert_matches_type(Chat, chat, path=["response"])
92+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
8993

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

@@ -258,7 +262,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
258262
chat = await async_client.chats.retrieve(
259263
"chat_id",
260264
)
261-
assert_matches_type(Chat, chat, path=["response"])
265+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
262266

263267
@parametrize
264268
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -269,7 +273,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
269273
assert response.is_closed is True
270274
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
271275
chat = await response.parse()
272-
assert_matches_type(Chat, chat, path=["response"])
276+
assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
273277

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

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

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

0 commit comments

Comments
 (0)