From 45d18143451c84ec01a86e55178901674b5bb5e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 08:24:44 +0000 Subject: [PATCH 1/2] feat(api): api update --- .stats.yml | 4 +-- README.md | 11 ++++--- src/moderation_api/resources/content.py | 12 +++++++ .../types/content_submit_params.py | 32 +++++++++++++++++++ .../types/content_submit_response.py | 1 + tests/api_resources/test_content.py | 12 +++++++ 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index b80b97b..6265db3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 27 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-cbf656f40e43acf60d9596f78204f031dc8c7205626df8f05ce8e88bcf49b597.yml -openapi_spec_hash: 23be5a56248a1a575b34833eb7e7fe49 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-9c5291067ec36cba0c9ef772c5c8eb10238fb332f1f25d0e31f3f2ad87c24e5e.yml +openapi_spec_hash: 790cc0a36d6ed693c06a285c441ab977 config_hash: 9d144cc6c49d3fd53e5b4472c1e22165 diff --git a/README.md b/README.md index 1fbce18..a19b6cf 100644 --- a/README.md +++ b/README.md @@ -130,11 +130,14 @@ from moderation_api import ModerationAPI client = ModerationAPI() -author = client.authors.create( - external_id="external_id", - metadata={}, +response = client.content.submit( + content={ + "text": "text", + "type": "text", + }, + client_action={"action": "review"}, ) -print(author.metadata) +print(response.client_action) ``` ## Handling errors diff --git a/src/moderation_api/resources/content.py b/src/moderation_api/resources/content.py index 5c0543b..b29a7a3 100644 --- a/src/moderation_api/resources/content.py +++ b/src/moderation_api/resources/content.py @@ -50,6 +50,7 @@ def submit( content: content_submit_params.Content, author_id: str | Omit = omit, channel: str | Omit = omit, + client_action: content_submit_params.ClientAction | Omit = omit, content_id: str | Omit = omit, conversation_id: str | Omit = omit, do_not_store: bool | Omit = omit, @@ -74,6 +75,10 @@ def submit( channel: Provide a channel ID or key. Will use the project's default channel if not provided. + client_action: A recommendation from your own client-side flagging (e.g. a banned-IP list or a + third-party tool). Feeds the rules engine and can escalate or override the + recommended action. Does not change whether our analysis flagged the content. + content_id: The unique ID of the content in your database. conversation_id: For example the ID of a chat room or a post @@ -104,6 +109,7 @@ def submit( "content": content, "author_id": author_id, "channel": channel, + "client_action": client_action, "content_id": content_id, "conversation_id": conversation_id, "do_not_store": do_not_store, @@ -147,6 +153,7 @@ async def submit( content: content_submit_params.Content, author_id: str | Omit = omit, channel: str | Omit = omit, + client_action: content_submit_params.ClientAction | Omit = omit, content_id: str | Omit = omit, conversation_id: str | Omit = omit, do_not_store: bool | Omit = omit, @@ -171,6 +178,10 @@ async def submit( channel: Provide a channel ID or key. Will use the project's default channel if not provided. + client_action: A recommendation from your own client-side flagging (e.g. a banned-IP list or a + third-party tool). Feeds the rules engine and can escalate or override the + recommended action. Does not change whether our analysis flagged the content. + content_id: The unique ID of the content in your database. conversation_id: For example the ID of a chat room or a post @@ -201,6 +212,7 @@ async def submit( "content": content, "author_id": author_id, "channel": channel, + "client_action": client_action, "content_id": content_id, "conversation_id": conversation_id, "do_not_store": do_not_store, diff --git a/src/moderation_api/types/content_submit_params.py b/src/moderation_api/types/content_submit_params.py index d7274cf..76f4631 100644 --- a/src/moderation_api/types/content_submit_params.py +++ b/src/moderation_api/types/content_submit_params.py @@ -21,6 +21,7 @@ "ContentObjectDataImage", "ContentObjectDataVideo", "ContentObjectDataAudio", + "ClientAction", "Policy", "PolicyToxicity", "PolicyPersonalInformation", @@ -69,6 +70,14 @@ class ContentSubmitParams(TypedDict, total=False): Will use the project's default channel if not provided. """ + client_action: Annotated[ClientAction, PropertyInfo(alias="clientAction")] + """A recommendation from your own client-side flagging (e.g. + + a banned-IP list or a third-party tool). Feeds the rules engine and can escalate + or override the recommended action. Does not change whether our analysis flagged + the content. + """ + content_id: Annotated[str, PropertyInfo(alias="contentId")] """The unique ID of the content in your database.""" @@ -200,6 +209,29 @@ class ContentObject(TypedDict, total=False): Content: TypeAlias = Union[ContentText, ContentImage, ContentVideo, ContentAudio, ContentObject] +class ClientAction(TypedDict, total=False): + """A recommendation from your own client-side flagging (e.g. + + a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content. + """ + + action: Required[Literal["review", "allow", "reject"]] + """Your recommendation for the content: allow, review, or reject.""" + + behavior: Literal["override", "escalate"] + """How your recommendation combines with ours. + + Defaults to 'escalate', which only applies it when stricter than ours; + 'override' replaces ours outright. + """ + + reason: str + """A human-readable explanation for your recommendation.""" + + source: str + """Where your recommendation came from, e.g. "banned-ip".""" + + class PolicyToxicity(TypedDict, total=False): id: Required[Literal["toxicity"]] diff --git a/src/moderation_api/types/content_submit_response.py b/src/moderation_api/types/content_submit_response.py index 7133c17..f79afe3 100644 --- a/src/moderation_api/types/content_submit_response.py +++ b/src/moderation_api/types/content_submit_response.py @@ -351,6 +351,7 @@ class Recommendation(BaseModel): "rule_match", "rule_default", "rule_fallback", + "client_override", ] ] """The reason code for the recommendation. diff --git a/tests/api_resources/test_content.py b/tests/api_resources/test_content.py index fbf989e..9f5a864 100644 --- a/tests/api_resources/test_content.py +++ b/tests/api_resources/test_content.py @@ -38,6 +38,12 @@ def test_method_submit_with_all_params(self, client: ModerationAPI) -> None: }, author_id="authorId", channel="channel", + client_action={ + "action": "review", + "behavior": "override", + "reason": "reason", + "source": "source", + }, content_id="contentId", conversation_id="conversationId", do_not_store=True, @@ -113,6 +119,12 @@ async def test_method_submit_with_all_params(self, async_client: AsyncModeration }, author_id="authorId", channel="channel", + client_action={ + "action": "review", + "behavior": "override", + "reason": "reason", + "source": "source", + }, content_id="contentId", conversation_id="conversationId", do_not_store=True, From f72e4914e5d5b5496b2e2bf61b67785b0294c9c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 08:25:07 +0000 Subject: [PATCH 2/2] release: 1.24.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/moderation_api/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cdcf20e..bfaab56 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.23.0" + ".": "1.24.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d697f1..fbad283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.24.0 (2026-06-02) + +Full Changelog: [v1.23.0...v1.24.0](https://github.com/moderation-api/sdk-python/compare/v1.23.0...v1.24.0) + +### Features + +* **api:** api update ([45d1814](https://github.com/moderation-api/sdk-python/commit/45d18143451c84ec01a86e55178901674b5bb5e3)) + ## 1.23.0 (2026-06-01) Full Changelog: [v1.22.0...v1.23.0](https://github.com/moderation-api/sdk-python/compare/v1.22.0...v1.23.0) diff --git a/pyproject.toml b/pyproject.toml index 11c51dc..31ecf22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "moderation_api" -version = "1.23.0" +version = "1.24.0" description = "The official Python library for the moderation-api API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/moderation_api/_version.py b/src/moderation_api/_version.py index 08811a8..0852e07 100644 --- a/src/moderation_api/_version.py +++ b/src/moderation_api/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "moderation_api" -__version__ = "1.23.0" # x-release-please-version +__version__ = "1.24.0" # x-release-please-version