Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.3.0"
".": "4.4.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-b2fe5c35562a5dafc33b2b5441a9e199668a03c7497b6d6350a2d25332dfecb0.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f081d80ec1b3a4951cccc2a085d46405da9aea9da7295cc264e834ada84127eb.yml
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.4.0 (2025-01-15)

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

### Features

* **api:** api update ([#129](https://github.com/DataMini/asktable-python/issues/129)) ([005b72f](https://github.com/DataMini/asktable-python/commit/005b72fb886bbabb2c5e09a04a029bc127587414))

## 4.3.0 (2025-01-11)

Full Changelog: [v4.2.0...v4.3.0](https://github.com/DataMini/asktable-python/compare/v4.2.0...v4.3.0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "asktable"
version = "4.3.0"
version = "4.4.0"
description = "The official Python library for the asktable API"
dynamic = ["readme"]
license = "Apache-2.0"
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__ = "4.3.0" # x-release-please-version
__version__ = "4.4.0" # x-release-please-version
51 changes: 35 additions & 16 deletions src/asktable/types/answer_response.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing import List, Optional
from datetime import datetime

from .._models import BaseModel

__all__ = ["AnswerResponse"]
__all__ = ["AnswerResponse", "Answer", "AnswerAttachment", "Request"]


class AnswerResponse(BaseModel):
id: str
class AnswerAttachment(BaseModel):
info: object

answer: Optional[object] = None
type: str
"""The type of the attachment"""

created_at: datetime

datasource_id: str
"""数据源 ID"""
class Answer(BaseModel):
text: str

duration: int
attachments: Optional[List[AnswerAttachment]] = None

modified_at: datetime

project_id: str
class Request(BaseModel):
datasource_id: str
"""数据源 ID"""

question: str

status: str

err_msg: Optional[str] = None
"""错误信息"""
"""查询语句"""

max_rows: Optional[int] = None
"""最大返回行数,默认为 0,即不限制返回行数"""
Expand All @@ -45,3 +42,25 @@ class AnswerResponse(BaseModel):

with_json: Optional[bool] = None
"""是否同时将数据,作为 json 格式的附件一起返回"""


class AnswerResponse(BaseModel):
id: str

answer: Optional[Answer] = None

created_at: datetime

duration: int

modified_at: datetime

project_id: str

request: Request

status: str

err_msg: Optional[str] = None

trace_id: Optional[str] = None
44 changes: 27 additions & 17 deletions src/asktable/types/query_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,21 @@

from .._models import BaseModel

__all__ = ["QueryResponse"]
__all__ = ["QueryResponse", "Query", "Request"]


class QueryResponse(BaseModel):
id: str
class Query(BaseModel):
sql: str
"""SQL 语句"""

created_at: datetime

class Request(BaseModel):
datasource_id: str
"""数据源 ID"""

duration: Optional[int] = None

modified_at: datetime

project_id: str

query: Optional[object] = None

question: str
"""查询语句"""

status: str

err_msg: Optional[str] = None
"""错误信息"""

role_id: Optional[str] = None
"""
角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
Expand All @@ -40,3 +28,25 @@ class QueryResponse(BaseModel):

role_variables: Optional[object] = None
"""在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""


class QueryResponse(BaseModel):
id: str

created_at: datetime

duration: int

modified_at: datetime

project_id: str

query: Optional[Query] = None

request: Request

status: str

err_msg: Optional[str] = None

trace_id: Optional[str] = None
16 changes: 8 additions & 8 deletions tests/api_resources/test_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class TestAnswers:
def test_method_create(self, client: Asktable) -> None:
answer = client.answers.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)
assert_matches_type(AnswerResponse, answer, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
answer = client.answers.create(
datasource_id="datasource_id",
question="xxx",
question="question",
max_rows=0,
role_id="role_id",
role_variables={},
Expand All @@ -42,7 +42,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
def test_raw_response_create(self, client: Asktable) -> None:
response = client.answers.with_raw_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)

assert response.is_closed is True
Expand All @@ -54,7 +54,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
def test_streaming_response_create(self, client: Asktable) -> None:
with client.answers.with_streaming_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down Expand Up @@ -106,15 +106,15 @@ class TestAsyncAnswers:
async def test_method_create(self, async_client: AsyncAsktable) -> None:
answer = await async_client.answers.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)
assert_matches_type(AnswerResponse, answer, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
answer = await async_client.answers.create(
datasource_id="datasource_id",
question="xxx",
question="question",
max_rows=0,
role_id="role_id",
role_variables={},
Expand All @@ -126,7 +126,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
response = await async_client.answers.with_raw_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)

assert response.is_closed is True
Expand All @@ -138,7 +138,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.answers.with_streaming_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down
16 changes: 8 additions & 8 deletions tests/api_resources/test_sqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class TestSqls:
def test_method_create(self, client: Asktable) -> None:
sql = client.sqls.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)
assert_matches_type(QueryResponse, sql, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
sql = client.sqls.create(
datasource_id="datasource_id",
question="xxx",
question="question",
role_id="role_id",
role_variables={},
)
Expand All @@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
def test_raw_response_create(self, client: Asktable) -> None:
response = client.sqls.with_raw_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)

assert response.is_closed is True
Expand All @@ -52,7 +52,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
def test_streaming_response_create(self, client: Asktable) -> None:
with client.sqls.with_streaming_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down Expand Up @@ -104,15 +104,15 @@ class TestAsyncSqls:
async def test_method_create(self, async_client: AsyncAsktable) -> None:
sql = await async_client.sqls.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)
assert_matches_type(QueryResponse, sql, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
sql = await async_client.sqls.create(
datasource_id="datasource_id",
question="xxx",
question="question",
role_id="role_id",
role_variables={},
)
Expand All @@ -122,7 +122,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
response = await async_client.sqls.with_raw_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
)

assert response.is_closed is True
Expand All @@ -134,7 +134,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.sqls.with_streaming_response.create(
datasource_id="datasource_id",
question="xxx",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down
Loading