Skip to content
Open
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 @@
{
".": "0.32.0"
".": "0.33.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/profound%2Fprofound-85c2cc542ebd87adbf37b0e66894b4854b2e828f88bcafed4ea77f68a97355ce.yml
openapi_spec_hash: fb8408a3cfee3614593fdedee497c1d7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/profound%2Fprofound-060d7cfc1e35a0dd50dd6407c3bffc85ba8f9141973aa17981e9a5d772c2a29d.yml
openapi_spec_hash: da36e2144d0e2f36518bf1b4f8090b0b
config_hash: f683a29859356d6968a19ae3e6063b63
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.33.0 (2026-03-20)

Full Changelog: [v0.32.0...v0.33.0](https://github.com/cooper-square-technologies/profound-python-sdk/compare/v0.32.0...v0.33.0)

### Features

* **api:** api update ([5a404f0](https://github.com/cooper-square-technologies/profound-python-sdk/commit/5a404f00c3067f19069e5552b13ae400a9ffeef0))
* **api:** api update ([509d95f](https://github.com/cooper-square-technologies/profound-python-sdk/commit/509d95f4de2f04aa7d87a675acb09314ef854877))
* **api:** api update ([b050c07](https://github.com/cooper-square-technologies/profound-python-sdk/commit/b050c070b9ce850723cef0f2175141c6ed09ec36))


### Bug Fixes

* sanitize endpoint path params ([6ad08f2](https://github.com/cooper-square-technologies/profound-python-sdk/commit/6ad08f271d90cee4cd405a916fd81e031ebe28ed))

## 0.32.0 (2026-03-17)

Full Changelog: [v0.31.1...v0.32.0](https://github.com/cooper-square-technologies/profound-python-sdk/compare/v0.31.1...v0.32.0)
Expand Down
12 changes: 1 addition & 11 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# Shared Types

```python
from profound.types import (
AssetNameFilter,
ModelIDFilter,
Pagination,
PathFilter,
PersonaIDFilter,
PromptFilter,
RegionIDFilter,
TagIDFilter,
TopicIDFilter,
)
from profound.types import AssetNameFilter, Pagination, PathFilter, PromptFilter
```

# Organizations
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 = "profound"
version = "0.32.0"
version = "0.33.0"
description = "The official Python library for the profound API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
1 change: 1 addition & 0 deletions src/profound/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ._path import path_template as path_template
from ._sync import asyncify as asyncify
from ._proxy import LazyProxy as LazyProxy
from ._utils import (
Expand Down
127 changes: 127 additions & 0 deletions src/profound/_utils/_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
from __future__ import annotations

import re
from typing import (
Any,
Mapping,
Callable,
)
from urllib.parse import quote

# Matches '.' or '..' where each dot is either literal or percent-encoded (%2e / %2E).
_DOT_SEGMENT_RE = re.compile(r"^(?:\.|%2[eE]){1,2}$")

_PLACEHOLDER_RE = re.compile(r"\{(\w+)\}")


def _quote_path_segment_part(value: str) -> str:
"""Percent-encode `value` for use in a URI path segment.

Considers characters not in `pchar` set from RFC 3986 §3.3 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
"""
# quote() already treats unreserved characters (letters, digits, and -._~)
# as safe, so we only need to add sub-delims, ':', and '@'.
# Notably, unlike the default `safe` for quote(), / is unsafe and must be quoted.
return quote(value, safe="!$&'()*+,;=:@")


def _quote_query_part(value: str) -> str:
"""Percent-encode `value` for use in a URI query string.

Considers &, = and characters not in `query` set from RFC 3986 §3.4 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.4
"""
return quote(value, safe="!$'()*+,;:@/?")


def _quote_fragment_part(value: str) -> str:
"""Percent-encode `value` for use in a URI fragment.

Considers characters not in `fragment` set from RFC 3986 §3.5 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
"""
return quote(value, safe="!$&'()*+,;=:@/?")


def _interpolate(
template: str,
values: Mapping[str, Any],
quoter: Callable[[str], str],
) -> str:
"""Replace {name} placeholders in `template`, quoting each value with `quoter`.

Placeholder names are looked up in `values`.

Raises:
KeyError: If a placeholder is not found in `values`.
"""
# re.split with a capturing group returns alternating
# [text, name, text, name, ..., text] elements.
parts = _PLACEHOLDER_RE.split(template)

for i in range(1, len(parts), 2):
name = parts[i]
if name not in values:
raise KeyError(f"a value for placeholder {{{name}}} was not provided")
val = values[name]
if val is None:
parts[i] = "null"
elif isinstance(val, bool):
parts[i] = "true" if val else "false"
else:
parts[i] = quoter(str(values[name]))

return "".join(parts)


def path_template(template: str, /, **kwargs: Any) -> str:
"""Interpolate {name} placeholders in `template` from keyword arguments.

Args:
template: The template string containing {name} placeholders.
**kwargs: Keyword arguments to interpolate into the template.

Returns:
The template with placeholders interpolated and percent-encoded.

Safe characters for percent-encoding are dependent on the URI component.
Placeholders in path and fragment portions are percent-encoded where the `segment`
and `fragment` sets from RFC 3986 respectively are considered safe.
Placeholders in the query portion are percent-encoded where the `query` set from
RFC 3986 §3.3 is considered safe except for = and & characters.

Raises:
KeyError: If a placeholder is not found in `kwargs`.
ValueError: If resulting path contains /./ or /../ segments (including percent-encoded dot-segments).
"""
# Split the template into path, query, and fragment portions.
fragment_template: str | None = None
query_template: str | None = None

rest = template
if "#" in rest:
rest, fragment_template = rest.split("#", 1)
if "?" in rest:
rest, query_template = rest.split("?", 1)
path_template = rest

# Interpolate each portion with the appropriate quoting rules.
path_result = _interpolate(path_template, kwargs, _quote_path_segment_part)

# Reject dot-segments (. and ..) in the final assembled path. The check
# runs after interpolation so that adjacent placeholders or a mix of static
# text and placeholders that together form a dot-segment are caught.
# Also reject percent-encoded dot-segments to protect against incorrectly
# implemented normalization in servers/proxies.
for segment in path_result.split("/"):
if _DOT_SEGMENT_RE.match(segment):
raise ValueError(f"Constructed path {path_result!r} contains dot-segment {segment!r} which is not allowed")

result = path_result
if query_template is not None:
result += "?" + _interpolate(query_template, kwargs, _quote_query_part)
if fragment_template is not None:
result += "#" + _interpolate(fragment_template, kwargs, _quote_fragment_part)

return result
2 changes: 1 addition & 1 deletion src/profound/_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__ = "profound"
__version__ = "0.32.0" # x-release-please-version
__version__ = "0.33.0" # x-release-please-version
10 changes: 5 additions & 5 deletions src/profound/resources/content/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import httpx

from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ..._utils import maybe_transform, async_maybe_transform
from ..._utils import path_template, maybe_transform, async_maybe_transform
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
Expand Down Expand Up @@ -71,7 +71,7 @@ def retrieve(
if not content_id:
raise ValueError(f"Expected a non-empty value for `content_id` but received {content_id!r}")
return self._get(
f"/v1/content/{asset_id}/optimization/{content_id}",
path_template("/v1/content/{asset_id}/optimization/{content_id}", asset_id=asset_id, content_id=content_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -110,7 +110,7 @@ def list(
if not asset_id:
raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}")
return self._get(
f"/v1/content/{asset_id}/optimization",
path_template("/v1/content/{asset_id}/optimization", asset_id=asset_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -177,7 +177,7 @@ async def retrieve(
if not content_id:
raise ValueError(f"Expected a non-empty value for `content_id` but received {content_id!r}")
return await self._get(
f"/v1/content/{asset_id}/optimization/{content_id}",
path_template("/v1/content/{asset_id}/optimization/{content_id}", asset_id=asset_id, content_id=content_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -216,7 +216,7 @@ async def list(
if not asset_id:
raise ValueError(f"Expected a non-empty value for `asset_id` but received {asset_id!r}")
return await self._get(
f"/v1/content/{asset_id}/optimization",
path_template("/v1/content/{asset_id}/optimization", asset_id=asset_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
18 changes: 13 additions & 5 deletions src/profound/resources/logs/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Dict, List, Union, Iterable, cast
from typing import Any, Dict, List, Union, Iterable, Optional, cast
from datetime import datetime
from typing_extensions import Literal

Expand Down Expand Up @@ -53,7 +53,7 @@ def bots(
domain: str,
metrics: List[Literal["count"]],
start_date: Union[str, datetime],
date_interval: Literal["day", "week", "month", "year", "relative_week"] | Omit = omit,
date_interval: Literal["hour", "day", "week", "month", "year", "relative_week"] | Omit = omit,
dimensions: List[
Literal[
"timestamp",
Expand All @@ -76,6 +76,7 @@ def bots(
end_date: Union[str, datetime] | Omit = omit,
filters: Iterable[raw_bots_params.Filter] | Omit = omit,
order_by: Dict[str, Literal["asc", "desc"]] | Omit = omit,
organization_id: Optional[str] | Omit = omit,
pagination: Pagination | Omit = omit,
# 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.
Expand Down Expand Up @@ -137,6 +138,7 @@ def bots(
"end_date": end_date,
"filters": filters,
"order_by": order_by,
"organization_id": organization_id,
"pagination": pagination,
},
raw_bots_params.RawBotsParams,
Expand All @@ -154,7 +156,7 @@ def logs(
domain: str,
metrics: List[Literal["count"]],
start_date: Union[str, datetime],
date_interval: Literal["day", "week", "month", "year", "relative_week"] | Omit = omit,
date_interval: Literal["hour", "day", "week", "month", "year", "relative_week"] | Omit = omit,
dimensions: List[
Literal[
"timestamp",
Expand All @@ -174,6 +176,7 @@ def logs(
end_date: Union[str, datetime] | Omit = omit,
filters: Iterable[raw_logs_params.Filter] | Omit = omit,
order_by: Dict[str, Literal["asc", "desc"]] | Omit = omit,
organization_id: Optional[str] | Omit = omit,
pagination: Pagination | Omit = omit,
# 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.
Expand Down Expand Up @@ -235,6 +238,7 @@ def logs(
"end_date": end_date,
"filters": filters,
"order_by": order_by,
"organization_id": organization_id,
"pagination": pagination,
},
raw_logs_params.RawLogsParams,
Expand Down Expand Up @@ -273,7 +277,7 @@ async def bots(
domain: str,
metrics: List[Literal["count"]],
start_date: Union[str, datetime],
date_interval: Literal["day", "week", "month", "year", "relative_week"] | Omit = omit,
date_interval: Literal["hour", "day", "week", "month", "year", "relative_week"] | Omit = omit,
dimensions: List[
Literal[
"timestamp",
Expand All @@ -296,6 +300,7 @@ async def bots(
end_date: Union[str, datetime] | Omit = omit,
filters: Iterable[raw_bots_params.Filter] | Omit = omit,
order_by: Dict[str, Literal["asc", "desc"]] | Omit = omit,
organization_id: Optional[str] | Omit = omit,
pagination: Pagination | Omit = omit,
# 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.
Expand Down Expand Up @@ -357,6 +362,7 @@ async def bots(
"end_date": end_date,
"filters": filters,
"order_by": order_by,
"organization_id": organization_id,
"pagination": pagination,
},
raw_bots_params.RawBotsParams,
Expand All @@ -374,7 +380,7 @@ async def logs(
domain: str,
metrics: List[Literal["count"]],
start_date: Union[str, datetime],
date_interval: Literal["day", "week", "month", "year", "relative_week"] | Omit = omit,
date_interval: Literal["hour", "day", "week", "month", "year", "relative_week"] | Omit = omit,
dimensions: List[
Literal[
"timestamp",
Expand All @@ -394,6 +400,7 @@ async def logs(
end_date: Union[str, datetime] | Omit = omit,
filters: Iterable[raw_logs_params.Filter] | Omit = omit,
order_by: Dict[str, Literal["asc", "desc"]] | Omit = omit,
organization_id: Optional[str] | Omit = omit,
pagination: Pagination | Omit = omit,
# 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.
Expand Down Expand Up @@ -455,6 +462,7 @@ async def logs(
"end_date": end_date,
"filters": filters,
"order_by": order_by,
"organization_id": organization_id,
"pagination": pagination,
},
raw_logs_params.RawLogsParams,
Expand Down
Loading
Loading