tinyfish 0.11.0__tar.gz → 0.11.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinyfish-0.11.0 → tinyfish-0.11.1}/CHANGELOG.md +7 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/PKG-INFO +6 -6
- {tinyfish-0.11.0 → tinyfish-0.11.1}/README.md +5 -5
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/pagination-guide.md +2 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/pyproject.toml +1 -1
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/_base.py +13 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/async_.py +14 -24
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/sync.py +14 -24
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/datasets/__init__.py +6 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/datasets/types.py +13 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/research/__init__.py +0 -66
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/runs/types.py +4 -1
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_datasets.py +29 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_errors.py +46 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_research.py +34 -7
- {tinyfish-0.11.0 → tinyfish-0.11.1}/.gitignore +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/.pre-commit-config.yaml +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/AGENTS.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/CLAUDE.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/RELEASE.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/exceptions-and-errors-guide.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/internal/api-integration-header.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/internal/exceptions-and-errors-guide.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/internal/publishing-private-guide.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/proxy-and-browser-profiles.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/docs/streaming-guide.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/client/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/exceptions.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/resource.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/_utils/sse_parser.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/agent/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/agent/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/browser/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/browser/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/client.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/fetch/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/fetch/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/monitors/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/monitors/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/profiles/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/profiles/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/py.typed +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/research/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/runs/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/search/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/search/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/vault/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/vault/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/wallet/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/src/tinyfish/wallet/types.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/__init__.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/conftest.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_agent.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_browser.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_client.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_datasets_events.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_fetch.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_monitors.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_profiles.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_research_events.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_runs.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_search.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_sse_parser.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_vault.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/test_wallet.py +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/tests/testing_guide.md +0 -0
- {tinyfish-0.11.0 → tinyfish-0.11.1}/uv.lock +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.11.1](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.11.0...sdk-py/v0.11.1) (2026-12-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **datasets:** lower the default rows from 100 to 40 (PROD-5182) ([#7587](https://github.com/tinyfish-io/ux-labs/issues/7587)) ([a27985f](https://github.com/tinyfish-io/ux-labs/commit/a27985f430267e07ea30835086d064aded4d4f64))
|
|
9
|
+
|
|
3
10
|
## [0.11.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.10.0...sdk-py/v0.11.0) (2026-10-23)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tinyfish
|
|
3
|
-
Version: 0.11.
|
|
3
|
+
Version: 0.11.1
|
|
4
4
|
Summary: Official Python SDK for the TinyFish API
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: httpx>=0.27.0
|
|
@@ -305,7 +305,7 @@ if response.pagination.has_more:
|
|
|
305
305
|
| Field | Type | Description |
|
|
306
306
|
|-------|------|-------------|
|
|
307
307
|
| `data` | `list[Run]` | List of runs |
|
|
308
|
-
| `pagination.total` | `int` | Total runs matching filters |
|
|
308
|
+
| `pagination.total` | `int` | Total runs matching filters; for a team's workflow key, it stops at 1,000 |
|
|
309
309
|
| `pagination.has_more` | `bool` | Whether more pages exist |
|
|
310
310
|
| `pagination.next_cursor` | `str \| None` | Pass to `cursor=` for the next page |
|
|
311
311
|
|
|
@@ -401,7 +401,7 @@ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
|
|
|
401
401
|
|
|
402
402
|
### `research` — deep research
|
|
403
403
|
|
|
404
|
-
Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `
|
|
404
|
+
Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Each completed run is billed (`deep` $2, `max` $3). Starts are never retried, since a retry could start (and bill) a second run. See [Research limits](https://docs.tinyfish.ai/research-api/reference#limits).
|
|
405
405
|
|
|
406
406
|
```python
|
|
407
407
|
run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
|
|
@@ -434,7 +434,7 @@ with client.research.events(run_id) as stream: # `async with` / `async for` on
|
|
|
434
434
|
|
|
435
435
|
### `datasets` — build a dataset from a prompt
|
|
436
436
|
|
|
437
|
-
`create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default
|
|
437
|
+
`create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default 40, at most 250). `events()` follows the run; `rows()` reads the rows. `create()` and `populate()` are billed and never retried, since a retry could start a second run.
|
|
438
438
|
|
|
439
439
|
```python
|
|
440
440
|
dataset = client.datasets.create(prompt="Specialty coffee shops in Oakland with their website and rating", target_rows=50)
|
|
@@ -586,7 +586,7 @@ client = TinyFish(
|
|
|
586
586
|
)
|
|
587
587
|
```
|
|
588
588
|
|
|
589
|
-
The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait).
|
|
589
|
+
The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait). Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) fail immediately.
|
|
590
590
|
|
|
591
591
|
### Browser profiles
|
|
592
592
|
|
|
@@ -679,7 +679,7 @@ except SDKError:
|
|
|
679
679
|
print("Something else went wrong")
|
|
680
680
|
```
|
|
681
681
|
|
|
682
|
-
The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff.
|
|
682
|
+
The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) and non-retryable errors (`401`, `400`, `404`) raise immediately.
|
|
683
683
|
|
|
684
684
|
For the full exception hierarchy and internal architecture, see [docs/internal/exceptions-and-errors-guide.md](docs/internal/exceptions-and-errors-guide.md).
|
|
685
685
|
|
|
@@ -295,7 +295,7 @@ if response.pagination.has_more:
|
|
|
295
295
|
| Field | Type | Description |
|
|
296
296
|
|-------|------|-------------|
|
|
297
297
|
| `data` | `list[Run]` | List of runs |
|
|
298
|
-
| `pagination.total` | `int` | Total runs matching filters |
|
|
298
|
+
| `pagination.total` | `int` | Total runs matching filters; for a team's workflow key, it stops at 1,000 |
|
|
299
299
|
| `pagination.has_more` | `bool` | Whether more pages exist |
|
|
300
300
|
| `pagination.next_cursor` | `str \| None` | Pass to `cursor=` for the next page |
|
|
301
301
|
|
|
@@ -391,7 +391,7 @@ client.monitors.cancel(monitor_id) # deletes the Monitor and its schedule
|
|
|
391
391
|
|
|
392
392
|
### `research` — deep research
|
|
393
393
|
|
|
394
|
-
Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `
|
|
394
|
+
Same shape as `agent`, with keyword-only arguments: `run()` blocks, `queue()` returns at once, `stream()` yields events. Options: `output_language`, `domain_filter`, `prior_run_id` or `session_id`. `mode` is `"deep"` (default, 5–20 min) or `"max"` (5–45 min). Each completed run is billed (`deep` $2, `max` $3). Starts are never retried, since a retry could start (and bill) a second run. See [Research limits](https://docs.tinyfish.ai/research-api/reference#limits).
|
|
395
395
|
|
|
396
396
|
```python
|
|
397
397
|
run = client.research.run(query="Compare long-duration energy storage approaches", mode="deep")
|
|
@@ -424,7 +424,7 @@ with client.research.events(run_id) as stream: # `async with` / `async for` on
|
|
|
424
424
|
|
|
425
425
|
### `datasets` — build a dataset from a prompt
|
|
426
426
|
|
|
427
|
-
`create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default
|
|
427
|
+
`create()` plans a schema from a prompt (or takes a `spec` from `plan()`), creates the dataset and starts filling it to `target_rows` (default 40, at most 250). `events()` follows the run; `rows()` reads the rows. `create()` and `populate()` are billed and never retried, since a retry could start a second run.
|
|
428
428
|
|
|
429
429
|
```python
|
|
430
430
|
dataset = client.datasets.create(prompt="Specialty coffee shops in Oakland with their website and rating", target_rows=50)
|
|
@@ -576,7 +576,7 @@ client = TinyFish(
|
|
|
576
576
|
)
|
|
577
577
|
```
|
|
578
578
|
|
|
579
|
-
The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait).
|
|
579
|
+
The SDK retries `408`, `429`, and `5xx` errors automatically with exponential backoff (0.5s multiplier, max 8s wait). Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) fail immediately.
|
|
580
580
|
|
|
581
581
|
### Browser profiles
|
|
582
582
|
|
|
@@ -669,7 +669,7 @@ except SDKError:
|
|
|
669
669
|
print("Something else went wrong")
|
|
670
670
|
```
|
|
671
671
|
|
|
672
|
-
The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff.
|
|
672
|
+
The SDK automatically retries transient errors (`408`, `429`, `5xx`) up to `max_retries` times with exponential backoff. Daily allowance errors (`429` with `error.details.reason: "free_allowance_exhausted"`) and non-retryable errors (`401`, `400`, `404`) raise immediately.
|
|
673
673
|
|
|
674
674
|
For the full exception hierarchy and internal architecture, see [docs/internal/exceptions-and-errors-guide.md](docs/internal/exceptions-and-errors-guide.md).
|
|
675
675
|
|
|
@@ -95,6 +95,8 @@ print(response.pagination.has_more) # True if more pages exist
|
|
|
95
95
|
print(response.pagination.next_cursor) # Pass to cursor= for the next page
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
For a team's workflow key, `total` stops counting at 1,000, so a total of 1,000 means at least 1,000 runs. To read every run, keep paging while `has_more` is true.
|
|
99
|
+
|
|
98
100
|
### Full pagination loop
|
|
99
101
|
|
|
100
102
|
```python
|
|
@@ -34,6 +34,19 @@ _RETRY_MULTIPLIER: float = 0.5
|
|
|
34
34
|
_RETRY_MAX_WAIT: float = 8.0
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
def _should_retry(error: BaseException) -> bool:
|
|
38
|
+
if isinstance(error, RateLimitError) and error.response is not None:
|
|
39
|
+
try:
|
|
40
|
+
body = error.response.json()
|
|
41
|
+
api_error = body.get("error") if isinstance(body, dict) else None
|
|
42
|
+
details = api_error.get("details") if isinstance(api_error, dict) else None
|
|
43
|
+
if isinstance(details, dict) and details.get("reason") == "free_allowance_exhausted":
|
|
44
|
+
return False # Daily allowance cannot recover during short backoff.
|
|
45
|
+
except ValueError:
|
|
46
|
+
pass # Non-JSON 429 responses keep the ordinary retry policy.
|
|
47
|
+
return isinstance(error, (RequestTimeoutError, RateLimitError, InternalServerError, httpx.RequestError))
|
|
48
|
+
|
|
49
|
+
|
|
37
50
|
def _sanitize_client_header(value: str) -> str:
|
|
38
51
|
"""Non-printable chars raise in httpx; 128 is the server cap (client_name varchar(128))."""
|
|
39
52
|
return "".join(ch for ch in value if 32 <= ord(ch) <= 126).strip()[:128]
|
|
@@ -7,16 +7,20 @@ from typing import Any, Self, TypeVar
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
from pydantic import BaseModel
|
|
10
|
-
from tenacity import retry,
|
|
10
|
+
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
|
|
11
11
|
|
|
12
12
|
from ..exceptions import (
|
|
13
13
|
APIConnectionError,
|
|
14
14
|
APITimeoutError,
|
|
15
|
-
InternalServerError,
|
|
16
|
-
RateLimitError,
|
|
17
|
-
RequestTimeoutError,
|
|
18
15
|
)
|
|
19
|
-
from ._base import
|
|
16
|
+
from ._base import (
|
|
17
|
+
_DEFAULT_MAX_RETRIES,
|
|
18
|
+
_DEFAULT_TIMEOUT,
|
|
19
|
+
_RETRY_MAX_WAIT,
|
|
20
|
+
_RETRY_MULTIPLIER,
|
|
21
|
+
_BaseClient,
|
|
22
|
+
_should_retry,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
ResponseT = TypeVar("ResponseT", bound=BaseModel)
|
|
22
26
|
|
|
@@ -59,7 +63,7 @@ class BaseAsyncAPIClient(_BaseClient):
|
|
|
59
63
|
"""
|
|
60
64
|
Make async HTTP request with automatic retries.
|
|
61
65
|
|
|
62
|
-
Retryable errors: 408, 429, 5xx, and network errors.
|
|
66
|
+
Retryable errors: 408, transient 429, 5xx, and network errors.
|
|
63
67
|
Non-retryable errors (400, 401, 403, 404, …) propagate immediately.
|
|
64
68
|
|
|
65
69
|
Args:
|
|
@@ -76,20 +80,13 @@ class BaseAsyncAPIClient(_BaseClient):
|
|
|
76
80
|
json = self._inject_integration(path, json)
|
|
77
81
|
max_attempts = (self._max_retries if max_retries is None else max_retries) + 1
|
|
78
82
|
|
|
79
|
-
# Retryable: 408, 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
|
|
83
|
+
# Retryable: 408, transient 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
|
|
80
84
|
# Non-retryable status errors (400, 401, 403, 404, …) propagate immediately.
|
|
81
85
|
# After retries exhausted: httpx errors are wrapped into SDK types by the outer try/except.
|
|
82
86
|
@retry(
|
|
83
87
|
stop=stop_after_attempt(max_attempts),
|
|
84
88
|
wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
|
|
85
|
-
retry=
|
|
86
|
-
(
|
|
87
|
-
RequestTimeoutError,
|
|
88
|
-
RateLimitError,
|
|
89
|
-
InternalServerError,
|
|
90
|
-
httpx.RequestError, # covers TimeoutException and connection errors
|
|
91
|
-
)
|
|
92
|
-
),
|
|
89
|
+
retry=retry_if_exception(_should_retry),
|
|
93
90
|
reraise=True,
|
|
94
91
|
)
|
|
95
92
|
async def _execute() -> httpx.Response:
|
|
@@ -164,7 +161,7 @@ class BaseAsyncAPIClient(_BaseClient):
|
|
|
164
161
|
) -> AsyncGenerator[str, None]:
|
|
165
162
|
"""POST request that streams raw response lines (for SSE). Does not parse JSON.
|
|
166
163
|
|
|
167
|
-
Retries the initial connection on 429/5xx with exponential backoff,
|
|
164
|
+
Retries the initial connection on transient 429/5xx with exponential backoff,
|
|
168
165
|
matching the retry behaviour of ``_request()``. Once a 200 response
|
|
169
166
|
is received and streaming begins, no further retries are attempted.
|
|
170
167
|
"""
|
|
@@ -197,14 +194,7 @@ class BaseAsyncAPIClient(_BaseClient):
|
|
|
197
194
|
@retry(
|
|
198
195
|
stop=stop_after_attempt(max_attempts),
|
|
199
196
|
wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
|
|
200
|
-
retry=
|
|
201
|
-
(
|
|
202
|
-
RequestTimeoutError,
|
|
203
|
-
RateLimitError,
|
|
204
|
-
InternalServerError,
|
|
205
|
-
httpx.RequestError,
|
|
206
|
-
)
|
|
207
|
-
),
|
|
197
|
+
retry=retry_if_exception(_should_retry),
|
|
208
198
|
reraise=True,
|
|
209
199
|
)
|
|
210
200
|
async def _connect() -> httpx.Response:
|
|
@@ -7,16 +7,20 @@ from typing import Any, Self, TypeVar
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
from pydantic import BaseModel
|
|
10
|
-
from tenacity import retry,
|
|
10
|
+
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
|
|
11
11
|
|
|
12
12
|
from ..exceptions import (
|
|
13
13
|
APIConnectionError,
|
|
14
14
|
APITimeoutError,
|
|
15
|
-
InternalServerError,
|
|
16
|
-
RateLimitError,
|
|
17
|
-
RequestTimeoutError,
|
|
18
15
|
)
|
|
19
|
-
from ._base import
|
|
16
|
+
from ._base import (
|
|
17
|
+
_DEFAULT_MAX_RETRIES,
|
|
18
|
+
_DEFAULT_TIMEOUT,
|
|
19
|
+
_RETRY_MAX_WAIT,
|
|
20
|
+
_RETRY_MULTIPLIER,
|
|
21
|
+
_BaseClient,
|
|
22
|
+
_should_retry,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
ResponseT = TypeVar("ResponseT", bound=BaseModel)
|
|
22
26
|
|
|
@@ -59,7 +63,7 @@ class BaseSyncAPIClient(_BaseClient):
|
|
|
59
63
|
"""
|
|
60
64
|
Make HTTP request with automatic retries.
|
|
61
65
|
|
|
62
|
-
Retryable errors: 408, 429, 5xx, and network errors.
|
|
66
|
+
Retryable errors: 408, transient 429, 5xx, and network errors.
|
|
63
67
|
Non-retryable errors (400, 401, 403, 404, …) propagate immediately.
|
|
64
68
|
|
|
65
69
|
Args:
|
|
@@ -76,20 +80,13 @@ class BaseSyncAPIClient(_BaseClient):
|
|
|
76
80
|
json = self._inject_integration(path, json)
|
|
77
81
|
max_attempts = (self._max_retries if max_retries is None else max_retries) + 1
|
|
78
82
|
|
|
79
|
-
# Retryable: 408, 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
|
|
83
|
+
# Retryable: 408, transient 429, 5xx, and network errors (TimeoutException ⊂ RequestError).
|
|
80
84
|
# Non-retryable status errors (400, 401, 403, 404, …) propagate immediately.
|
|
81
85
|
# After retries exhausted: httpx errors are wrapped into SDK types by the outer try/except.
|
|
82
86
|
@retry(
|
|
83
87
|
stop=stop_after_attempt(max_attempts),
|
|
84
88
|
wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
|
|
85
|
-
retry=
|
|
86
|
-
(
|
|
87
|
-
RequestTimeoutError,
|
|
88
|
-
RateLimitError,
|
|
89
|
-
InternalServerError,
|
|
90
|
-
httpx.RequestError, # covers TimeoutException and connection errors
|
|
91
|
-
)
|
|
92
|
-
),
|
|
89
|
+
retry=retry_if_exception(_should_retry),
|
|
93
90
|
reraise=True,
|
|
94
91
|
)
|
|
95
92
|
def _execute() -> httpx.Response:
|
|
@@ -164,7 +161,7 @@ class BaseSyncAPIClient(_BaseClient):
|
|
|
164
161
|
) -> Generator[str, None, None]:
|
|
165
162
|
"""POST request that streams raw response lines (for SSE). Does not parse JSON.
|
|
166
163
|
|
|
167
|
-
Retries the initial connection on 429/5xx with exponential backoff,
|
|
164
|
+
Retries the initial connection on transient 429/5xx with exponential backoff,
|
|
168
165
|
matching the retry behaviour of ``_request()``. Once a 200 response
|
|
169
166
|
is received and streaming begins, no further retries are attempted.
|
|
170
167
|
"""
|
|
@@ -197,14 +194,7 @@ class BaseSyncAPIClient(_BaseClient):
|
|
|
197
194
|
@retry(
|
|
198
195
|
stop=stop_after_attempt(max_attempts),
|
|
199
196
|
wait=wait_exponential(multiplier=_RETRY_MULTIPLIER, max=_RETRY_MAX_WAIT),
|
|
200
|
-
retry=
|
|
201
|
-
(
|
|
202
|
-
RequestTimeoutError,
|
|
203
|
-
RateLimitError,
|
|
204
|
-
InternalServerError,
|
|
205
|
-
httpx.RequestError,
|
|
206
|
-
)
|
|
207
|
-
),
|
|
197
|
+
retry=retry_if_exception(_should_retry),
|
|
208
198
|
reraise=True,
|
|
209
199
|
)
|
|
210
200
|
def _connect() -> httpx.Response:
|
|
@@ -17,6 +17,7 @@ from tinyfish._utils.resource import BaseAsyncAPIResource, BaseSyncAPIResource
|
|
|
17
17
|
from tinyfish._utils.sse_parser import SSEFrame, async_parse_sse_frames, parse_sse_frames
|
|
18
18
|
|
|
19
19
|
from .types import (
|
|
20
|
+
MAX_COLUMNS,
|
|
20
21
|
Dataset,
|
|
21
22
|
DatasetCancelRunResponse,
|
|
22
23
|
DatasetDeleteResponse,
|
|
@@ -76,6 +77,11 @@ def _build_create_body(
|
|
|
76
77
|
spec = DatasetSpec.model_validate(spec).model_dump(exclude_none=True)
|
|
77
78
|
except ValidationError as e:
|
|
78
79
|
raise ValueError(f"Invalid spec: {e}") from e
|
|
80
|
+
if len(spec["columns"]) > MAX_COLUMNS:
|
|
81
|
+
raise ValueError(
|
|
82
|
+
f"Invalid spec: a dataset has at most {MAX_COLUMNS} columns, the key included; "
|
|
83
|
+
f"this one has {len(spec['columns'])}"
|
|
84
|
+
)
|
|
79
85
|
return _without_none(prompt=prompt, spec=spec, target_rows=target_rows, populate=populate)
|
|
80
86
|
|
|
81
87
|
|
|
@@ -42,6 +42,16 @@ class DatasetSpecColumn(_DatasetModel):
|
|
|
42
42
|
type: DatasetColumnType
|
|
43
43
|
is_primary_key: bool
|
|
44
44
|
retrieval_hint: str | None = Field(default=None, description="Where and how the agent finds the value")
|
|
45
|
+
format: str | None = Field(default=None, description="How the value is written, one sentence")
|
|
46
|
+
examples: list[str] | None = Field(default=None, description="Up to three example values as they appear in a cell")
|
|
47
|
+
is_unique: bool | None = Field(
|
|
48
|
+
default=None,
|
|
49
|
+
description="One entity per value, e.g. a profile URL; a second row with the same value merges into the first",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# New datasets only; a stored dataset may be wider.
|
|
54
|
+
MAX_COLUMNS = 10
|
|
45
55
|
|
|
46
56
|
|
|
47
57
|
class DatasetSpec(_DatasetModel):
|
|
@@ -110,6 +120,9 @@ class DatasetRowColumn(_DatasetModel):
|
|
|
110
120
|
label: str
|
|
111
121
|
type: DatasetColumnType
|
|
112
122
|
is_primary_key: bool
|
|
123
|
+
is_unique: bool | None = None
|
|
124
|
+
format: str | None = None
|
|
125
|
+
examples: list[str] | None = None
|
|
113
126
|
|
|
114
127
|
|
|
115
128
|
class DatasetRow(_DatasetModel):
|
|
@@ -20,7 +20,6 @@ from .types import (
|
|
|
20
20
|
ResearchCancelResponse,
|
|
21
21
|
ResearchCreatedEvent,
|
|
22
22
|
ResearchDomainFilter,
|
|
23
|
-
ResearchDomainType,
|
|
24
23
|
ResearchErrorEvent,
|
|
25
24
|
ResearchEvent,
|
|
26
25
|
ResearchFinalResultEvent,
|
|
@@ -63,11 +62,6 @@ def _build_run_body(
|
|
|
63
62
|
query: str,
|
|
64
63
|
mode: ResearchMode,
|
|
65
64
|
output_language: str | None,
|
|
66
|
-
domain_type: ResearchDomainType | None,
|
|
67
|
-
after_date: str | None,
|
|
68
|
-
before_date: str | None,
|
|
69
|
-
recency_minutes: int | None,
|
|
70
|
-
weak_sources_enabled: bool | None,
|
|
71
65
|
domain_filter: ResearchDomainFilter | dict[str, object] | None,
|
|
72
66
|
prior_run_id: str | None,
|
|
73
67
|
session_id: str | None,
|
|
@@ -195,11 +189,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
195
189
|
query: str,
|
|
196
190
|
mode: ResearchMode = "deep",
|
|
197
191
|
output_language: str | None = None,
|
|
198
|
-
domain_type: ResearchDomainType | None = None,
|
|
199
|
-
after_date: str | None = None,
|
|
200
|
-
before_date: str | None = None,
|
|
201
|
-
recency_minutes: int | None = None,
|
|
202
|
-
weak_sources_enabled: bool | None = None,
|
|
203
192
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
204
193
|
prior_run_id: str | None = None,
|
|
205
194
|
session_id: str | None = None,
|
|
@@ -209,11 +198,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
209
198
|
query,
|
|
210
199
|
mode,
|
|
211
200
|
output_language,
|
|
212
|
-
domain_type,
|
|
213
|
-
after_date,
|
|
214
|
-
before_date,
|
|
215
|
-
recency_minutes,
|
|
216
|
-
weak_sources_enabled,
|
|
217
201
|
domain_filter,
|
|
218
202
|
prior_run_id,
|
|
219
203
|
session_id,
|
|
@@ -238,11 +222,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
238
222
|
query: str,
|
|
239
223
|
mode: ResearchMode = "deep",
|
|
240
224
|
output_language: str | None = None,
|
|
241
|
-
domain_type: ResearchDomainType | None = None,
|
|
242
|
-
after_date: str | None = None,
|
|
243
|
-
before_date: str | None = None,
|
|
244
|
-
recency_minutes: int | None = None,
|
|
245
|
-
weak_sources_enabled: bool | None = None,
|
|
246
225
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
247
226
|
prior_run_id: str | None = None,
|
|
248
227
|
session_id: str | None = None,
|
|
@@ -252,11 +231,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
252
231
|
query,
|
|
253
232
|
mode,
|
|
254
233
|
output_language,
|
|
255
|
-
domain_type,
|
|
256
|
-
after_date,
|
|
257
|
-
before_date,
|
|
258
|
-
recency_minutes,
|
|
259
|
-
weak_sources_enabled,
|
|
260
234
|
domain_filter,
|
|
261
235
|
prior_run_id,
|
|
262
236
|
session_id,
|
|
@@ -269,11 +243,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
269
243
|
query: str,
|
|
270
244
|
mode: ResearchMode = "deep",
|
|
271
245
|
output_language: str | None = None,
|
|
272
|
-
domain_type: ResearchDomainType | None = None,
|
|
273
|
-
after_date: str | None = None,
|
|
274
|
-
before_date: str | None = None,
|
|
275
|
-
recency_minutes: int | None = None,
|
|
276
|
-
weak_sources_enabled: bool | None = None,
|
|
277
246
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
278
247
|
prior_run_id: str | None = None,
|
|
279
248
|
session_id: str | None = None,
|
|
@@ -288,11 +257,6 @@ class ResearchResource(BaseSyncAPIResource):
|
|
|
288
257
|
query,
|
|
289
258
|
mode,
|
|
290
259
|
output_language,
|
|
291
|
-
domain_type,
|
|
292
|
-
after_date,
|
|
293
|
-
before_date,
|
|
294
|
-
recency_minutes,
|
|
295
|
-
weak_sources_enabled,
|
|
296
260
|
domain_filter,
|
|
297
261
|
prior_run_id,
|
|
298
262
|
session_id,
|
|
@@ -408,11 +372,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
408
372
|
query: str,
|
|
409
373
|
mode: ResearchMode = "deep",
|
|
410
374
|
output_language: str | None = None,
|
|
411
|
-
domain_type: ResearchDomainType | None = None,
|
|
412
|
-
after_date: str | None = None,
|
|
413
|
-
before_date: str | None = None,
|
|
414
|
-
recency_minutes: int | None = None,
|
|
415
|
-
weak_sources_enabled: bool | None = None,
|
|
416
375
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
417
376
|
prior_run_id: str | None = None,
|
|
418
377
|
session_id: str | None = None,
|
|
@@ -422,11 +381,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
422
381
|
query,
|
|
423
382
|
mode,
|
|
424
383
|
output_language,
|
|
425
|
-
domain_type,
|
|
426
|
-
after_date,
|
|
427
|
-
before_date,
|
|
428
|
-
recency_minutes,
|
|
429
|
-
weak_sources_enabled,
|
|
430
384
|
domain_filter,
|
|
431
385
|
prior_run_id,
|
|
432
386
|
session_id,
|
|
@@ -453,11 +407,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
453
407
|
query: str,
|
|
454
408
|
mode: ResearchMode = "deep",
|
|
455
409
|
output_language: str | None = None,
|
|
456
|
-
domain_type: ResearchDomainType | None = None,
|
|
457
|
-
after_date: str | None = None,
|
|
458
|
-
before_date: str | None = None,
|
|
459
|
-
recency_minutes: int | None = None,
|
|
460
|
-
weak_sources_enabled: bool | None = None,
|
|
461
410
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
462
411
|
prior_run_id: str | None = None,
|
|
463
412
|
session_id: str | None = None,
|
|
@@ -467,11 +416,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
467
416
|
query,
|
|
468
417
|
mode,
|
|
469
418
|
output_language,
|
|
470
|
-
domain_type,
|
|
471
|
-
after_date,
|
|
472
|
-
before_date,
|
|
473
|
-
recency_minutes,
|
|
474
|
-
weak_sources_enabled,
|
|
475
419
|
domain_filter,
|
|
476
420
|
prior_run_id,
|
|
477
421
|
session_id,
|
|
@@ -484,11 +428,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
484
428
|
query: str,
|
|
485
429
|
mode: ResearchMode = "deep",
|
|
486
430
|
output_language: str | None = None,
|
|
487
|
-
domain_type: ResearchDomainType | None = None,
|
|
488
|
-
after_date: str | None = None,
|
|
489
|
-
before_date: str | None = None,
|
|
490
|
-
recency_minutes: int | None = None,
|
|
491
|
-
weak_sources_enabled: bool | None = None,
|
|
492
431
|
domain_filter: ResearchDomainFilter | dict[str, object] | None = None,
|
|
493
432
|
prior_run_id: str | None = None,
|
|
494
433
|
session_id: str | None = None,
|
|
@@ -503,11 +442,6 @@ class AsyncResearchResource(BaseAsyncAPIResource):
|
|
|
503
442
|
query,
|
|
504
443
|
mode,
|
|
505
444
|
output_language,
|
|
506
|
-
domain_type,
|
|
507
|
-
after_date,
|
|
508
|
-
before_date,
|
|
509
|
-
recency_minutes,
|
|
510
|
-
weak_sources_enabled,
|
|
511
445
|
domain_filter,
|
|
512
446
|
prior_run_id,
|
|
513
447
|
session_id,
|
|
@@ -101,7 +101,10 @@ RunRetrieveResponse = Run
|
|
|
101
101
|
class PaginationInfo(BaseModel):
|
|
102
102
|
"""Pagination metadata for list responses."""
|
|
103
103
|
|
|
104
|
-
total: int = Field(
|
|
104
|
+
total: int = Field(
|
|
105
|
+
...,
|
|
106
|
+
description="Total number of runs matching the current filters. Team Runs lists stop counting at 1,000.",
|
|
107
|
+
)
|
|
105
108
|
has_more: bool = Field(..., description="Whether there are more results after this page")
|
|
106
109
|
next_cursor: str | None = Field(None, description="Cursor for fetching next page. None if no more results.")
|
|
107
110
|
|
|
@@ -94,6 +94,32 @@ def test_create_sends_a_spec_as_model_or_dict_and_populate_false(client: TinyFis
|
|
|
94
94
|
client.datasets.create(spec=_SPEC, populate=False)
|
|
95
95
|
assert _body(route) == {"spec": _SPEC, "populate": False}
|
|
96
96
|
assert json.loads(route.calls[1].request.content) == {"spec": _SPEC, "populate": False}
|
|
97
|
+
# A column's format, examples and is_unique are typed and sent as given.
|
|
98
|
+
described = {
|
|
99
|
+
**_SPEC,
|
|
100
|
+
"columns": [
|
|
101
|
+
{
|
|
102
|
+
"name": "name",
|
|
103
|
+
"type": "string",
|
|
104
|
+
"is_primary_key": True,
|
|
105
|
+
"format": "Trading name",
|
|
106
|
+
"examples": ["Blue Bottle"],
|
|
107
|
+
},
|
|
108
|
+
{"name": "website", "type": "url", "is_primary_key": False, "is_unique": True},
|
|
109
|
+
],
|
|
110
|
+
}
|
|
111
|
+
spec = DatasetSpec.model_validate(described)
|
|
112
|
+
assert spec.columns[1].is_unique is True
|
|
113
|
+
client.datasets.create(spec=spec, populate=False)
|
|
114
|
+
assert json.loads(route.calls[2].request.content)["spec"]["columns"][0]["examples"] == ["Blue Bottle"]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
118
|
+
def test_get_and_list_keep_a_stored_dataset_wider_than_the_cap(client: TinyFish, respx_mock: MockRouter):
|
|
119
|
+
columns = [{"name": f"c{i}", "type": "string", "is_primary_key": i == 0} for i in range(12)]
|
|
120
|
+
wide = {**_DATASET, "spec": {**_DATASET["spec"], "columns": columns}}
|
|
121
|
+
respx_mock.get(_DATASET_PATH).mock(return_value=httpx.Response(200, json=wide))
|
|
122
|
+
assert len(client.datasets.get(_DATASET_ID).spec.columns) == 12
|
|
97
123
|
|
|
98
124
|
|
|
99
125
|
@pytest.mark.respx(base_url=BASE_URL, assert_all_called=False)
|
|
@@ -107,6 +133,9 @@ def test_create_rejects_bad_input_before_sending(client: TinyFish, respx_mock: M
|
|
|
107
133
|
client.datasets.create(prompt=" ")
|
|
108
134
|
with pytest.raises(ValueError, match="Invalid spec"):
|
|
109
135
|
client.datasets.create(spec={"name": "x"})
|
|
136
|
+
eleven = [{"name": f"c{i}", "type": "string", "is_primary_key": i == 0} for i in range(11)]
|
|
137
|
+
with pytest.raises(ValueError, match="at most 10 columns, the key included; this one has 11"):
|
|
138
|
+
client.datasets.create(spec={"name": "x", "description": "x", "columns": eleven})
|
|
110
139
|
with pytest.raises(TypeError, match="webhook_url"):
|
|
111
140
|
client.datasets.create(prompt=_PROMPT, webhook_url="x") # type: ignore[call-arg]
|
|
112
141
|
assert not route.called
|
|
@@ -319,3 +319,49 @@ async def test_async_max_retries_0_does_not_retry(async_client: AsyncTinyFish, r
|
|
|
319
319
|
with pytest.raises(RateLimitError):
|
|
320
320
|
await c.agent.run(**_BODY)
|
|
321
321
|
assert route.call_count == 1
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@pytest.mark.parametrize("product", ["search", "fetch"])
|
|
325
|
+
@pytest.mark.parametrize("reason,attempts", [("free_allowance_exhausted", 1), ("rate_limit_exceeded", 3), (None, 3)])
|
|
326
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
327
|
+
def test_daily_allowance_retry_policy(product: str, reason: str | None, attempts: int, respx_mock: MockRouter):
|
|
328
|
+
message = "Daily allowance reached. Resets at 00:00 UTC. https://example.com/wallet"
|
|
329
|
+
route = respx_mock.route(method="GET" if product == "search" else "POST", path=f"/v1/{product}").mock(
|
|
330
|
+
return_value=httpx.Response(
|
|
331
|
+
429, json={"error": {"code": "RATE_LIMIT_EXCEEDED", "message": message, "details": {"reason": reason}}}
|
|
332
|
+
)
|
|
333
|
+
)
|
|
334
|
+
with TinyFish(api_key=API_KEY, base_url=BASE_URL, max_retries=2) as client, mock.patch("time.sleep"):
|
|
335
|
+
with pytest.raises(RateLimitError) as exc:
|
|
336
|
+
if product == "search":
|
|
337
|
+
client.search.query("test")
|
|
338
|
+
else:
|
|
339
|
+
client.fetch.get_contents(["https://example.com"])
|
|
340
|
+
assert route.call_count == attempts
|
|
341
|
+
assert exc.value.status_code == 429
|
|
342
|
+
assert exc.value.code == "RATE_LIMIT_EXCEEDED"
|
|
343
|
+
assert exc.value.message == message
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
@pytest.mark.parametrize("product", ["search", "fetch"])
|
|
347
|
+
@pytest.mark.parametrize("reason,attempts", [("free_allowance_exhausted", 1), ("rate_limit_exceeded", 3), (None, 3)])
|
|
348
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
349
|
+
async def test_async_daily_allowance_retry_policy(
|
|
350
|
+
product: str, reason: str | None, attempts: int, respx_mock: MockRouter
|
|
351
|
+
):
|
|
352
|
+
message = "Daily allowance reached. Resets at 00:00 UTC. https://example.com/wallet"
|
|
353
|
+
route = respx_mock.route(method="GET" if product == "search" else "POST", path=f"/v1/{product}").mock(
|
|
354
|
+
return_value=httpx.Response(
|
|
355
|
+
429, json={"error": {"code": "RATE_LIMIT_EXCEEDED", "message": message, "details": {"reason": reason}}}
|
|
356
|
+
)
|
|
357
|
+
)
|
|
358
|
+
async with AsyncTinyFish(api_key=API_KEY, base_url=BASE_URL, max_retries=2) as client:
|
|
359
|
+
with mock.patch("asyncio.sleep"), pytest.raises(RateLimitError) as exc:
|
|
360
|
+
if product == "search":
|
|
361
|
+
await client.search.query("test")
|
|
362
|
+
else:
|
|
363
|
+
await client.fetch.get_contents(["https://example.com"])
|
|
364
|
+
assert route.call_count == attempts
|
|
365
|
+
assert exc.value.status_code == 429
|
|
366
|
+
assert exc.value.code == "RATE_LIMIT_EXCEEDED"
|
|
367
|
+
assert exc.value.message == message
|
|
@@ -102,16 +102,13 @@ def test_queue_omits_mode_so_the_server_picks_deep(client: TinyFish, respx_mock:
|
|
|
102
102
|
|
|
103
103
|
|
|
104
104
|
@pytest.mark.respx(base_url=BASE_URL)
|
|
105
|
-
def
|
|
105
|
+
def test_queue_sends_language_and_domain_filter_model(client: TinyFish, respx_mock: MockRouter):
|
|
106
106
|
route = respx_mock.post(_START_PATH).mock(
|
|
107
107
|
return_value=httpx.Response(200, json={"research_run_id": _RUN_ID, "error": None})
|
|
108
108
|
)
|
|
109
109
|
client.research.queue(
|
|
110
110
|
query=_QUERY,
|
|
111
111
|
output_language="ja",
|
|
112
|
-
domain_type="news",
|
|
113
|
-
recency_minutes=1440,
|
|
114
|
-
weak_sources_enabled=True,
|
|
115
112
|
domain_filter=ResearchDomainFilter(mode="include", domains=["example.com"]),
|
|
116
113
|
session_id="0b6c1f1e-1d2a-4d6b-9a77-4ad5c1f0e001",
|
|
117
114
|
)
|
|
@@ -119,9 +116,6 @@ def test_queue_sends_filters_and_domain_filter_model(client: TinyFish, respx_moc
|
|
|
119
116
|
"query": _QUERY,
|
|
120
117
|
"mode": "deep",
|
|
121
118
|
"output_language": "ja",
|
|
122
|
-
"domain_type": "news",
|
|
123
|
-
"recency_minutes": 1440,
|
|
124
|
-
"weak_sources_enabled": True,
|
|
125
119
|
"domain_filter": {"mode": "include", "domains": ["example.com"]},
|
|
126
120
|
"session_id": "0b6c1f1e-1d2a-4d6b-9a77-4ad5c1f0e001",
|
|
127
121
|
}
|
|
@@ -266,3 +260,36 @@ async def test_async_get_list_and_cancel(async_client: AsyncTinyFish, respx_mock
|
|
|
266
260
|
async def test_async_queue_rejects_empty_query(async_client: AsyncTinyFish):
|
|
267
261
|
with pytest.raises(ValueError):
|
|
268
262
|
await async_client.research.queue(query="")
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@pytest.mark.parametrize(
|
|
266
|
+
"field,value",
|
|
267
|
+
[
|
|
268
|
+
("weak_sources_enabled", True),
|
|
269
|
+
("domain_type", "news"),
|
|
270
|
+
("after_date", "2026-01-01"),
|
|
271
|
+
("before_date", "2026-06-30"),
|
|
272
|
+
("recency_minutes", 1440),
|
|
273
|
+
],
|
|
274
|
+
)
|
|
275
|
+
@pytest.mark.parametrize("method", ["queue", "run", "stream"])
|
|
276
|
+
def test_rejects_removed_parameters(client: TinyFish, field, value, method):
|
|
277
|
+
with pytest.raises(TypeError, match=field):
|
|
278
|
+
getattr(client.research, method)(query=_QUERY, **{field: value})
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
@pytest.mark.parametrize(
|
|
282
|
+
"field,value",
|
|
283
|
+
[
|
|
284
|
+
("weak_sources_enabled", True),
|
|
285
|
+
("domain_type", "news"),
|
|
286
|
+
("after_date", "2026-01-01"),
|
|
287
|
+
("before_date", "2026-06-30"),
|
|
288
|
+
("recency_minutes", 1440),
|
|
289
|
+
],
|
|
290
|
+
)
|
|
291
|
+
@pytest.mark.parametrize("method", ["queue", "run", "stream"])
|
|
292
|
+
def test_async_rejects_removed_parameters(field, value, method):
|
|
293
|
+
client = AsyncTinyFish(api_key=API_KEY, base_url=BASE_URL)
|
|
294
|
+
with pytest.raises(TypeError, match=field):
|
|
295
|
+
getattr(client.research, method)(query=_QUERY, **{field: value})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|