Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
746f693
chore: remove custom code
stainless-app[bot] Mar 17, 2025
3bfe6e6
codegen metadata
stainless-app[bot] Mar 17, 2025
1bf7016
fix(ci): ensure pip is always available (#185)
stainless-app[bot] Mar 17, 2025
077f917
fix(ci): remove publishing patch (#186)
stainless-app[bot] Mar 17, 2025
dcaee52
codegen metadata
stainless-app[bot] Mar 20, 2025
645b80a
feat(api): api update (#187)
stainless-app[bot] Mar 21, 2025
ebd0446
feat(api): api update (#188)
stainless-app[bot] Mar 24, 2025
f294618
chore: fix typos (#189)
stainless-app[bot] Mar 27, 2025
696b007
codegen metadata
stainless-app[bot] Mar 27, 2025
fabff6d
feat(api): api update (#190)
stainless-app[bot] Mar 27, 2025
0270755
feat(api): api update (#191)
stainless-app[bot] Mar 30, 2025
d70fbc1
codegen metadata
stainless-app[bot] Mar 30, 2025
5a0c771
codegen metadata
stainless-app[bot] Mar 31, 2025
d6d57bc
feat(api): api update (#192)
stainless-app[bot] Apr 1, 2025
1ae0d26
codegen metadata
stainless-app[bot] Apr 2, 2025
4483c2f
chore(internal): minor test fixes (#193)
stainless-app[bot] Apr 3, 2025
27b9d4f
chore(internal): remove trailing character (#194)
stainless-app[bot] Apr 4, 2025
fb83cf4
chore(internal): codegen related update (#195)
stainless-app[bot] Apr 5, 2025
addbcf9
feat(api): api update (#196)
stainless-app[bot] Apr 8, 2025
1f09d5b
chore(internal): slight transform perf improvement (#197)
stainless-app[bot] Apr 9, 2025
133aa56
chore(tests): improve enum examples (#198)
stainless-app[bot] Apr 9, 2025
9424bae
chore: slight wording improvement in README (#199)
stainless-app[bot] Apr 9, 2025
dc51949
release: 5.3.0
stainless-app[bot] Apr 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
/home/runner/.rye/self/bin/python3 -m ensurepip --default-pip
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.2.0"
".": "5.3.0"
}
4 changes: 3 additions & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
configured_endpoints: 96
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-a5dd7235306810ee00a03bee4d754c8af4852a2513fa575bfa142d0287b12d35.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-5f188889fe648ea83d57911900fe61825d9d7d1446fce966ffca7a9bbe2e3079.yml
openapi_spec_hash: 42af219a138819686969b60410be0cb6
config_hash: 575ddfb316392e5f7f3c7b7999796a03
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## 5.3.0 (2025-04-09)

Full Changelog: [v5.2.0...v5.3.0](https://github.com/DataMini/asktable-python/compare/v5.2.0...v5.3.0)

### Features

* **api:** api update ([#187](https://github.com/DataMini/asktable-python/issues/187)) ([645b80a](https://github.com/DataMini/asktable-python/commit/645b80a780d0409c0368ab2ec7d4c811b4bb74ac))
* **api:** api update ([#188](https://github.com/DataMini/asktable-python/issues/188)) ([ebd0446](https://github.com/DataMini/asktable-python/commit/ebd044644cd2bd152456b124e4b356cd08bfdc76))
* **api:** api update ([#190](https://github.com/DataMini/asktable-python/issues/190)) ([fabff6d](https://github.com/DataMini/asktable-python/commit/fabff6d4a56673e1c6b60744e88607fc773abc55))
* **api:** api update ([#191](https://github.com/DataMini/asktable-python/issues/191)) ([0270755](https://github.com/DataMini/asktable-python/commit/0270755b827e9ea9227ce977e026fefaf1189da0))
* **api:** api update ([#192](https://github.com/DataMini/asktable-python/issues/192)) ([d6d57bc](https://github.com/DataMini/asktable-python/commit/d6d57bcf4eb98b8adb76508963ecc6a7ac2aaa01))
* **api:** api update ([#196](https://github.com/DataMini/asktable-python/issues/196)) ([addbcf9](https://github.com/DataMini/asktable-python/commit/addbcf9cdb9d3f6c710ac53f94b529c236eaa5c0))


### Bug Fixes

* **ci:** ensure pip is always available ([#185](https://github.com/DataMini/asktable-python/issues/185)) ([1bf7016](https://github.com/DataMini/asktable-python/commit/1bf701617a81109d6071e06f09910349544cbf6f))
* **ci:** remove publishing patch ([#186](https://github.com/DataMini/asktable-python/issues/186)) ([077f917](https://github.com/DataMini/asktable-python/commit/077f9172189fb51d058fdaf48671d1c74d1c73cf))


### Chores

* fix typos ([#189](https://github.com/DataMini/asktable-python/issues/189)) ([f294618](https://github.com/DataMini/asktable-python/commit/f294618bf32edd5a19f1a357f13e78e4c0fec096))
* **internal:** codegen related update ([#195](https://github.com/DataMini/asktable-python/issues/195)) ([fb83cf4](https://github.com/DataMini/asktable-python/commit/fb83cf4102ccb7da31a7f66419aa937db9338982))
* **internal:** minor test fixes ([#193](https://github.com/DataMini/asktable-python/issues/193)) ([4483c2f](https://github.com/DataMini/asktable-python/commit/4483c2fefd7f57ed9dfaebc62f4b3d5677d282ee))
* **internal:** remove trailing character ([#194](https://github.com/DataMini/asktable-python/issues/194)) ([27b9d4f](https://github.com/DataMini/asktable-python/commit/27b9d4fbd4a9579c98faa74a75fe87a77489e1b2))
* **internal:** slight transform perf improvement ([#197](https://github.com/DataMini/asktable-python/issues/197)) ([1f09d5b](https://github.com/DataMini/asktable-python/commit/1f09d5b9d3e0119efdbed970898899428406fb29))
* remove custom code ([746f693](https://github.com/DataMini/asktable-python/commit/746f6936a501d656086f6342abed4a54ab07be96))
* slight wording improvement in README ([#199](https://github.com/DataMini/asktable-python/issues/199)) ([9424bae](https://github.com/DataMini/asktable-python/commit/9424bae54d01f1f69cf148f7e941e2149b90b905))
* **tests:** improve enum examples ([#198](https://github.com/DataMini/asktable-python/issues/198)) ([133aa56](https://github.com/DataMini/asktable-python/commit/133aa566654b70214d489a66ab929a17edf93918))

## 5.2.0 (2025-03-17)

Full Changelog: [v5.1.0...v5.2.0](https://github.com/DataMini/asktable-python/compare/v5.1.0...v5.2.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ print(response.chat_role)

## File uploads

Request parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.

```python
from pathlib import Path
Expand Down
3 changes: 0 additions & 3 deletions bin/publish-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
set -eux
mkdir -p dist
rye build --clean
# Patching importlib-metadata version until upstream library version is updated
# https://github.com/pypa/twine/issues/977#issuecomment-2189800841
"$HOME/.rye/self/bin/python3" -m pip install 'importlib-metadata==7.2.1'
rye publish --yes --token=$PYPI_TOKEN
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "asktable"
version = "5.2.0"
version = "5.3.0"
description = "The official Python library for the Asktable API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -86,7 +86,7 @@ typecheck = { chain = [
"typecheck:mypy" = "mypy ."

[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[tool.hatch.build]
Expand Down
2 changes: 1 addition & 1 deletion src/asktable/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None:
setattr(typ, "__pydantic_config__", config) # noqa: B010


# our use of subclasssing here causes weirdness for type checkers,
# our use of subclassing here causes weirdness for type checkers,
# so we just pretend that we don't subclass
if TYPE_CHECKING:
GenericModel = BaseModel
Expand Down
24 changes: 23 additions & 1 deletion src/asktable/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _get_annotated_type(type_: type) -> type | None:
def _maybe_transform_key(key: str, type_: type) -> str:
"""Transform the given `data` based on the annotations provided in `type_`.

Note: this function only looks at `Annotated` types that contain `PropertInfo` metadata.
Note: this function only looks at `Annotated` types that contain `PropertyInfo` metadata.
"""
annotated_type = _get_annotated_type(type_)
if annotated_type is None:
Expand All @@ -142,6 +142,10 @@ def _maybe_transform_key(key: str, type_: type) -> str:
return key


def _no_transform_needed(annotation: type) -> bool:
return annotation == float or annotation == int


def _transform_recursive(
data: object,
*,
Expand Down Expand Up @@ -184,6 +188,15 @@ def _transform_recursive(
return cast(object, data)

inner_type = extract_type_arg(stripped_type, 0)
if _no_transform_needed(inner_type):
# for some types there is no need to transform anything, so we can get a small
# perf boost from skipping that work.
#
# but we still need to convert to a list to ensure the data is json-serializable
if is_list(data):
return data
return list(data)

return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]

if is_union_type(stripped_type):
Expand Down Expand Up @@ -332,6 +345,15 @@ async def _async_transform_recursive(
return cast(object, data)

inner_type = extract_type_arg(stripped_type, 0)
if _no_transform_needed(inner_type):
# for some types there is no need to transform anything, so we can get a small
# perf boost from skipping that work.
#
# but we still need to convert to a list to ensure the data is json-serializable
if is_list(data):
return data
return list(data)

return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]

if is_union_type(stripped_type):
Expand Down
2 changes: 1 addition & 1 deletion src/asktable/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "asktable"
__version__ = "5.2.0" # x-release-please-version
__version__ = "5.3.0" # x-release-please-version
40 changes: 40 additions & 0 deletions src/asktable/resources/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def create(
magic_input: Optional[str] | NotGiven = NOT_GIVEN,
max_rows: int | NotGiven = NOT_GIVEN,
publish: bool | NotGiven = NOT_GIVEN,
query_balance: Optional[int] | NotGiven = NOT_GIVEN,
sample_questions: Optional[List[str]] | NotGiven = NOT_GIVEN,
webhooks: List[str] | NotGiven = NOT_GIVEN,
welcome_message: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -87,8 +89,12 @@ def create(

publish: 是否公开

query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数

sample_questions: 示例问题列表

webhooks: Webhook URL 列表

welcome_message: 欢迎消息

extra_headers: Send extra headers
Expand All @@ -111,7 +117,9 @@ def create(
"magic_input": magic_input,
"max_rows": max_rows,
"publish": publish,
"query_balance": query_balance,
"sample_questions": sample_questions,
"webhooks": webhooks,
"welcome_message": welcome_message,
},
bot_create_params.BotCreateParams,
Expand Down Expand Up @@ -168,7 +176,9 @@ def update(
max_rows: Optional[int] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
publish: Optional[bool] | NotGiven = NOT_GIVEN,
query_balance: Optional[int] | NotGiven = NOT_GIVEN,
sample_questions: Optional[List[str]] | NotGiven = NOT_GIVEN,
webhooks: Optional[List[str]] | NotGiven = NOT_GIVEN,
welcome_message: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -199,8 +209,12 @@ def update(

publish: 是否公开

query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数

sample_questions: 示例问题列表

webhooks: Webhook URL 列表

welcome_message: 欢迎消息

extra_headers: Send extra headers
Expand All @@ -226,7 +240,9 @@ def update(
"max_rows": max_rows,
"name": name,
"publish": publish,
"query_balance": query_balance,
"sample_questions": sample_questions,
"webhooks": webhooks,
"welcome_message": welcome_message,
},
bot_update_params.BotUpdateParams,
Expand All @@ -240,6 +256,7 @@ def update(
def list(
self,
*,
bot_ids: Optional[List[str]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
Expand All @@ -254,6 +271,8 @@ def list(
查询所有 Bot

Args:
bot_ids: Bot ID

name: 名称

page: Page number
Expand All @@ -278,6 +297,7 @@ def list(
timeout=timeout,
query=maybe_transform(
{
"bot_ids": bot_ids,
"name": name,
"page": page,
"size": size,
Expand Down Expand Up @@ -391,7 +411,9 @@ async def create(
magic_input: Optional[str] | NotGiven = NOT_GIVEN,
max_rows: int | NotGiven = NOT_GIVEN,
publish: bool | NotGiven = NOT_GIVEN,
query_balance: Optional[int] | NotGiven = NOT_GIVEN,
sample_questions: Optional[List[str]] | NotGiven = NOT_GIVEN,
webhooks: List[str] | NotGiven = NOT_GIVEN,
welcome_message: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -420,8 +442,12 @@ async def create(

publish: 是否公开

query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数

sample_questions: 示例问题列表

webhooks: Webhook URL 列表

welcome_message: 欢迎消息

extra_headers: Send extra headers
Expand All @@ -444,7 +470,9 @@ async def create(
"magic_input": magic_input,
"max_rows": max_rows,
"publish": publish,
"query_balance": query_balance,
"sample_questions": sample_questions,
"webhooks": webhooks,
"welcome_message": welcome_message,
},
bot_create_params.BotCreateParams,
Expand Down Expand Up @@ -501,7 +529,9 @@ async def update(
max_rows: Optional[int] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
publish: Optional[bool] | NotGiven = NOT_GIVEN,
query_balance: Optional[int] | NotGiven = NOT_GIVEN,
sample_questions: Optional[List[str]] | NotGiven = NOT_GIVEN,
webhooks: Optional[List[str]] | NotGiven = NOT_GIVEN,
welcome_message: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -532,8 +562,12 @@ async def update(

publish: 是否公开

query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数

sample_questions: 示例问题列表

webhooks: Webhook URL 列表

welcome_message: 欢迎消息

extra_headers: Send extra headers
Expand All @@ -559,7 +593,9 @@ async def update(
"max_rows": max_rows,
"name": name,
"publish": publish,
"query_balance": query_balance,
"sample_questions": sample_questions,
"webhooks": webhooks,
"welcome_message": welcome_message,
},
bot_update_params.BotUpdateParams,
Expand All @@ -573,6 +609,7 @@ async def update(
def list(
self,
*,
bot_ids: Optional[List[str]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
Expand All @@ -587,6 +624,8 @@ def list(
查询所有 Bot

Args:
bot_ids: Bot ID

name: 名称

page: Page number
Expand All @@ -611,6 +650,7 @@ def list(
timeout=timeout,
query=maybe_transform(
{
"bot_ids": bot_ids,
"name": name,
"page": page,
"size": size,
Expand Down
4 changes: 2 additions & 2 deletions src/asktable/resources/chats/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def create(
name: Optional[str] | NotGiven = NOT_GIVEN,
role_id: Optional[str] | NotGiven = NOT_GIVEN,
role_variables: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
user_profile: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
user_profile: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -263,7 +263,7 @@ async def create(
name: Optional[str] | NotGiven = NOT_GIVEN,
role_id: Optional[str] | NotGiven = NOT_GIVEN,
role_variables: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
user_profile: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
user_profile: Optional[Dict[str, Union[str, int, bool]]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
Loading