diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 8c231268..188841d6 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -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' diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b29b3b64..41010749 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.2.0" + ".": "5.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index efe0ae1c..17ea7ce7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1fd3c6..eb0e1a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 84a1c27b..7a3d8291 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/publish-pypi b/bin/publish-pypi index 05bfccbb..826054e9 100644 --- a/bin/publish-pypi +++ b/bin/publish-pypi @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 0ae2be3d..9ffa8bbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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] diff --git a/src/asktable/_models.py b/src/asktable/_models.py index b51a1bf5..34935716 100644 --- a/src/asktable/_models.py +++ b/src/asktable/_models.py @@ -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 diff --git a/src/asktable/_utils/_transform.py b/src/asktable/_utils/_transform.py index 18afd9d8..3ec62081 100644 --- a/src/asktable/_utils/_transform.py +++ b/src/asktable/_utils/_transform.py @@ -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: @@ -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, *, @@ -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): @@ -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): diff --git a/src/asktable/_version.py b/src/asktable/_version.py index 3a989bcc..f432bb10 100644 --- a/src/asktable/_version.py +++ b/src/asktable/_version.py @@ -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 diff --git a/src/asktable/resources/bots.py b/src/asktable/resources/bots.py index 6ce7781e..1cfc9725 100644 --- a/src/asktable/resources/bots.py +++ b/src/asktable/resources/bots.py @@ -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. @@ -87,8 +89,12 @@ def create( publish: 是否公开 + query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数 + sample_questions: 示例问题列表 + webhooks: Webhook URL 列表 + welcome_message: 欢迎消息 extra_headers: Send extra headers @@ -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, @@ -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. @@ -199,8 +209,12 @@ def update( publish: 是否公开 + query_balance: bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数 + sample_questions: 示例问题列表 + webhooks: Webhook URL 列表 + welcome_message: 欢迎消息 extra_headers: Send extra headers @@ -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, @@ -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, @@ -254,6 +271,8 @@ def list( 查询所有 Bot Args: + bot_ids: Bot ID + name: 名称 page: Page number @@ -278,6 +297,7 @@ def list( timeout=timeout, query=maybe_transform( { + "bot_ids": bot_ids, "name": name, "page": page, "size": size, @@ -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. @@ -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 @@ -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, @@ -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. @@ -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 @@ -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, @@ -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, @@ -587,6 +624,8 @@ def list( 查询所有 Bot Args: + bot_ids: Bot ID + name: 名称 page: Page number @@ -611,6 +650,7 @@ def list( timeout=timeout, query=maybe_transform( { + "bot_ids": bot_ids, "name": name, "page": page, "size": size, diff --git a/src/asktable/resources/chats/chats.py b/src/asktable/resources/chats/chats.py index 661ca731..123f7d69 100644 --- a/src/asktable/resources/chats/chats.py +++ b/src/asktable/resources/chats/chats.py @@ -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, @@ -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, diff --git a/src/asktable/resources/datasources/datasources.py b/src/asktable/resources/datasources/datasources.py index 17bebdff..a2b1b03e 100644 --- a/src/asktable/resources/datasources/datasources.py +++ b/src/asktable/resources/datasources/datasources.py @@ -112,6 +112,7 @@ def create( "dameng", "adbmysql", "adbpostgres", + "xugu", ], access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, name: Optional[str] | NotGiven = NOT_GIVEN, @@ -211,6 +212,7 @@ def update( "dameng", "adbmysql", "adbpostgres", + "xugu", ] ] | NotGiven = NOT_GIVEN, @@ -485,6 +487,10 @@ def update_field( field_name: str, schema_name: str, table_name: str, + identifiable_type: Optional[ + Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"] + ] + | NotGiven = NOT_GIVEN, visibility: Optional[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. @@ -497,6 +503,8 @@ def update_field( 更新数据源的某个字段的描述 Args: + identifiable_type: identifiable type + visibility: field visibility extra_headers: Send extra headers @@ -512,7 +520,11 @@ def update_field( return self._patch( f"/v1/datasources/{datasource_id}/field", body=maybe_transform( - {"visibility": visibility}, datasource_update_field_params.DatasourceUpdateFieldParams + { + "identifiable_type": identifiable_type, + "visibility": visibility, + }, + datasource_update_field_params.DatasourceUpdateFieldParams, ), options=make_request_options( extra_headers=extra_headers, @@ -582,6 +594,7 @@ async def create( "dameng", "adbmysql", "adbpostgres", + "xugu", ], access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, name: Optional[str] | NotGiven = NOT_GIVEN, @@ -681,6 +694,7 @@ async def update( "dameng", "adbmysql", "adbpostgres", + "xugu", ] ] | NotGiven = NOT_GIVEN, @@ -955,6 +969,10 @@ async def update_field( field_name: str, schema_name: str, table_name: str, + identifiable_type: Optional[ + Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"] + ] + | NotGiven = NOT_GIVEN, visibility: Optional[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. @@ -967,6 +985,8 @@ async def update_field( 更新数据源的某个字段的描述 Args: + identifiable_type: identifiable type + visibility: field visibility extra_headers: Send extra headers @@ -982,7 +1002,11 @@ async def update_field( return await self._patch( f"/v1/datasources/{datasource_id}/field", body=await async_maybe_transform( - {"visibility": visibility}, datasource_update_field_params.DatasourceUpdateFieldParams + { + "identifiable_type": identifiable_type, + "visibility": visibility, + }, + datasource_update_field_params.DatasourceUpdateFieldParams, ), options=make_request_options( extra_headers=extra_headers, diff --git a/src/asktable/types/bot_create_params.py b/src/asktable/types/bot_create_params.py index 43088a3f..7e0ada9e 100644 --- a/src/asktable/types/bot_create_params.py +++ b/src/asktable/types/bot_create_params.py @@ -33,8 +33,14 @@ class BotCreateParams(TypedDict, total=False): publish: bool """是否公开""" + query_balance: Optional[int] + """bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数""" + sample_questions: Optional[List[str]] """示例问题列表""" + webhooks: List[str] + """Webhook URL 列表""" + welcome_message: Optional[str] """欢迎消息""" diff --git a/src/asktable/types/bot_list_params.py b/src/asktable/types/bot_list_params.py index af394450..2463c813 100644 --- a/src/asktable/types/bot_list_params.py +++ b/src/asktable/types/bot_list_params.py @@ -2,13 +2,16 @@ from __future__ import annotations -from typing import Optional +from typing import List, Optional from typing_extensions import TypedDict __all__ = ["BotListParams"] class BotListParams(TypedDict, total=False): + bot_ids: Optional[List[str]] + """Bot ID""" + name: Optional[str] """名称""" diff --git a/src/asktable/types/bot_update_params.py b/src/asktable/types/bot_update_params.py index 239c8e71..e5946079 100644 --- a/src/asktable/types/bot_update_params.py +++ b/src/asktable/types/bot_update_params.py @@ -36,8 +36,14 @@ class BotUpdateParams(TypedDict, total=False): publish: Optional[bool] """是否公开""" + query_balance: Optional[int] + """bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 0 的整数""" + sample_questions: Optional[List[str]] """示例问题列表""" + webhooks: Optional[List[str]] + """Webhook URL 列表""" + welcome_message: Optional[str] """欢迎消息""" diff --git a/src/asktable/types/chat.py b/src/asktable/types/chat.py index 5d26c3e8..ff282d79 100644 --- a/src/asktable/types/chat.py +++ b/src/asktable/types/chat.py @@ -43,5 +43,5 @@ class Chat(BaseModel): role_variables: Optional[Dict[str, Union[str, int, bool]]] = None """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递""" - user_profile: Optional[Dict[str, str]] = None + user_profile: Optional[Dict[str, Union[str, int, bool]]] = None """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递""" diff --git a/src/asktable/types/chat_create_params.py b/src/asktable/types/chat_create_params.py index 74302e71..ca697335 100644 --- a/src/asktable/types/chat_create_params.py +++ b/src/asktable/types/chat_create_params.py @@ -27,5 +27,5 @@ class ChatCreateParams(TypedDict, total=False): role_variables: Optional[Dict[str, Union[str, int, bool]]] """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递""" - user_profile: Optional[Dict[str, str]] + user_profile: Optional[Dict[str, Union[str, int, bool]]] """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递""" diff --git a/src/asktable/types/chat_retrieve_response.py b/src/asktable/types/chat_retrieve_response.py index 2999466c..3868c1a8 100644 --- a/src/asktable/types/chat_retrieve_response.py +++ b/src/asktable/types/chat_retrieve_response.py @@ -45,7 +45,9 @@ class ChatRetrieveResponse(BaseModel): role_variables: Optional[Dict[str, Union[str, int, bool]]] = None """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递""" - user_profile: Optional[Dict[str, str]] = None + sample_questions: Optional[List[str]] = None + + user_profile: Optional[Dict[str, Union[str, int, bool]]] = None """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递""" welcome_message: Optional[str] = None diff --git a/src/asktable/types/chatbot.py b/src/asktable/types/chatbot.py index 616249e5..5f86403e 100644 --- a/src/asktable/types/chatbot.py +++ b/src/asktable/types/chatbot.py @@ -44,8 +44,14 @@ class Chatbot(BaseModel): publish: Optional[bool] = None """是否公开""" + query_balance: Optional[int] = None + """bot 的查询次数,默认是 None,表示无限次查询,入参为大于等于 1 的整数""" + sample_questions: Optional[List[str]] = None """示例问题列表""" + webhooks: Optional[List[str]] = None + """Webhook URL 列表""" + welcome_message: Optional[str] = None """欢迎消息""" diff --git a/src/asktable/types/datasource.py b/src/asktable/types/datasource.py index 1147fb85..8cfe326c 100644 --- a/src/asktable/types/datasource.py +++ b/src/asktable/types/datasource.py @@ -31,6 +31,7 @@ class Datasource(BaseModel): "dameng", "adbmysql", "adbpostgres", + "xugu", ] """数据源引擎""" diff --git a/src/asktable/types/datasource_create_params.py b/src/asktable/types/datasource_create_params.py index 61920464..8ddc93cb 100644 --- a/src/asktable/types/datasource_create_params.py +++ b/src/asktable/types/datasource_create_params.py @@ -30,6 +30,7 @@ class DatasourceCreateParams(TypedDict, total=False): "dameng", "adbmysql", "adbpostgres", + "xugu", ] ] """数据源引擎""" diff --git a/src/asktable/types/datasource_retrieve_response.py b/src/asktable/types/datasource_retrieve_response.py index 512130d4..50a24de8 100644 --- a/src/asktable/types/datasource_retrieve_response.py +++ b/src/asktable/types/datasource_retrieve_response.py @@ -76,6 +76,7 @@ class DatasourceRetrieveResponse(BaseModel): "dameng", "adbmysql", "adbpostgres", + "xugu", ] """数据源引擎""" diff --git a/src/asktable/types/datasource_retrieve_runtime_meta_response.py b/src/asktable/types/datasource_retrieve_runtime_meta_response.py index 4465ecb6..3ddeefcf 100644 --- a/src/asktable/types/datasource_retrieve_runtime_meta_response.py +++ b/src/asktable/types/datasource_retrieve_runtime_meta_response.py @@ -1,12 +1,21 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Dict, List +from typing_extensions import Literal from .._models import BaseModel -__all__ = ["DatasourceRetrieveRuntimeMetaResponse"] +__all__ = ["DatasourceRetrieveRuntimeMetaResponse", "Schema"] + + +class Schema(BaseModel): + name: str + """表名称数据""" + + type: Literal["table", "view"] + """表的类型""" class DatasourceRetrieveRuntimeMetaResponse(BaseModel): - schemas: Dict[str, List[str]] + schemas: Dict[str, List[Schema]] """元数据""" diff --git a/src/asktable/types/datasource_update_field_params.py b/src/asktable/types/datasource_update_field_params.py index 9236c80e..f756bdf4 100644 --- a/src/asktable/types/datasource_update_field_params.py +++ b/src/asktable/types/datasource_update_field_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["DatasourceUpdateFieldParams"] @@ -15,5 +15,8 @@ class DatasourceUpdateFieldParams(TypedDict, total=False): table_name: Required[str] + identifiable_type: Optional[Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"]] + """identifiable type""" + visibility: Optional[bool] """field visibility""" diff --git a/src/asktable/types/datasource_update_params.py b/src/asktable/types/datasource_update_params.py index fb3a53d0..4abe181d 100644 --- a/src/asktable/types/datasource_update_params.py +++ b/src/asktable/types/datasource_update_params.py @@ -36,6 +36,7 @@ class DatasourceUpdateParams(TypedDict, total=False): "dameng", "adbmysql", "adbpostgres", + "xugu", ] ] """数据源引擎""" diff --git a/src/asktable/types/datasources/meta_create_params.py b/src/asktable/types/datasources/meta_create_params.py index 5684c17b..4d452ff8 100644 --- a/src/asktable/types/datasources/meta_create_params.py +++ b/src/asktable/types/datasources/meta_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, List, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["MetaCreateParams", "Meta", "MetaSchemas", "MetaSchemasTables", "MetaSchemasTablesFields"] @@ -28,6 +28,9 @@ class MetaSchemasTablesFields(TypedDict, total=False): data_type: Optional[str] """field data type""" + identifiable_type: Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"] + """identifiable type""" + sample_data: Optional[str] """field sample data""" @@ -44,6 +47,9 @@ class MetaSchemasTables(TypedDict, total=False): fields: Dict[str, MetaSchemasTablesFields] + table_type: Literal["table", "view"] + """table type""" + class MetaSchemas(TypedDict, total=False): name: Required[str] diff --git a/src/asktable/types/datasources/meta_update_params.py b/src/asktable/types/datasources/meta_update_params.py index 997a0110..862f0776 100644 --- a/src/asktable/types/datasources/meta_update_params.py +++ b/src/asktable/types/datasources/meta_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, List, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["MetaUpdateParams", "Meta", "MetaSchemas", "MetaSchemasTables", "MetaSchemasTablesFields"] @@ -26,6 +26,9 @@ class MetaSchemasTablesFields(TypedDict, total=False): data_type: Optional[str] """field data type""" + identifiable_type: Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"] + """identifiable type""" + sample_data: Optional[str] """field sample data""" @@ -42,6 +45,9 @@ class MetaSchemasTables(TypedDict, total=False): fields: Dict[str, MetaSchemasTablesFields] + table_type: Literal["table", "view"] + """table type""" + class MetaSchemas(TypedDict, total=False): name: Required[str] diff --git a/src/asktable/types/meta.py b/src/asktable/types/meta.py index c7c1877a..05cd5f20 100644 --- a/src/asktable/types/meta.py +++ b/src/asktable/types/meta.py @@ -2,6 +2,7 @@ from typing import Dict, Optional from datetime import datetime +from typing_extensions import Literal from .._models import BaseModel @@ -33,6 +34,11 @@ class SchemasTablesFields(BaseModel): data_type: Optional[str] = None """field data type""" + identifiable_type: Optional[ + Literal["plain", "person_name", "email", "ssn", "id", "phone", "address", "company"] + ] = None + """identifiable type""" + sample_data: Optional[str] = None """field sample data""" @@ -58,6 +64,9 @@ class SchemasTables(BaseModel): origin_desc: str """table description from database""" + table_type: Optional[Literal["table", "view"]] = None + """table type""" + class Schemas(BaseModel): curr_desc: str diff --git a/tests/api_resources/datasources/test_meta.py b/tests/api_resources/datasources/test_meta.py index 4b5c86a0..91a71800 100644 --- a/tests/api_resources/datasources/test_meta.py +++ b/tests/api_resources/datasources/test_meta.py @@ -45,10 +45,12 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: "name": "name", "origin_desc": "origin_desc", "data_type": "data_type", + "identifiable_type": "plain", "sample_data": "sample_data", "visibility": True, } }, + "table_type": "table", } }, } @@ -154,10 +156,12 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: "name": "name", "origin_desc": "origin_desc", "data_type": "data_type", + "identifiable_type": "plain", "sample_data": "sample_data", "visibility": True, } }, + "table_type": "table", } }, } @@ -272,10 +276,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) "name": "name", "origin_desc": "origin_desc", "data_type": "data_type", + "identifiable_type": "plain", "sample_data": "sample_data", "visibility": True, } }, + "table_type": "table", } }, } @@ -381,10 +387,12 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) "name": "name", "origin_desc": "origin_desc", "data_type": "data_type", + "identifiable_type": "plain", "sample_data": "sample_data", "visibility": True, } }, + "table_type": "table", } }, } diff --git a/tests/api_resources/extapis/test_routes.py b/tests/api_resources/extapis/test_routes.py index 1076391e..65ed8f4a 100644 --- a/tests/api_resources/extapis/test_routes.py +++ b/tests/api_resources/extapis/test_routes.py @@ -98,7 +98,7 @@ def test_path_params_create(self, client: Asktable) -> None: path_extapi_id="", id="id", created_at=parse_datetime("2019-12-27T18:11:19.117Z"), - body_extapi_id="", + body_extapi_id="extapi_id", method="GET", name="name", path="/resource", @@ -386,7 +386,7 @@ async def test_path_params_create(self, async_client: AsyncAsktable) -> None: path_extapi_id="", id="id", created_at=parse_datetime("2019-12-27T18:11:19.117Z"), - body_extapi_id="", + body_extapi_id="extapi_id", method="GET", name="name", path="/resource", diff --git a/tests/api_resources/sys/projects/test_api_keys.py b/tests/api_resources/sys/projects/test_api_keys.py index cf170f47..9a7325f0 100644 --- a/tests/api_resources/sys/projects/test_api_keys.py +++ b/tests/api_resources/sys/projects/test_api_keys.py @@ -24,7 +24,7 @@ class TestAPIKeys: def test_method_create(self, client: Asktable) -> None: api_key = client.sys.projects.api_keys.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) assert_matches_type(APIKeyCreateResponse, api_key, path=["response"]) @@ -32,7 +32,7 @@ def test_method_create(self, client: Asktable) -> None: def test_raw_response_create(self, client: Asktable) -> None: response = client.sys.projects.api_keys.with_raw_response.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) assert response.is_closed is True @@ -44,7 +44,7 @@ def test_raw_response_create(self, client: Asktable) -> None: def test_streaming_response_create(self, client: Asktable) -> None: with client.sys.projects.api_keys.with_streaming_response.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -59,7 +59,7 @@ def test_path_params_create(self, client: Asktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"): client.sys.projects.api_keys.with_raw_response.create( project_id="", - ak_role="sys", + ak_role="admin", ) @parametrize @@ -159,7 +159,7 @@ def test_method_create_token(self, client: Asktable) -> None: def test_method_create_token_with_all_params(self, client: Asktable) -> None: api_key = client.sys.projects.api_keys.create_token( project_id="project_id", - ak_role="sys", + ak_role="asker", chat_role={ "role_id": "1", "role_variables": {"id": "42"}, @@ -208,7 +208,7 @@ class TestAsyncAPIKeys: async def test_method_create(self, async_client: AsyncAsktable) -> None: api_key = await async_client.sys.projects.api_keys.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) assert_matches_type(APIKeyCreateResponse, api_key, path=["response"]) @@ -216,7 +216,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: response = await async_client.sys.projects.api_keys.with_raw_response.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) assert response.is_closed is True @@ -228,7 +228,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: async with async_client.sys.projects.api_keys.with_streaming_response.create( project_id="project_id", - ak_role="sys", + ak_role="admin", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -243,7 +243,7 @@ async def test_path_params_create(self, async_client: AsyncAsktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"): await async_client.sys.projects.api_keys.with_raw_response.create( project_id="", - ak_role="sys", + ak_role="admin", ) @parametrize @@ -343,7 +343,7 @@ async def test_method_create_token(self, async_client: AsyncAsktable) -> None: async def test_method_create_token_with_all_params(self, async_client: AsyncAsktable) -> None: api_key = await async_client.sys.projects.api_keys.create_token( project_id="project_id", - ak_role="sys", + ak_role="asker", chat_role={ "role_id": "1", "role_variables": {"id": "42"}, diff --git a/tests/api_resources/sys/test_projects.py b/tests/api_resources/sys/test_projects.py index 0b45c0ba..97e7ebc8 100644 --- a/tests/api_resources/sys/test_projects.py +++ b/tests/api_resources/sys/test_projects.py @@ -147,7 +147,7 @@ def test_method_list(self, client: Asktable) -> None: def test_method_list_with_all_params(self, client: Asktable) -> None: project = client.sys.projects.list( page=1, - project_ids=["string"], + project_ids=["string", "string"], size=1, ) assert_matches_type(SyncPage[Project], project, path=["response"]) @@ -365,7 +365,7 @@ async def test_method_list(self, async_client: AsyncAsktable) -> None: async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None: project = await async_client.sys.projects.list( page=1, - project_ids=["string"], + project_ids=["string", "string"], size=1, ) assert_matches_type(AsyncPage[Project], project, path=["response"]) diff --git a/tests/api_resources/test_auth.py b/tests/api_resources/test_auth.py index a834d2c3..18a08f28 100644 --- a/tests/api_resources/test_auth.py +++ b/tests/api_resources/test_auth.py @@ -25,7 +25,7 @@ def test_method_create_token(self, client: Asktable) -> None: @parametrize def test_method_create_token_with_all_params(self, client: Asktable) -> None: auth = client.auth.create_token( - ak_role="sys", + ak_role="asker", chat_role={ "role_id": "1", "role_variables": {"id": "42"}, @@ -92,7 +92,7 @@ async def test_method_create_token(self, async_client: AsyncAsktable) -> None: @parametrize async def test_method_create_token_with_all_params(self, async_client: AsyncAsktable) -> None: auth = await async_client.auth.create_token( - ak_role="sys", + ak_role="asker", chat_role={ "role_id": "1", "role_variables": {"id": "42"}, diff --git a/tests/api_resources/test_bots.py b/tests/api_resources/test_bots.py index 37748566..787b84d8 100644 --- a/tests/api_resources/test_bots.py +++ b/tests/api_resources/test_bots.py @@ -37,7 +37,9 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: magic_input="magic_input", max_rows=50, publish=True, + query_balance=100, sample_questions=["你好!今天中午有什么适合我的午餐?"], + webhooks=["string"], welcome_message="欢迎使用AskTable", ) assert_matches_type(Chatbot, bot, path=["response"]) @@ -126,7 +128,9 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: max_rows=50, name="name", publish=True, + query_balance=100, sample_questions=["你好!今天中午有什么适合我的午餐?"], + webhooks=["string"], welcome_message="欢迎使用AskTable", ) assert_matches_type(Chatbot, bot, path=["response"]) @@ -170,6 +174,7 @@ def test_method_list(self, client: Asktable) -> None: @parametrize def test_method_list_with_all_params(self, client: Asktable) -> None: bot = client.bots.list( + bot_ids=["string", "string"], name="name", page=1, size=1, @@ -299,7 +304,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) magic_input="magic_input", max_rows=50, publish=True, + query_balance=100, sample_questions=["你好!今天中午有什么适合我的午餐?"], + webhooks=["string"], welcome_message="欢迎使用AskTable", ) assert_matches_type(Chatbot, bot, path=["response"]) @@ -388,7 +395,9 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) max_rows=50, name="name", publish=True, + query_balance=100, sample_questions=["你好!今天中午有什么适合我的午餐?"], + webhooks=["string"], welcome_message="欢迎使用AskTable", ) assert_matches_type(Chatbot, bot, path=["response"]) @@ -432,6 +441,7 @@ async def test_method_list(self, async_client: AsyncAsktable) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None: bot = await async_client.bots.list( + bot_ids=["string", "string"], name="name", page=1, size=1, diff --git a/tests/api_resources/test_chats.py b/tests/api_resources/test_chats.py index 5a84e9da..254fc7c6 100644 --- a/tests/api_resources/test_chats.py +++ b/tests/api_resources/test_chats.py @@ -31,8 +31,8 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: role_id="role_42", role_variables={"id": "123123123"}, user_profile={ - "age": "string", - "is_male": "string", + "age": 18, + "is_male": True, "name": "张三", }, ) @@ -184,8 +184,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) role_id="role_42", role_variables={"id": "123123123"}, user_profile={ - "age": "string", - "is_male": "string", + "age": 18, + "is_male": True, "name": "张三", }, ) diff --git a/tests/api_resources/test_datasources.py b/tests/api_resources/test_datasources.py index a99d4858..758b1d57 100644 --- a/tests/api_resources/test_datasources.py +++ b/tests/api_resources/test_datasources.py @@ -134,7 +134,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: engine="mysql", field_count=1, meta_error="error message", - meta_status="processing", + meta_status="success", name="用户库", sample_questions="示例问题", schema_count=1, @@ -390,6 +390,7 @@ def test_method_update_field_with_all_params(self, client: Asktable) -> None: field_name="field_name", schema_name="schema_name", table_name="table_name", + identifiable_type="plain", visibility=True, ) assert_matches_type(object, datasource, path=["response"]) @@ -550,7 +551,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) engine="mysql", field_count=1, meta_error="error message", - meta_status="processing", + meta_status="success", name="用户库", sample_questions="示例问题", schema_count=1, @@ -806,6 +807,7 @@ async def test_method_update_field_with_all_params(self, async_client: AsyncAskt field_name="field_name", schema_name="schema_name", table_name="table_name", + identifiable_type="plain", visibility=True, ) assert_matches_type(object, datasource, path=["response"]) diff --git a/tests/api_resources/test_policies.py b/tests/api_resources/test_policies.py index 1832cc19..1c03eafa 100644 --- a/tests/api_resources/test_policies.py +++ b/tests/api_resources/test_policies.py @@ -229,7 +229,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None: policy = client.policies.list( name="name", page=1, - policy_ids=["string"], + policy_ids=["string", "string"], size=1, ) assert_matches_type(SyncPage[Policy], policy, path=["response"]) @@ -507,7 +507,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> policy = await async_client.policies.list( name="name", page=1, - policy_ids=["string"], + policy_ids=["string", "string"], size=1, ) assert_matches_type(AsyncPage[Policy], policy, path=["response"]) diff --git a/tests/api_resources/test_roles.py b/tests/api_resources/test_roles.py index b1105c52..8f83b821 100644 --- a/tests/api_resources/test_roles.py +++ b/tests/api_resources/test_roles.py @@ -155,7 +155,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None: role = client.roles.list( name="name", page=1, - role_ids=["string"], + role_ids=["string", "string"], size=1, ) assert_matches_type(SyncPage[Role], role, path=["response"]) @@ -268,7 +268,7 @@ def test_method_get_variables_with_all_params(self, client: Asktable) -> None: role = client.roles.get_variables( role_id="role_id", bot_id="bot_id", - datasource_ids=["string"], + datasource_ids=["string", "string"], ) assert_matches_type(object, role, path=["response"]) @@ -441,7 +441,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> role = await async_client.roles.list( name="name", page=1, - role_ids=["string"], + role_ids=["string", "string"], size=1, ) assert_matches_type(AsyncPage[Role], role, path=["response"]) @@ -554,7 +554,7 @@ async def test_method_get_variables_with_all_params(self, async_client: AsyncAsk role = await async_client.roles.get_variables( role_id="role_id", bot_id="bot_id", - datasource_ids=["string"], + datasource_ids=["string", "string"], ) assert_matches_type(object, role, path=["response"]) diff --git a/tests/test_client.py b/tests/test_client.py index 1efc0ea1..0b8079fb 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1597,7 +1597,7 @@ def test_get_platform(self) -> None: import threading from asktable._utils import asyncify - from asktable._base_client import get_platform + from asktable._base_client import get_platform async def test_main() -> None: result = await asyncify(get_platform)() diff --git a/tests/test_transform.py b/tests/test_transform.py index 581d749f..a8a384a5 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -432,3 +432,15 @@ async def test_base64_file_input(use_async: bool) -> None: assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == { "foo": "SGVsbG8sIHdvcmxkIQ==" } # type: ignore[comparison-overlap] + + +@parametrize +@pytest.mark.asyncio +async def test_transform_skipping(use_async: bool) -> None: + # lists of ints are left as-is + data = [1, 2, 3] + assert await transform(data, List[int], use_async) is data + + # iterables of ints are converted to a list + data = iter([1, 2, 3]) + assert await transform(data, Iterable[int], use_async) == [1, 2, 3]