From a056894aba1cfda91e7ea07b16b40c6e74566b5a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 10:02:46 +0000 Subject: [PATCH] feat(api): manual updates --- .stats.yml | 2 +- api.md | 34 +++- src/asktable/_client.py | 18 ++ src/asktable/resources/__init__.py | 28 +++ src/asktable/resources/chats/chats.py | 105 ++++++++++- src/asktable/resources/dataframes.py | 163 ++++++++++++++++++ src/asktable/resources/files.py | 162 +++++++++++++++++ src/asktable/types/__init__.py | 3 + .../types/chat_post_message_params.py | 11 ++ .../types/chat_post_message_response.py | 12 ++ .../types/dataframe_retrieve_response.py | 43 +++++ tests/api_resources/test_chats.py | 90 +++++++++- tests/api_resources/test_dataframes.py | 98 +++++++++++ tests/api_resources/test_files.py | 97 +++++++++++ 14 files changed, 861 insertions(+), 5 deletions(-) create mode 100644 src/asktable/resources/dataframes.py create mode 100644 src/asktable/resources/files.py create mode 100644 src/asktable/types/chat_post_message_params.py create mode 100644 src/asktable/types/chat_post_message_response.py create mode 100644 src/asktable/types/dataframe_retrieve_response.py create mode 100644 tests/api_resources/test_dataframes.py create mode 100644 tests/api_resources/test_files.py diff --git a/.stats.yml b/.stats.yml index ce6172aa..751b9da1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 91 +configured_endpoints: 94 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-2d9923ffe6d2d59041bac841db518829933a84e3251a372c9ad2306473fd7488.yml diff --git a/api.md b/api.md index 40b6f666..3c766c34 100644 --- a/api.md +++ b/api.md @@ -103,7 +103,14 @@ Methods: Types: ```python -from asktable.types import AIMessage, Chat, ToolMessage, UserMessage, ChatRetrieveResponse +from asktable.types import ( + AIMessage, + Chat, + ToolMessage, + UserMessage, + ChatRetrieveResponse, + ChatPostMessageResponse, +) ``` Methods: @@ -112,6 +119,7 @@ Methods: - client.chats.retrieve(chat_id) -> ChatRetrieveResponse - client.chats.list(\*\*params) -> SyncPage[Chat] - client.chats.delete(chat_id) -> None +- client.chats.post_message(chat_id, \*\*params) -> ChatPostMessageResponse ## Messages @@ -381,3 +389,27 @@ from asktable.types import ScoreCreateResponse Methods: - client.scores.create(\*\*params) -> ScoreCreateResponse + +# Files + +Types: + +```python +from asktable.types import FileRetrieveResponse +``` + +Methods: + +- client.files.retrieve(file_id) -> object + +# Dataframes + +Types: + +```python +from asktable.types import DataframeRetrieveResponse +``` + +Methods: + +- client.dataframes.retrieve(dataframe_id) -> DataframeRetrieveResponse diff --git a/src/asktable/_client.py b/src/asktable/_client.py index 51d4026a..1569ca30 100644 --- a/src/asktable/_client.py +++ b/src/asktable/_client.py @@ -28,6 +28,7 @@ auth, bots, sqls, + files, roles, caches, scores, @@ -35,6 +36,7 @@ project, policies, trainings, + dataframes, integration, preferences, securetunnels, @@ -83,6 +85,8 @@ class Asktable(SyncAPIClient): trainings: trainings.TrainingsResource project: project.ProjectResource scores: scores.ScoresResource + files: files.FilesResource + dataframes: dataframes.DataframesResource with_raw_response: AsktableWithRawResponse with_streaming_response: AsktableWithStreamedResponse @@ -158,6 +162,8 @@ def __init__( self.trainings = trainings.TrainingsResource(self) self.project = project.ProjectResource(self) self.scores = scores.ScoresResource(self) + self.files = files.FilesResource(self) + self.dataframes = dataframes.DataframesResource(self) self.with_raw_response = AsktableWithRawResponse(self) self.with_streaming_response = AsktableWithStreamedResponse(self) @@ -285,6 +291,8 @@ class AsyncAsktable(AsyncAPIClient): trainings: trainings.AsyncTrainingsResource project: project.AsyncProjectResource scores: scores.AsyncScoresResource + files: files.AsyncFilesResource + dataframes: dataframes.AsyncDataframesResource with_raw_response: AsyncAsktableWithRawResponse with_streaming_response: AsyncAsktableWithStreamedResponse @@ -360,6 +368,8 @@ def __init__( self.trainings = trainings.AsyncTrainingsResource(self) self.project = project.AsyncProjectResource(self) self.scores = scores.AsyncScoresResource(self) + self.files = files.AsyncFilesResource(self) + self.dataframes = dataframes.AsyncDataframesResource(self) self.with_raw_response = AsyncAsktableWithRawResponse(self) self.with_streaming_response = AsyncAsktableWithStreamedResponse(self) @@ -488,6 +498,8 @@ def __init__(self, client: Asktable) -> None: self.trainings = trainings.TrainingsResourceWithRawResponse(client.trainings) self.project = project.ProjectResourceWithRawResponse(client.project) self.scores = scores.ScoresResourceWithRawResponse(client.scores) + self.files = files.FilesResourceWithRawResponse(client.files) + self.dataframes = dataframes.DataframesResourceWithRawResponse(client.dataframes) class AsyncAsktableWithRawResponse: @@ -512,6 +524,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.trainings = trainings.AsyncTrainingsResourceWithRawResponse(client.trainings) self.project = project.AsyncProjectResourceWithRawResponse(client.project) self.scores = scores.AsyncScoresResourceWithRawResponse(client.scores) + self.files = files.AsyncFilesResourceWithRawResponse(client.files) + self.dataframes = dataframes.AsyncDataframesResourceWithRawResponse(client.dataframes) class AsktableWithStreamedResponse: @@ -536,6 +550,8 @@ def __init__(self, client: Asktable) -> None: self.trainings = trainings.TrainingsResourceWithStreamingResponse(client.trainings) self.project = project.ProjectResourceWithStreamingResponse(client.project) self.scores = scores.ScoresResourceWithStreamingResponse(client.scores) + self.files = files.FilesResourceWithStreamingResponse(client.files) + self.dataframes = dataframes.DataframesResourceWithStreamingResponse(client.dataframes) class AsyncAsktableWithStreamedResponse: @@ -560,6 +576,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.trainings = trainings.AsyncTrainingsResourceWithStreamingResponse(client.trainings) self.project = project.AsyncProjectResourceWithStreamingResponse(client.project) self.scores = scores.AsyncScoresResourceWithStreamingResponse(client.scores) + self.files = files.AsyncFilesResourceWithStreamingResponse(client.files) + self.dataframes = dataframes.AsyncDataframesResourceWithStreamingResponse(client.dataframes) Client = Asktable diff --git a/src/asktable/resources/__init__.py b/src/asktable/resources/__init__.py index 44456326..45e0bfb5 100644 --- a/src/asktable/resources/__init__.py +++ b/src/asktable/resources/__init__.py @@ -40,6 +40,14 @@ ChatsResourceWithStreamingResponse, AsyncChatsResourceWithStreamingResponse, ) +from .files import ( + FilesResource, + AsyncFilesResource, + FilesResourceWithRawResponse, + AsyncFilesResourceWithRawResponse, + FilesResourceWithStreamingResponse, + AsyncFilesResourceWithStreamingResponse, +) from .roles import ( RolesResource, AsyncRolesResource, @@ -104,6 +112,14 @@ TrainingsResourceWithStreamingResponse, AsyncTrainingsResourceWithStreamingResponse, ) +from .dataframes import ( + DataframesResource, + AsyncDataframesResource, + DataframesResourceWithRawResponse, + AsyncDataframesResourceWithRawResponse, + DataframesResourceWithStreamingResponse, + AsyncDataframesResourceWithStreamingResponse, +) from .datasources import ( DatasourcesResource, AsyncDatasourcesResource, @@ -254,4 +270,16 @@ "AsyncScoresResourceWithRawResponse", "ScoresResourceWithStreamingResponse", "AsyncScoresResourceWithStreamingResponse", + "FilesResource", + "AsyncFilesResource", + "FilesResourceWithRawResponse", + "AsyncFilesResourceWithRawResponse", + "FilesResourceWithStreamingResponse", + "AsyncFilesResourceWithStreamingResponse", + "DataframesResource", + "AsyncDataframesResource", + "DataframesResourceWithRawResponse", + "AsyncDataframesResourceWithRawResponse", + "DataframesResourceWithStreamingResponse", + "AsyncDataframesResourceWithStreamingResponse", ] diff --git a/src/asktable/resources/chats/chats.py b/src/asktable/resources/chats/chats.py index a20f13ad..d974eeb4 100644 --- a/src/asktable/resources/chats/chats.py +++ b/src/asktable/resources/chats/chats.py @@ -2,11 +2,11 @@ from __future__ import annotations -from typing import Dict, Union, Optional +from typing import Any, Dict, Union, Optional, cast import httpx -from ...types import chat_list_params, chat_create_params +from ...types import chat_list_params, chat_create_params, chat_post_message_params from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from ..._utils import ( maybe_transform, @@ -32,6 +32,7 @@ from ...types.chat import Chat from ..._base_client import AsyncPaginator, make_request_options from ...types.chat_retrieve_response import ChatRetrieveResponse +from ...types.chat_post_message_response import ChatPostMessageResponse __all__ = ["ChatsResource", "AsyncChatsResource"] @@ -231,6 +232,49 @@ def delete( cast_to=NoneType, ) + def post_message( + self, + chat_id: str, + *, + question: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ChatPostMessageResponse: + """ + 发消息 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not chat_id: + raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") + return cast( + ChatPostMessageResponse, + self._post( + f"/chats/{chat_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"question": question}, chat_post_message_params.ChatPostMessageParams), + ), + cast_to=cast( + Any, ChatPostMessageResponse + ), # Union types cannot be passed in as arguments in the type system + ), + ) + class AsyncChatsResource(AsyncAPIResource): @cached_property @@ -427,6 +471,51 @@ async def delete( cast_to=NoneType, ) + async def post_message( + self, + chat_id: str, + *, + question: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ChatPostMessageResponse: + """ + 发消息 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not chat_id: + raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") + return cast( + ChatPostMessageResponse, + await self._post( + f"/chats/{chat_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"question": question}, chat_post_message_params.ChatPostMessageParams + ), + ), + cast_to=cast( + Any, ChatPostMessageResponse + ), # Union types cannot be passed in as arguments in the type system + ), + ) + class ChatsResourceWithRawResponse: def __init__(self, chats: ChatsResource) -> None: @@ -444,6 +533,9 @@ def __init__(self, chats: ChatsResource) -> None: self.delete = to_raw_response_wrapper( chats.delete, ) + self.post_message = to_raw_response_wrapper( + chats.post_message, + ) @cached_property def messages(self) -> MessagesResourceWithRawResponse: @@ -466,6 +558,9 @@ def __init__(self, chats: AsyncChatsResource) -> None: self.delete = async_to_raw_response_wrapper( chats.delete, ) + self.post_message = async_to_raw_response_wrapper( + chats.post_message, + ) @cached_property def messages(self) -> AsyncMessagesResourceWithRawResponse: @@ -488,6 +583,9 @@ def __init__(self, chats: ChatsResource) -> None: self.delete = to_streamed_response_wrapper( chats.delete, ) + self.post_message = to_streamed_response_wrapper( + chats.post_message, + ) @cached_property def messages(self) -> MessagesResourceWithStreamingResponse: @@ -510,6 +608,9 @@ def __init__(self, chats: AsyncChatsResource) -> None: self.delete = async_to_streamed_response_wrapper( chats.delete, ) + self.post_message = async_to_streamed_response_wrapper( + chats.post_message, + ) @cached_property def messages(self) -> AsyncMessagesResourceWithStreamingResponse: diff --git a/src/asktable/resources/dataframes.py b/src/asktable/resources/dataframes.py new file mode 100644 index 00000000..8f0953c3 --- /dev/null +++ b/src/asktable/resources/dataframes.py @@ -0,0 +1,163 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.dataframe_retrieve_response import DataframeRetrieveResponse + +__all__ = ["DataframesResource", "AsyncDataframesResource"] + + +class DataframesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DataframesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return DataframesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DataframesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return DataframesResourceWithStreamingResponse(self) + + def retrieve( + self, + dataframe_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DataframeRetrieveResponse: + """ + Get Dataframe + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataframe_id: + raise ValueError(f"Expected a non-empty value for `dataframe_id` but received {dataframe_id!r}") + return self._get( + f"/dataframes/{dataframe_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DataframeRetrieveResponse, + ) + + +class AsyncDataframesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDataframesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return AsyncDataframesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDataframesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return AsyncDataframesResourceWithStreamingResponse(self) + + async def retrieve( + self, + dataframe_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DataframeRetrieveResponse: + """ + Get Dataframe + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not dataframe_id: + raise ValueError(f"Expected a non-empty value for `dataframe_id` but received {dataframe_id!r}") + return await self._get( + f"/dataframes/{dataframe_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DataframeRetrieveResponse, + ) + + +class DataframesResourceWithRawResponse: + def __init__(self, dataframes: DataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = to_raw_response_wrapper( + dataframes.retrieve, + ) + + +class AsyncDataframesResourceWithRawResponse: + def __init__(self, dataframes: AsyncDataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = async_to_raw_response_wrapper( + dataframes.retrieve, + ) + + +class DataframesResourceWithStreamingResponse: + def __init__(self, dataframes: DataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = to_streamed_response_wrapper( + dataframes.retrieve, + ) + + +class AsyncDataframesResourceWithStreamingResponse: + def __init__(self, dataframes: AsyncDataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = async_to_streamed_response_wrapper( + dataframes.retrieve, + ) diff --git a/src/asktable/resources/files.py b/src/asktable/resources/files.py new file mode 100644 index 00000000..b3a6261c --- /dev/null +++ b/src/asktable/resources/files.py @@ -0,0 +1,162 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options + +__all__ = ["FilesResource", "AsyncFilesResource"] + + +class FilesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return FilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return FilesResourceWithStreamingResponse(self) + + def retrieve( + self, + file_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + 获取文件 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + return self._get( + f"/files/{file_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncFilesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return AsyncFilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return AsyncFilesResourceWithStreamingResponse(self) + + async def retrieve( + self, + file_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + 获取文件 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + return await self._get( + f"/files/{file_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class FilesResourceWithRawResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.retrieve = to_raw_response_wrapper( + files.retrieve, + ) + + +class AsyncFilesResourceWithRawResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.retrieve = async_to_raw_response_wrapper( + files.retrieve, + ) + + +class FilesResourceWithStreamingResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.retrieve = to_streamed_response_wrapper( + files.retrieve, + ) + + +class AsyncFilesResourceWithStreamingResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.retrieve = async_to_streamed_response_wrapper( + files.retrieve, + ) diff --git a/src/asktable/types/__init__.py b/src/asktable/types/__init__.py index 8cd2bd96..6b15da69 100644 --- a/src/asktable/types/__init__.py +++ b/src/asktable/types/__init__.py @@ -48,6 +48,7 @@ from .training_delete_params import TrainingDeleteParams as TrainingDeleteParams from .training_list_response import TrainingListResponse as TrainingListResponse from .auth_create_token_params import AuthCreateTokenParams as AuthCreateTokenParams +from .chat_post_message_params import ChatPostMessageParams as ChatPostMessageParams from .datasource_create_params import DatasourceCreateParams as DatasourceCreateParams from .datasource_update_params import DatasourceUpdateParams as DatasourceUpdateParams from .preference_create_params import PreferenceCreateParams as PreferenceCreateParams @@ -56,11 +57,13 @@ from .training_create_response import TrainingCreateResponse as TrainingCreateResponse from .role_get_polices_response import RoleGetPolicesResponse as RoleGetPolicesResponse from .role_get_variables_params import RoleGetVariablesParams as RoleGetVariablesParams +from .chat_post_message_response import ChatPostMessageResponse as ChatPostMessageResponse from .datasource_add_file_params import DatasourceAddFileParams as DatasourceAddFileParams from .preference_create_response import PreferenceCreateResponse as PreferenceCreateResponse from .preference_update_response import PreferenceUpdateResponse as PreferenceUpdateResponse from .securetunnel_create_params import SecuretunnelCreateParams as SecuretunnelCreateParams from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams +from .dataframe_retrieve_response import DataframeRetrieveResponse as DataframeRetrieveResponse from .datasource_retrieve_response import DatasourceRetrieveResponse as DatasourceRetrieveResponse from .preference_retrieve_response import PreferenceRetrieveResponse as PreferenceRetrieveResponse from .business_glossary_list_params import BusinessGlossaryListParams as BusinessGlossaryListParams diff --git a/src/asktable/types/chat_post_message_params.py b/src/asktable/types/chat_post_message_params.py new file mode 100644 index 00000000..31a7464d --- /dev/null +++ b/src/asktable/types/chat_post_message_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ChatPostMessageParams"] + + +class ChatPostMessageParams(TypedDict, total=False): + question: Required[str] diff --git a/src/asktable/types/chat_post_message_response.py b/src/asktable/types/chat_post_message_response.py new file mode 100644 index 00000000..fb2c48a6 --- /dev/null +++ b/src/asktable/types/chat_post_message_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import TypeAlias + +from .ai_message import AIMessage +from .tool_message import ToolMessage +from .user_message import UserMessage + +__all__ = ["ChatPostMessageResponse"] + +ChatPostMessageResponse: TypeAlias = Union[UserMessage, AIMessage, ToolMessage] diff --git a/src/asktable/types/dataframe_retrieve_response.py b/src/asktable/types/dataframe_retrieve_response.py new file mode 100644 index 00000000..75cdbde6 --- /dev/null +++ b/src/asktable/types/dataframe_retrieve_response.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from datetime import datetime + +from .._models import BaseModel + +__all__ = ["DataframeRetrieveResponse"] + + +class DataframeRetrieveResponse(BaseModel): + id: str + """ID""" + + chart_options: object + """图表选项""" + + content: List[object] + """内容""" + + created_at: datetime + """创建时间""" + + header: List[object] + """表头""" + + modified_at: datetime + """更新时间""" + + msg_id: str + """消息 ID""" + + project_id: str + """项目 ID""" + + row_count: int + """行数""" + + sql: str + """SQL""" + + title: str + """标题""" diff --git a/tests/api_resources/test_chats.py b/tests/api_resources/test_chats.py index 5a84e9da..662e2035 100644 --- a/tests/api_resources/test_chats.py +++ b/tests/api_resources/test_chats.py @@ -9,7 +9,11 @@ from asktable import Asktable, AsyncAsktable from tests.utils import assert_matches_type -from asktable.types import Chat, ChatRetrieveResponse +from asktable.types import ( + Chat, + ChatRetrieveResponse, + ChatPostMessageResponse, +) from asktable.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -167,6 +171,48 @@ def test_path_params_delete(self, client: Asktable) -> None: "", ) + @parametrize + def test_method_post_message(self, client: Asktable) -> None: + chat = client.chats.post_message( + chat_id="chat_id", + question="question", + ) + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + @parametrize + def test_raw_response_post_message(self, client: Asktable) -> None: + response = client.chats.with_raw_response.post_message( + chat_id="chat_id", + question="question", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + chat = response.parse() + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + @parametrize + def test_streaming_response_post_message(self, client: Asktable) -> None: + with client.chats.with_streaming_response.post_message( + chat_id="chat_id", + question="question", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + chat = response.parse() + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_post_message(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"): + client.chats.with_raw_response.post_message( + chat_id="", + question="question", + ) + class TestAsyncChats: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -319,3 +365,45 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None: await async_client.chats.with_raw_response.delete( "", ) + + @parametrize + async def test_method_post_message(self, async_client: AsyncAsktable) -> None: + chat = await async_client.chats.post_message( + chat_id="chat_id", + question="question", + ) + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + @parametrize + async def test_raw_response_post_message(self, async_client: AsyncAsktable) -> None: + response = await async_client.chats.with_raw_response.post_message( + chat_id="chat_id", + question="question", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + chat = await response.parse() + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + @parametrize + async def test_streaming_response_post_message(self, async_client: AsyncAsktable) -> None: + async with async_client.chats.with_streaming_response.post_message( + chat_id="chat_id", + question="question", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + chat = await response.parse() + assert_matches_type(ChatPostMessageResponse, chat, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_post_message(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"): + await async_client.chats.with_raw_response.post_message( + chat_id="", + question="question", + ) diff --git a/tests/api_resources/test_dataframes.py b/tests/api_resources/test_dataframes.py new file mode 100644 index 00000000..8e71063a --- /dev/null +++ b/tests/api_resources/test_dataframes.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from asktable import Asktable, AsyncAsktable +from tests.utils import assert_matches_type +from asktable.types import DataframeRetrieveResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDataframes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: Asktable) -> None: + dataframe = client.dataframes.retrieve( + "dataframe_id", + ) + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: Asktable) -> None: + response = client.dataframes.with_raw_response.retrieve( + "dataframe_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataframe = response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: Asktable) -> None: + with client.dataframes.with_streaming_response.retrieve( + "dataframe_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataframe = response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataframe_id` but received ''"): + client.dataframes.with_raw_response.retrieve( + "", + ) + + +class TestAsyncDataframes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncAsktable) -> None: + dataframe = await async_client.dataframes.retrieve( + "dataframe_id", + ) + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None: + response = await async_client.dataframes.with_raw_response.retrieve( + "dataframe_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataframe = await response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None: + async with async_client.dataframes.with_streaming_response.retrieve( + "dataframe_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataframe = await response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataframe_id` but received ''"): + await async_client.dataframes.with_raw_response.retrieve( + "", + ) diff --git a/tests/api_resources/test_files.py b/tests/api_resources/test_files.py new file mode 100644 index 00000000..6b979645 --- /dev/null +++ b/tests/api_resources/test_files.py @@ -0,0 +1,97 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from asktable import Asktable, AsyncAsktable +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFiles: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: Asktable) -> None: + file = client.files.retrieve( + "file_id", + ) + assert_matches_type(object, file, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: Asktable) -> None: + response = client.files.with_raw_response.retrieve( + "file_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(object, file, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: Asktable) -> None: + with client.files.with_streaming_response.retrieve( + "file_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(object, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.retrieve( + "", + ) + + +class TestAsyncFiles: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncAsktable) -> None: + file = await async_client.files.retrieve( + "file_id", + ) + assert_matches_type(object, file, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None: + response = await async_client.files.with_raw_response.retrieve( + "file_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(object, file, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None: + async with async_client.files.with_streaming_response.retrieve( + "file_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(object, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await async_client.files.with_raw_response.retrieve( + "", + )