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
12 changes: 6 additions & 6 deletions .castiron.stats.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
schema_version: 1
generation_id: aa334d19-49e5-459a-aa06-eae1aa10f9b6
openapi_spec_hash: 33197c21507247a70c52e3097dd39dbd
openapi_transformed_spec_hash: 0fafe1908d64bbb9e28934d046e8eef4
generation_id: 629365c8-c19e-4349-b8d4-1815a9bfa729
openapi_spec_hash: f56829f9ec48b31ed299c5fb497984d7
openapi_transformed_spec_hash: 400d42fb468bbe078e4f0c87c366490b
config_hash: db72038ac88cdb94ae1cafef6aada78e
codegen_sha: 272fc07df78a0966f186aa9cf4471d60e3f8c19a
codegen_hash: 7e10845027768a64557899710423f0fd5847fe80b1967e4d196e82a02759e04e
public_codegen_sha: 8f87a28c9e1bdeaf73ae32939ec48a40e22d250a
codegen_sha: a1d286ab5c57c5047e0acc339c0a2359d33678f9
codegen_hash: e5f930fec1f997ea02bd1746597be5ff2a24c1917743b5bf2d4a2ee617ef8e3b
public_codegen_sha: 5d14ef0360d1e1cfd09ff815f3a8339c8498e604
95 changes: 7 additions & 88 deletions api_reference/openapi.transformed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9617,15 +9617,15 @@ paths:
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "omni-moderation-latest",
"input": "I want to kill them."
"input": "...text to classify goes here..."
}'
python: |
from openai import OpenAI
client = OpenAI()

moderation = client.moderations.create(
model="omni-moderation-latest",
input="I want to kill them.",
input="...text to classify goes here...",
)
print(moderation)
javascript: |
Expand All @@ -9636,7 +9636,7 @@ paths:
async function main() {
const moderation = await openai.moderations.create({
model: "omni-moderation-latest",
input: "I want to kill them.",
input: "...text to classify goes here...",
});

console.log(moderation);
Expand All @@ -9653,88 +9653,7 @@ paths:
apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);

ClientResult<ModerationResult> moderation = client.ClassifyText("I want to kill them.");
response: |
{
"id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR",
"model": "omni-moderation-latest",
"results": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": true,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": true,
"violence": true,
"illicit": false,
"illicit/violent": false
},
"category_scores": {
"sexual": 1.1726012417057063e-05,
"hate": 0.22706663608551025,
"harassment": 0.5215635299682617,
"self-harm": 2.227119921371923e-06,
"sexual/minors": 7.107352217872176e-08,
"hate/threatening": 0.023547329008579254,
"violence/graphic": 3.391829886822961e-05,
"self-harm/intent": 1.646940972932498e-06,
"self-harm/instructions": 1.1198755256458526e-09,
"harassment/threatening": 0.5694745779037476,
"violence": 0.9971134662628174,
"illicit": 0.001,
"illicit/violent": 0.001
},
"category_applied_input_types": {
"sexual": [
"text"
],
"hate": [
"text"
],
"harassment": [
"text"
],
"self-harm": [
"text"
],
"sexual/minors": [
"text"
],
"hate/threatening": [
"text"
],
"violence/graphic": [
"text"
],
"self-harm/intent": [
"text"
],
"self-harm/instructions": [
"text"
],
"harassment/threatening": [
"text"
],
"violence": [
"text"
],
"illicit": [
"text"
],
"illicit/violent": [
"text"
]
}
}
]
}
ClientResult<ModerationResult> moderation = client.ClassifyText("...text to classify goes here...");
- title: Image and text
request:
curl: |
Expand Down Expand Up @@ -43664,13 +43583,13 @@ components:
- type: string
description: A string of text to classify for moderation.
default: ''
example: I want to kill them.
example: '...text to classify goes here...'
- type: array
description: An array of strings to classify for moderation.
items:
type: string
default: ''
example: I want to kill them.
example: '...text to classify goes here...'
- type: array
description: An array of multi-modal inputs to the moderation model.
items:
Expand Down Expand Up @@ -107471,7 +107390,7 @@ components:
text:
description: A string of text to classify.
type: string
example: I want to kill them
example: '...text to classify goes here...'
required:
- type
- text
Expand Down
2 changes: 1 addition & 1 deletion scripts/castiron/generated-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -7783,7 +7783,7 @@
},
"tests/api_resources/test_moderations.py": {
"mode": "100644",
"sha256": "7fc53147d634a25ae16dfc80fb3d21fb260acccc97c8f2a50ab4137f0b1b71c9"
"sha256": "adcca3e2545f71c66c5036f263995261928b13b06ee359f6aa2dbfee0a966abf"
},
"tests/api_resources/test_realtime.py": {
"mode": "100644",
Expand Down
16 changes: 8 additions & 8 deletions tests/api_resources/test_moderations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ class TestModerations:
@parametrize
def test_method_create(self, client: OpenAI) -> None:
moderation = client.moderations.create(
input="I want to kill them.",
input="...text to classify goes here...",
)
assert_matches_type(ModerationCreateResponse, moderation, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: OpenAI) -> None:
moderation = client.moderations.create(
input="I want to kill them.",
input="...text to classify goes here...",
model="omni-moderation-2024-09-26",
)
assert_matches_type(ModerationCreateResponse, moderation, path=["response"])

@parametrize
def test_raw_response_create(self, client: OpenAI) -> None:
response = client.moderations.with_raw_response.create(
input="I want to kill them.",
input="...text to classify goes here...",
)

assert response.is_closed is True
Expand All @@ -46,7 +46,7 @@ def test_raw_response_create(self, client: OpenAI) -> None:
@parametrize
def test_streaming_response_create(self, client: OpenAI) -> None:
with client.moderations.with_streaming_response.create(
input="I want to kill them.",
input="...text to classify goes here...",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -65,22 +65,22 @@ class TestAsyncModerations:
@parametrize
async def test_method_create(self, async_client: AsyncOpenAI) -> None:
moderation = await async_client.moderations.create(
input="I want to kill them.",
input="...text to classify goes here...",
)
assert_matches_type(ModerationCreateResponse, moderation, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
moderation = await async_client.moderations.create(
input="I want to kill them.",
input="...text to classify goes here...",
model="omni-moderation-2024-09-26",
)
assert_matches_type(ModerationCreateResponse, moderation, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
response = await async_client.moderations.with_raw_response.create(
input="I want to kill them.",
input="...text to classify goes here...",
)

assert response.is_closed is True
Expand All @@ -91,7 +91,7 @@ async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
async with async_client.moderations.with_streaming_response.create(
input="I want to kill them.",
input="...text to classify goes here...",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down
Loading