Skip to content

Commit 6e24354

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): api update (#17)
1 parent a7c324d commit 6e24354

File tree

11 files changed

+68
-28
lines changed

11 files changed

+68
-28
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: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f31385daf5ebf616e46fc8458a1eeafbec0849e12dbfa221bcb2d409db409e10.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-70caff6d751e62dc360c72766ea91a07da36288a58a83a412fd64d1e8ca0aa2a.yml

src/asktable/_base_client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ def __init__(
143143
self.url = url
144144
self.params = params
145145

146+
@override
147+
def __repr__(self) -> str:
148+
if self.url:
149+
return f"{self.__class__.__name__}(url={self.url})"
150+
return f"{self.__class__.__name__}(params={self.params})"
151+
146152

147153
class BasePage(GenericModel, Generic[_T]):
148154
"""
@@ -689,7 +695,8 @@ def _calculate_retry_timeout(
689695
if retry_after is not None and 0 < retry_after <= 60:
690696
return retry_after
691697

692-
nb_retries = max_retries - remaining_retries
698+
# Also cap retry count to 1000 to avoid any potential overflows with `pow`
699+
nb_retries = min(max_retries - remaining_retries, 1000)
693700

694701
# Apply exponential backoff, but not more than the max.
695702
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)

src/asktable/_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
192192
if cast_to == float:
193193
return cast(R, float(response.text))
194194

195+
if cast_to == bool:
196+
return cast(R, response.text.lower() == "true")
197+
195198
origin = get_origin(cast_to) or cast_to
196199

197200
if origin == APIResponse:

src/asktable/resources/chats/chats.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Optional
5+
from typing import Dict, Union, Optional
66

77
import httpx
88

@@ -64,7 +64,6 @@ def create(
6464
self,
6565
*,
6666
bot_id: Optional[str] | NotGiven = NOT_GIVEN,
67-
datasource_ids: Optional[List[str]] | NotGiven = NOT_GIVEN,
6867
name: Optional[str] | NotGiven = NOT_GIVEN,
6968
role_id: Optional[str] | NotGiven = NOT_GIVEN,
7069
role_variables: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
@@ -83,8 +82,6 @@ def create(
8382
bot_id: 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
8483
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
8584
86-
datasource_ids: 直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource
87-
8885
name: New name for the chat
8986
9087
role_id: 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
@@ -107,7 +104,6 @@ def create(
107104
body=maybe_transform(
108105
{
109106
"bot_id": bot_id,
110-
"datasource_ids": datasource_ids,
111107
"name": name,
112108
"role_id": role_id,
113109
"role_variables": role_variables,
@@ -263,7 +259,6 @@ async def create(
263259
self,
264260
*,
265261
bot_id: Optional[str] | NotGiven = NOT_GIVEN,
266-
datasource_ids: Optional[List[str]] | NotGiven = NOT_GIVEN,
267262
name: Optional[str] | NotGiven = NOT_GIVEN,
268263
role_id: Optional[str] | NotGiven = NOT_GIVEN,
269264
role_variables: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
@@ -282,8 +277,6 @@ async def create(
282277
bot_id: 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
283278
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
284279
285-
datasource_ids: 直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource
286-
287280
name: New name for the chat
288281
289282
role_id: 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
@@ -306,7 +299,6 @@ async def create(
306299
body=await async_maybe_transform(
307300
{
308301
"bot_id": bot_id,
309-
"datasource_ids": datasource_ids,
310302
"name": name,
311303
"role_id": role_id,
312304
"role_variables": role_variables,

src/asktable/types/chat.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

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

66
from .._models import BaseModel
@@ -24,9 +24,6 @@ class Chat(BaseModel):
2424
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
2525
"""
2626

27-
datasource_ids: Optional[List[str]] = None
28-
"""直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource"""
29-
3027
latest_msg: Optional[datetime] = None
3128

3229
name: Optional[str] = None

src/asktable/types/chat_create_params.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Optional
5+
from typing import Dict, Union, Optional
66
from typing_extensions import TypedDict
77

88
__all__ = ["ChatCreateParams"]
@@ -15,9 +15,6 @@ class ChatCreateParams(TypedDict, total=False):
1515
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
1616
"""
1717

18-
datasource_ids: Optional[List[str]]
19-
"""直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource"""
20-
2118
name: Optional[str]
2219
"""New name for the chat"""
2320

src/asktable/types/chat_list_response.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class Item(BaseModel):
3232
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
3333
"""
3434

35-
datasource_ids: Optional[List[str]] = None
36-
"""直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource"""
37-
3835
latest_msg: Optional[datetime] = None
3936
"""最新消息时间"""
4037

src/asktable/types/chat_out.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

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

66
from .._models import BaseModel
@@ -24,9 +24,6 @@ class ChatOut(BaseModel):
2424
可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
2525
"""
2626

27-
datasource_ids: Optional[List[str]] = None
28-
"""直接与数据源对话,我们会自动为你创建一个机器人, only support one datasource"""
29-
3027
latest_msg: Optional[datetime] = None
3128

3229
name: Optional[str] = None

tests/api_resources/test_chats.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_method_create(self, client: Asktable) -> None:
2626
def test_method_create_with_all_params(self, client: Asktable) -> None:
2727
chat = client.chats.create(
2828
bot_id="bot_42",
29-
datasource_ids=["ds_42"],
3029
name="name",
3130
role_id="role_42",
3231
role_variables={"id": "123123123"},
@@ -180,7 +179,6 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
180179
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
181180
chat = await async_client.chats.create(
182181
bot_id="bot_42",
183-
datasource_ids=["ds_42"],
184182
name="name",
185183
role_id="role_42",
186184
role_variables={"id": "123123123"},

tests/test_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ class Model(BaseModel):
682682
[3, "", 0.5],
683683
[2, "", 0.5 * 2.0],
684684
[1, "", 0.5 * 4.0],
685+
[-1100, "", 7.8], # test large number potentially overflowing
685686
],
686687
)
687688
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
@@ -1441,6 +1442,7 @@ class Model(BaseModel):
14411442
[3, "", 0.5],
14421443
[2, "", 0.5 * 2.0],
14431444
[1, "", 0.5 * 4.0],
1445+
[-1100, "", 7.8], # test large number potentially overflowing
14441446
],
14451447
)
14461448
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))

0 commit comments

Comments
 (0)