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 .spec-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28bf2af12a8765adb95381c7160cfc5b5e4ddd12
6ace098c56527cf0a0e5018b67ec454412ee6926
2 changes: 1 addition & 1 deletion src/onepin/.fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
]
},
"originGitCommit": "968747c21f0b427963288a82817fbe21a736230b",
"originGitCommit": "9e634eff3eb65ab32b4a77b6fee5e0d27aa126cf",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"ciProvider": "github"
Expand Down
2 changes: 1 addition & 1 deletion src/onepin/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_headers(self) -> typing.Dict[str, str]:
import platform

headers: typing.Dict[str, str] = {
"User-Agent": "onepin/0.11.1",
"User-Agent": "onepin/0.12.1",
"X-Fern-Language": "Python",
"X-Fern-Runtime": f"python/{platform.python_version()}",
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
Expand Down
34 changes: 34 additions & 0 deletions src/onepin/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import email.utils
import re
import socket
import time
import typing
from contextlib import asynccontextmanager, contextmanager
Expand All @@ -23,6 +24,39 @@
JITTER_FACTOR = 0.2 # 20% random jitter


def get_keepalive_socket_options(
idle: int = 60,
intvl: int = 30,
cnt: int = 5,
) -> typing.List[typing.Tuple[int, int, int]]:
"""
Build TCP keepalive socket options for the current platform.

Keepalive probes keep otherwise-idle connections alive so that long,
non-streaming requests survive idle-connection reaping by a firewall,
load balancer, or NAT. The available socket constants are OS-dependent,
so each option is guarded and only emitted when the platform defines it:

- ``SO_KEEPALIVE`` is portable (Linux/macOS/Windows).
- The idle-before-first-probe knob is ``TCP_KEEPIDLE`` on Linux and modern
Windows, but ``TCP_KEEPALIVE`` on macOS.
- ``TCP_KEEPINTVL`` / ``TCP_KEEPCNT`` exist on Linux/macOS/modern Windows.

Passing these tuples to ``httpx.HTTPTransport(socket_options=...)`` /
``httpx.AsyncHTTPTransport(socket_options=...)`` applies them to every
connection the transport opens.
"""
opts: typing.List[typing.Tuple[int, int, int]] = [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)]
idle_const = getattr(socket, "TCP_KEEPIDLE", None) or getattr(socket, "TCP_KEEPALIVE", None)
if idle_const:
opts.append((socket.IPPROTO_TCP, idle_const, idle))
if hasattr(socket, "TCP_KEEPINTVL"):
opts.append((socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, intvl))
if hasattr(socket, "TCP_KEEPCNT"):
opts.append((socket.IPPROTO_TCP, socket.TCP_KEEPCNT, cnt))
return opts


def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float]:
"""
This function parses the `Retry-After` header in a HTTP response and returns the number of seconds to wait.
Expand Down
46 changes: 29 additions & 17 deletions src/onepin/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ client.templates.get(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2026,7 +2026,7 @@ client.templates.delete_template(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2120,7 +2120,7 @@ client.templates.update_template(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2254,7 +2254,7 @@ client.templates.estimate_template(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2352,7 +2352,7 @@ client.templates.clone(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2451,7 +2451,7 @@ client.templates.favorite_template(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2527,7 +2527,7 @@ client.templates.unfavorite_template(
<dl>
<dd>

**template_id:** `str`
**template_id:** `str` — Case-sensitive 8-character base62 template identifier.

</dd>
</dl>
Expand Down Expand Up @@ -2567,10 +2567,11 @@ Every filter accepts repeat-key OR semantics:
Filters combine across fields with AND; within a field, values OR.

`language` matches a voice when any of its declared locales matches any
requested value. Platform voices with no declared locales (catalog gaps)
are treated as general-use and match every language filter. User-uploaded
/ cloned voices with no declared locales are excluded — that state means
"language unknown" pending the clone flow's language detection.
requested value. A voice with no declared locales matches NO `language`
filter — it must positively declare a locale to surface under it. This holds
for platform and user-uploaded voices alike: an unclassified platform voice
(catalog gap) is not treated as general-use, and a user-uploaded/cloned voice
with no locale stays "language unknown" pending clone-flow detection.

Multi-sort: `sort` and `order` are parallel lists. `?sort=uses_count&sort=name&order=desc&order=asc`
orders primarily by uses_count DESC, secondarily by name ASC. When `order`
Expand Down Expand Up @@ -2770,10 +2771,18 @@ instead of hardcoding option lists (mirrors `GET /dictionary/languages`). Each
item is `{value, label, count}`: `value` is passed straight back to
`GET /voices`; `label` is the display name for providers/models and `null`
elsewhere (the FE owns language + enum labels); `count` is the number of
matching voices. For `languages`/`models`, `count` counts only voices that
explicitly declare the value — "general-use" platform voices (no declared
locales/models) that `GET /voices` matches against every language/model filter
are not counted, so a chip's count can be lower than the `GET /voices` result.
matching voices. A language surfaces as one chip keyed by its canonical
allowlist locale: every declared locale is folded onto the locale the
`GET /voices` filter would match it against (bare `ko` and regioned `ko-kr`
both count under `ko-kr`), so variants never split into duplicate chips for
the identical filter. Model counts include only voices that explicitly declare
the model. Language counts include voices that declare the exact regional locale
plus voices that declare its bare family (`en` contributes to every supported
`en-*` locale). A voice with no declared `supported_models` is "general use" —
`GET /voices` matches it against every model filter but no `models` chip counts
it, so a model chip's count can be lower than the `GET /voices?model=` result.
Languages have no such gap: no-locale voices are excluded from both the language
chips and `GET /voices?language=`, so language chip counts match the row counts.

Accepts the SAME filters as `GET /voices` (tab scope `source`/`favorites_only`,
plus `provider`/`model`/`language`/`gender`/`age`/`category`/`accent`/`search`).
Expand Down Expand Up @@ -6501,8 +6510,11 @@ client.workflows.patch_workflow(
List confirmed uploads attached to a workflow.

Returns only uploads that have been confirmed (fully transferred and
committed to the workflow). In-progress or abandoned uploads are excluded.
Each item includes a short-lived download URL for the uploaded file.
committed to the workflow), plus confirmed uploads the workflow definition's
Script Input nodes reference by id (e.g. a file attached in the assistant
chat, which stays bound to its assistant session). In-progress or abandoned
uploads are excluded. Each item includes a short-lived download URL for the
uploaded file.
</dd>
</dl>
</dd>
Expand Down
14 changes: 14 additions & 0 deletions src/onepin/templates/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def get(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -246,6 +247,7 @@ def delete_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -303,6 +305,7 @@ def update_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -379,6 +382,7 @@ def estimate_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -437,6 +441,7 @@ def clone(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -485,6 +490,7 @@ def favorite_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Expand Down Expand Up @@ -520,6 +526,7 @@ def unfavorite_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Expand Down Expand Up @@ -739,6 +746,7 @@ async def get(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -796,6 +804,7 @@ async def delete_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -861,6 +870,7 @@ async def update_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -945,6 +955,7 @@ async def estimate_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -1011,6 +1022,7 @@ async def clone(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

workspace_id : typing.Optional[str]

Expand Down Expand Up @@ -1067,6 +1079,7 @@ async def favorite_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Expand Down Expand Up @@ -1110,6 +1123,7 @@ async def unfavorite_template(
Parameters
----------
template_id : str
Case-sensitive 8-character base62 template identifier.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Expand Down
Loading